diff --git a/android/android.iml b/android/android.iml
index 8dac732..0a2bd27 100644
--- a/android/android.iml
+++ b/android/android.iml
@@ -12,6 +12,7 @@
+
diff --git a/android/dus/build.gradle b/android/dus/build.gradle
index c18b6bd..da72ccb 100644
--- a/android/dus/build.gradle
+++ b/android/dus/build.gradle
@@ -37,7 +37,7 @@ dependencies {
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile 'org.mockito:mockito-core:2.18.0'
compile 'com.vimeo.stag:stag-library:2.5.1'
- compile 'com.facebook.react:react-native:0.47.+'
+ compile 'com.facebook.react:react-native:+'
annotationProcessor 'com.vimeo.stag:stag-library-compiler:2.5.1'
}
diff --git a/android/dus/dus.iml b/android/dus/dus.iml
index f54744d..43221af 100644
--- a/android/dus/dus.iml
+++ b/android/dus/dus.iml
@@ -107,7 +107,6 @@
-
@@ -115,11 +114,11 @@
+
+
-
-
@@ -135,16 +134,12 @@
-
-
-
-
\ No newline at end of file
diff --git a/android/dus/src/main/java/com/flipkart/dus/DUSContentProvider.java b/android/dus/src/main/java/com/flipkart/dus/DUSContentProvider.java
index 9ac213a..4cfe723 100644
--- a/android/dus/src/main/java/com/flipkart/dus/DUSContentProvider.java
+++ b/android/dus/src/main/java/com/flipkart/dus/DUSContentProvider.java
@@ -11,6 +11,7 @@
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -136,10 +137,10 @@ public Cursor query(@NonNull Uri uri, String[] projection, String selection, Str
} else {
String filePath = getFileHelper().getFilePath(getScreenMaker().getFileKey(screenType));
if (TextUtils.isEmpty(filePath)) {
- shouldRefresh = getScreenMaker().fetchPage(screenType, getContext());
screenInfo = new ScreenInfo();
screenInfo.status = DUSContracts.LOADING;
mCachedScreenInfo.put(screenType, screenInfo);
+ shouldRefresh = getScreenMaker().fetchPage(screenType, getContext());
cursor = generateResponse(DUSContracts.LOADING, "");
} else {
screenInfo = new ScreenInfo();
@@ -255,22 +256,32 @@ public int delete(@NonNull Uri uri, String selection, @Nullable String[] selecti
getLoggerInstance().log("[SYNC] [DELETE]" + uri.toString());
switch (sUriMatcher.match(uri)) {
case DUSContracts.JS_COMPONENTS:
- getDatabaseHelper().getWritableDatabase().execSQL("DELETE FROM " + TABLE_COMPONENTS + selection);
+ try {
+ getDatabaseHelper().getWritableDatabase().execSQL("DELETE FROM " + TABLE_COMPONENTS + selection);
+ } catch (SQLiteException e) {
+ //Do nothing. This is a rare case and the database file
+ //should get deleted when the db is opened the next time
+ }
break;
case DUSContracts.JS_BUNDLE:
if (selectionArgs != null) {
+ //Removing screentypes of those pages for which we are refreshing the bundles
for (String screenType :
selectionArgs) {
mCachedScreenInfo.remove(screenType);
}
+ //Removing bundle files for all pages. We try to keep
+ //all the bundle files which belong to the list of the files that needs to be deleted
+ //but already have a bundle formed with the latest update graph version
ArrayList filesToKeep = new ArrayList<>(selectionArgs.length);
for (String screenType : selectionArgs) {
- filesToKeep.add(getScreenMaker().getFileKey(screenType));
+ filesToKeep.add(screenType);
}
getFileHelper().deleteRestOfFiles(filesToKeep);
}
break;
case DUSContracts.CLEAR:
+ mCachedScreenInfo.clear();
getDatabaseHelper().getWritableDatabase().delete(TABLE_COMPONENTS, null, null);
getFileHelper().deleteAllFiles();
}
@@ -292,16 +303,21 @@ public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
getLoggerInstance().log("[SYNC] [BULK_INSERT] " + uri.toString());
switch (sUriMatcher.match(uri)) {
case DUSContracts.JS_COMPONENTS: {
- SQLiteDatabase database = getDatabaseHelper().getWritableDatabase();
- database.beginTransaction();
try {
- for (ContentValues contentValue :
- values) {
- database.insertWithOnConflict(TABLE_COMPONENTS, null, contentValue, SQLiteDatabase.CONFLICT_REPLACE);
+ SQLiteDatabase database = getDatabaseHelper().getWritableDatabase();
+ database.beginTransaction();
+ try {
+ for (ContentValues contentValue :
+ values) {
+ database.insertWithOnConflict(TABLE_COMPONENTS, null, contentValue, SQLiteDatabase.CONFLICT_REPLACE);
+ }
+ database.setTransactionSuccessful();
+ } finally {
+ database.endTransaction();
}
- database.setTransactionSuccessful();
- } finally {
- database.endTransaction();
+ } catch (SQLiteException e) {
+ //Do nothing. This is a rare case and the database file
+ //should get deleted when the db is opened the next time
}
}
}
@@ -361,7 +377,9 @@ public void attachInfo(Context context, @NonNull ProviderInfo info) {
Log.d(TAG, "Getting authority: " + DUSContracts.CONTENT_AUTHORITY);
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_JS_BUNDLE + "/*", DUSContracts.JS_BUNDLE);
+ sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_JS_BUNDLE, DUSContracts.JS_BUNDLE);
sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_JS_COMPONENTS + "/*", DUSContracts.JS_COMPONENTS);
+ sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_JS_COMPONENTS, DUSContracts.JS_COMPONENTS);
sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_UPDATEGRAPH, DUSContracts.UPDATE_GRAPH);
sUriMatcher.addURI(DUSContracts.CONTENT_AUTHORITY, DUSContracts.PATH_CLEAR, DUSContracts.CLEAR);
super.attachInfo(context, info);
diff --git a/android/dus/src/main/java/com/flipkart/dus/internals/ComponentDownloader.java b/android/dus/src/main/java/com/flipkart/dus/internals/ComponentDownloader.java
index e45a3ab..753c54c 100644
--- a/android/dus/src/main/java/com/flipkart/dus/internals/ComponentDownloader.java
+++ b/android/dus/src/main/java/com/flipkart/dus/internals/ComponentDownloader.java
@@ -45,7 +45,7 @@ public void addToDownloadQueue(@NonNull final DownloadJob downloadJob) {
mNetworkInterface.getResponseString(new ArrayList<>(downloadList), new ResponseInterface>() {
@Override
public void OnSuccess(@NonNull HashMap networkResponse) {
- if (networkResponse.size() != downloadJob.getComponentKeys().size()) {
+ if (networkResponse.size() != downloadList.size()) {
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setErrorResponse("Could not fetch all files");
clearCallbackMap();
diff --git a/android/dus/src/main/java/com/flipkart/dus/internals/ScreenMaker.java b/android/dus/src/main/java/com/flipkart/dus/internals/ScreenMaker.java
index 1e331a4..5babd46 100644
--- a/android/dus/src/main/java/com/flipkart/dus/internals/ScreenMaker.java
+++ b/android/dus/src/main/java/com/flipkart/dus/internals/ScreenMaker.java
@@ -3,6 +3,9 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
+import android.database.SQLException;
+import android.database.sqlite.SQLiteDatabaseCorruptException;
+import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
@@ -62,7 +65,12 @@ public boolean fetchPage(@NonNull final String screenType, @NonNull final Contex
screenTypeBeingProcessed.remove(screenType);
}
} else {
- fetchComponents(screenType, context, componentsKeys);
+ AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
+ @Override
+ public void run() {
+ fetchComponents(screenType, context, componentsKeys);
+ }
+ });
}
}
return refreshGraph;
@@ -72,19 +80,23 @@ public boolean fetchPage(@NonNull final String screenType, @NonNull final Contex
private void fetchComponents(@NonNull final String screenName, @NonNull final Context context, @NonNull final ArrayList componentsKeys) {
ArrayList keysToDownload = new ArrayList<>(componentsKeys.size());
keysToDownload.addAll(componentsKeys);
- Cursor cachedComponents = context.getContentResolver().query(DUSContracts.buildFetchContentsUri(screenName), null, DUSContracts.getComponentsQuery(componentsKeys), null, null);
final ArrayMap componentMap = new ArrayMap<>(componentsKeys.size());
- if (cachedComponents != null) {
- if (cachedComponents.getCount() > 0) {
- cachedComponents.moveToFirst();
- do {
- String key = cachedComponents.getString(cachedComponents.getColumnIndex(DatabaseHelper.COMPONENT_KEY));
- String value = cachedComponents.getString(cachedComponents.getColumnIndex(DatabaseHelper.COMPONENT_VALUE));
- componentMap.put(key, value);
- keysToDownload.remove(key);
- } while (cachedComponents.moveToNext());
+ try {
+ Cursor cachedComponents = context.getContentResolver().query(DUSContracts.buildFetchContentsUri(screenName), null, DUSContracts.getComponentsQuery(componentsKeys), null, null);
+ if (cachedComponents != null) {
+ if (cachedComponents.getCount() > 0) {
+ cachedComponents.moveToFirst();
+ do {
+ String key = cachedComponents.getString(cachedComponents.getColumnIndex(DatabaseHelper.COMPONENT_KEY));
+ String value = cachedComponents.getString(cachedComponents.getColumnIndex(DatabaseHelper.COMPONENT_VALUE));
+ componentMap.put(key, value);
+ keysToDownload.remove(key);
+ } while (cachedComponents.moveToNext());
+ }
+ cachedComponents.close();
}
- cachedComponents.close();
+ } catch (SQLException e) {
+ //DO nothing as the chunks would get downloaded.
}
if (keysToDownload.size() == 0) {
diff --git a/android/dus/src/main/java/com/flipkart/dus/internals/UpdateGraphManager.java b/android/dus/src/main/java/com/flipkart/dus/internals/UpdateGraphManager.java
index d0a9196..9bef2b7 100644
--- a/android/dus/src/main/java/com/flipkart/dus/internals/UpdateGraphManager.java
+++ b/android/dus/src/main/java/com/flipkart/dus/internals/UpdateGraphManager.java
@@ -122,7 +122,15 @@ private void optimizeCache(@NonNull FileConfig fileConfig, @NonNull Context cont
fileConfig.getCurrentUpdateGraph().entrySet()) {
componentList.addAll(screenList.getValue());
}
+ String[] fileList = new String[fileConfig.getCurrentUpdateGraph().size()];
context.getContentResolver().delete(DUSContracts.buildFetchContentsUri(""), DUSContracts.getOptimizeStorageWhereQuery(componentList), null);
+ int i = 0;
+ for (String file : fileConfig.getCurrentUpdateGraph().keySet()) {
+ fileList[i] = generateFileKey(file);
+ i++;
+ }
+ context.getContentResolver().delete(DUSContracts.buildFetchPageUri(""), null, fileList);
+ mFileConfigHelper.setShouldOptimize(false);
}
@Nullable
diff --git a/index.js b/index.js
index d10569e..78b4ad7 100644
--- a/index.js
+++ b/index.js
@@ -7,9 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
*
+ * @format
*/
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};function _toArray(arr) {return Array.isArray(arr) ? arr : Array.from(arr);}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}
+'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};function _toArray(arr) {return Array.isArray(arr) ? arr : Array.from(arr);}function _toConsumableArray(arr) {if (Array.isArray(arr)) {for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];return arr2;} else {return Array.from(arr);}}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}
const assert = require('assert');
const crypto = require('crypto');
@@ -129,6 +130,15 @@ require('../Logger');const createActionStartEntry = _require3.createActionStartE
+
+
+
+
+
+
+
+
+
@@ -150,15 +160,16 @@ class Bundler {
-
constructor(opts) {
this._opts = opts;
opts.projectRoots.forEach(verifyRootExists);
const transformModuleStr = fs.readFileSync(opts.transformModulePath);
- const transformModuleHash =
- crypto.createHash('sha1').update(transformModuleStr).digest('hex');
+ const transformModuleHash = crypto.
+ createHash('sha1').
+ update(transformModuleStr).
+ digest('hex');
const stableProjectRoots = opts.projectRoots.map(p => {
return path.relative(path.join(__dirname, '../../../..'), p);
@@ -183,8 +194,9 @@ class Bundler {
}
}
- const transformCacheKey = crypto.createHash('sha1').update(
- cacheKeyParts.join('$')).
+ const transformCacheKey = crypto.
+ createHash('sha1').
+ update(cacheKeyParts.join('$')).
digest('hex');
debug(`Using transform cache key "${transformCacheKey}"`);
@@ -192,8 +204,10 @@ class Bundler {
opts.transformModulePath,
opts.maxWorkers,
{
- stdoutChunk: chunk => opts.reporter.update({ type: 'worker_stdout_chunk', chunk }),
- stderrChunk: chunk => opts.reporter.update({ type: 'worker_stderr_chunk', chunk }) },
+ stdoutChunk: chunk =>
+ opts.reporter.update({ type: 'worker_stdout_chunk', chunk }),
+ stderrChunk: chunk =>
+ opts.reporter.update({ type: 'worker_stderr_chunk', chunk }) },
opts.workerPath);
@@ -204,8 +218,10 @@ class Bundler {
this._resolverPromise = Resolver.load({
assetExts: opts.assetExts,
+ assetRegistryPath: opts.assetRegistryPath,
blacklistRE: opts.blacklistRE,
extraNodeModules: opts.extraNodeModules,
+ getPolyfills: opts.getPolyfills,
getTransformCacheKey,
globalTransformCache: opts.globalTransformCache,
hasteImpl: opts.hasteImpl,
@@ -220,8 +236,8 @@ class Bundler {
reporter: opts.reporter,
resetCache: opts.resetCache,
sourceExts: opts.sourceExts,
- transformCode:
- (module, code, transformCodeOptions) => this._transformer.transformFile(
+ transformCode: (module, code, transformCodeOptions) =>
+ this._transformer.transformFile(
module.path,
module.localPath,
code,
@@ -239,8 +255,8 @@ class Bundler {
end() {
this._transformer.kill();
- return this._resolverPromise.then(
- resolver => resolver.getDependencyGraph().getWatcher().end());
+ return this._resolverPromise.then(resolver =>
+ resolver.getDependencyGraph().getWatcher().end());
}
@@ -251,36 +267,41 @@ class Bundler {
{const
dev = options.dev,minify = options.minify,unbundle = options.unbundle;
- return this._resolverPromise.then(
- resolver => resolver.getModuleSystemDependencies({ dev, unbundle })).
- then(moduleSystemDeps => this._bundle(_extends({},
+ const postProcessBundleSourcemap = this._opts.postProcessBundleSourcemap;
+ return this._resolverPromise.
+ then(resolver => resolver.getModuleSystemDependencies({ dev, unbundle })).
+ then(moduleSystemDeps =>
+ this._bundle(_extends({},
options, {
- bundle: new Bundle({ dev, minify, sourceMapUrl: options.sourceMapUrl }),
+ bundle: new Bundle({
+ dev,
+ minify,
+ sourceMapUrl: options.sourceMapUrl,
+ postProcessBundleSourcemap }),
+
moduleSystemDeps })));
+
}
_sourceHMRURL(platform, hmrpath) {
- return this._hmrURL(
- '',
- platform,
- 'bundle',
- hmrpath);
-
+ return this._hmrURL('', platform, 'bundle', hmrpath);
}
_sourceMappingHMRURL(platform, hmrpath) {
// Chrome expects `sourceURL` when eval'ing code
- return this._hmrURL(
- '\/\/# sourceURL=',
- platform,
- 'map',
- hmrpath);
-
+ return this._hmrURL('//# sourceURL=', platform, 'map', hmrpath);
}
- _hmrURL(prefix, platform, extensionOverride, filePath) {
- const matchingRoot = this._projectRoots.find(root => filePath.startsWith(root));
+ _hmrURL(
+ prefix,
+ platform,
+ extensionOverride,
+ filePath)
+ {
+ const matchingRoot = this._projectRoots.find(root =>
+ filePath.startsWith(root));
+
if (!matchingRoot) {
throw new Error('No matching project root for ' + filePath);
@@ -298,13 +319,22 @@ class Bundler {
return (
- prefix + resource +
- '.' + extensionOverride + '?' +
- 'platform=' + (platform || '') + '&runModule=false&entryModuleOnly=true&hot=true');
+ prefix +
+ resource +
+ '.' +
+ extensionOverride +
+ '?' +
+ 'platform=' + (
+ platform || '') +
+ '&runModule=false&entryModuleOnly=true');
}
- hmrBundle(options, host, port) {
+ hmrBundle(
+ options,
+ host,
+ port)
+ {
return this._bundle(_extends({},
options, {
bundle: new HMRBundle({
@@ -354,9 +384,11 @@ class Bundler {
{let assetPlugins = _ref.assetPlugins,bundle = _ref.bundle,dev = _ref.dev,entryFile = _ref.entryFile,entryModuleOnly = _ref.entryModuleOnly,generateSourceMaps = _ref.generateSourceMaps,hot = _ref.hot,isolateModuleIDs = _ref.isolateModuleIDs,minify = _ref.minify;var _ref$moduleSystemDeps = _ref.moduleSystemDeps;let moduleSystemDeps = _ref$moduleSystemDeps === undefined ? [] : _ref$moduleSystemDeps,onProgress = _ref.onProgress,platform = _ref.platform,resolutionResponse = _ref.resolutionResponse,runBeforeMainModule = _ref.runBeforeMainModule,runModule = _ref.runModule,unbundle = _ref.unbundle;
- const onResolutionResponse = response => {
+ const onResolutionResponse =
+ response =>
+ {
/* $FlowFixMe: looks like ResolutionResponse is monkey-patched
- * with `getModuleId`. */
+ * with `getModuleId`. */
bundle.setMainModuleId(response.getModuleId(getMainModule(response)));
if (entryModuleOnly && entryFile) {
response.dependencies = response.dependencies.filter(module =>
@@ -366,16 +398,25 @@ class Bundler {
response.dependencies = moduleSystemDeps.concat(response.dependencies);
}
};
- const finalizeBundle = (_ref2) => {let finalBundle = _ref2.bundle,transformedModules = _ref2.transformedModules,response = _ref2.response,modulesByName = _ref2.modulesByName;return (
+ const finalizeBundle = (_ref2) => {let
+ finalBundle = _ref2.bundle,
+ transformedModules = _ref2.transformedModules,
+ response = _ref2.response,
+ modulesByName = _ref2.modulesByName;return (
+
- this._resolverPromise.then(resolver => Promise.all(
+ this._resolverPromise.
+ then(resolver =>
+ Promise.all(
transformedModules.map((_ref3) => {let module = _ref3.module,transformed = _ref3.transformed;return (
finalBundle.addModule(resolver, response, module, transformed));}))).
+
+
then(() => {
const runBeforeMainModuleIds = Array.isArray(runBeforeMainModule) ?
runBeforeMainModule.
@@ -427,18 +468,20 @@ class Bundler {
{let entryFile = _ref4.entryFile,dev = _ref4.dev,minify = _ref4.minify,platform = _ref4.platform,bundle = _ref4.bundle,hot = _ref4.hot,unbundle = _ref4.unbundle,resolutionResponse = _ref4.resolutionResponse,isolateModuleIDs = _ref4.isolateModuleIDs,generateSourceMaps = _ref4.generateSourceMaps,assetPlugins = _ref4.assetPlugins;var _ref4$onResolutionRes = _ref4.onResolutionResponse;let onResolutionResponse = _ref4$onResolutionRes === undefined ? emptyFunction : _ref4$onResolutionRes;var _ref4$onModuleTransfo = _ref4.onModuleTransformed;let onModuleTransformed = _ref4$onModuleTransfo === undefined ? emptyFunction : _ref4$onModuleTransfo;var _ref4$finalizeBundle = _ref4.finalizeBundle;let finalizeBundle = _ref4$finalizeBundle === undefined ? emptyFunction : _ref4$finalizeBundle;var _ref4$onProgress = _ref4.onProgress;let onProgress = _ref4$onProgress === undefined ? emptyFunction : _ref4$onProgress;
- const transformingFilesLogEntry =
- log(createActionStartEntry({
+ const transformingFilesLogEntry = log(
+ createActionStartEntry({
action_name: 'Transforming files',
entry_point: entryFile,
environment: dev ? 'dev' : 'prod' }));
+
const modulesByName = Object.create(null);
if (!resolutionResponse) {
resolutionResponse = this.getDependencies({
entryFile,
+ rootEntryFile: entryFile,
dev,
platform,
hot,
@@ -449,8 +492,9 @@ class Bundler {
}
- return Promise.all(
- [this._resolverPromise, resolutionResponse]).
+ return Promise.all([
+ this._resolverPromise,
+ resolutionResponse]).
then((_ref5) => {var _ref6 = _slicedToArray(_ref5, 2);let resolver = _ref6[0],response = _ref6[1];
bundle.setRamGroups(response.options.ramGroups);
@@ -459,12 +503,15 @@ class Bundler {
// get entry file complete path (`entryFile` is a local path, i.e. relative to roots)
let entryFilePath;
- if (response.dependencies.length > 1) {// skip HMR requests
- const numModuleSystemDependencies =
- resolver.getModuleSystemDependencies({ dev, unbundle }).length;
+ if (response.dependencies.length > 1) {
+ // skip HMR requests
+ const numModuleSystemDependencies = resolver.getModuleSystemDependencies(
+ { dev, unbundle }).
+ length;
const dependencyIndex =
- (response.numPrependedDependencies || 0) + numModuleSystemDependencies;
+ (response.numPrependedDependencies || 0) +
+ numModuleSystemDependencies;
if (dependencyIndex in response.dependencies) {
entryFilePath = response.dependencies[dependencyIndex].path;
@@ -472,8 +519,7 @@ class Bundler {
}
const modulesByTransport = new Map();
- const toModuleTransport =
- module =>
+ const toModuleTransport = module =>
this._toModuleTransport({
module,
bundle,
@@ -507,8 +553,14 @@ class Bundler {
module: modulesByTransport.get(transformed),
transformed }));
- return finalizeBundle({ bundle, transformedModules, response, modulesByName });
- }).then(() => bundle);
+ return finalizeBundle({
+ bundle,
+ transformedModules,
+ response,
+ modulesByName });
+
+ }).
+ then(() => bundle);
});
}
@@ -526,17 +578,17 @@ class Bundler {
- {let entryFile = _ref7.entryFile,platform = _ref7.platform;var _ref7$dev = _ref7.dev;let dev = _ref7$dev === undefined ? true : _ref7$dev;var _ref7$minify = _ref7.minify;let minify = _ref7$minify === undefined ? !dev : _ref7$minify;var _ref7$hot = _ref7.hot;let hot = _ref7$hot === undefined ? false : _ref7$hot;var _ref7$generateSourceM = _ref7.generateSourceMaps;let generateSourceMaps = _ref7$generateSourceM === undefined ? false : _ref7$generateSourceM;
- return this.getTransformOptions(
- entryFile,
- {
+
+
+ {let entryFile = _ref7.entryFile,rootEntryFile = _ref7.rootEntryFile,platform = _ref7.platform;var _ref7$dev = _ref7.dev;let dev = _ref7$dev === undefined ? true : _ref7$dev;var _ref7$minify = _ref7.minify;let minify = _ref7$minify === undefined ? !dev : _ref7$minify;var _ref7$hot = _ref7.hot;let hot = _ref7$hot === undefined ? false : _ref7$hot;var _ref7$generateSourceM = _ref7.generateSourceMaps;let generateSourceMaps = _ref7$generateSourceM === undefined ? false : _ref7$generateSourceM;
+ return this.getTransformOptions(rootEntryFile, {
+ enableBabelRCLookup: this._opts.enableBabelRCLookup,
dev,
generateSourceMaps,
hot,
minify,
platform,
projectRoots: this._projectRoots }).
-
then(bundlingOptions =>
this._resolverPromise.then(resolver =>
resolver.getShallowDependencies(entryFile, bundlingOptions.transformer)));
@@ -545,7 +597,9 @@ class Bundler {
}
getModuleForPath(entryFile) {
- return this._resolverPromise.then(resolver => resolver.getModuleForPath(entryFile));
+ return this._resolverPromise.then(resolver =>
+ resolver.getModuleForPath(entryFile));
+
}
getDependencies(_ref8)
@@ -568,10 +622,13 @@ class Bundler {
- {var _this = this;let entryFile = _ref8.entryFile,platform = _ref8.platform;var _ref8$dev = _ref8.dev;let dev = _ref8$dev === undefined ? true : _ref8$dev;var _ref8$minify = _ref8.minify;let minify = _ref8$minify === undefined ? !dev : _ref8$minify;var _ref8$hot = _ref8.hot;let hot = _ref8$hot === undefined ? false : _ref8$hot;var _ref8$recursive = _ref8.recursive;let recursive = _ref8$recursive === undefined ? true : _ref8$recursive;var _ref8$generateSourceM = _ref8.generateSourceMaps;let generateSourceMaps = _ref8$generateSourceM === undefined ? false : _ref8$generateSourceM;var _ref8$isolateModuleID = _ref8.isolateModuleIDs;let isolateModuleIDs = _ref8$isolateModuleID === undefined ? false : _ref8$isolateModuleID,onProgress = _ref8.onProgress;return _asyncToGenerator(function* () {
+
+
+ {var _this = this;let entryFile = _ref8.entryFile,platform = _ref8.platform;var _ref8$dev = _ref8.dev;let dev = _ref8$dev === undefined ? true : _ref8$dev;var _ref8$minify = _ref8.minify;let minify = _ref8$minify === undefined ? !dev : _ref8$minify;var _ref8$hot = _ref8.hot;let hot = _ref8$hot === undefined ? false : _ref8$hot;var _ref8$recursive = _ref8.recursive;let recursive = _ref8$recursive === undefined ? true : _ref8$recursive;var _ref8$generateSourceM = _ref8.generateSourceMaps;let generateSourceMaps = _ref8$generateSourceM === undefined ? false : _ref8$generateSourceM;var _ref8$isolateModuleID = _ref8.isolateModuleIDs;let isolateModuleIDs = _ref8$isolateModuleID === undefined ? false : _ref8$isolateModuleID,rootEntryFile = _ref8.rootEntryFile,onProgress = _ref8.onProgress;return _asyncToGenerator(function* () {
const bundlingOptions = yield _this.getTransformOptions(
- entryFile,
+ rootEntryFile,
{
+ enableBabelRCLookup: _this._opts.enableBabelRCLookup,
dev,
platform,
hot,
@@ -598,21 +655,28 @@ class Bundler {
+
+
+
+
+
+
{let entryFile = _ref9.entryFile,dev = _ref9.dev,platform = _ref9.platform,minify = _ref9.minify,generateSourceMaps = _ref9.generateSourceMaps;
- return this.getDependencies({ entryFile, dev, platform, minify, generateSourceMaps }).then(
- (_ref10) => {let dependencies = _ref10.dependencies;
+ return this.getDependencies({
+ entryFile,
+ rootEntryFile: entryFile,
+ dev,
+ platform,
+ minify,
+ generateSourceMaps }).
+ then((_ref10) => {let dependencies = _ref10.dependencies;
const ret = [];
const promises = [];
const placeHolder = {};
dependencies.forEach(dep => {
if (dep.isAsset()) {
- const localPath = toLocalPath(
- this._projectRoots,
- dep.path);
-
- promises.push(
- this._assetServer.getAssetData(localPath, platform));
-
+ const localPath = toLocalPath(this._projectRoots, dep.path);
+ promises.push(this._assetServer.getAssetData(localPath, platform));
ret.push(placeHolder);
} else {
ret.push(dep.path);
@@ -622,12 +686,11 @@ class Bundler {
return Promise.all(promises).then(assetsData => {
assetsData.forEach((_ref11) => {let files = _ref11.files;
const index = ret.indexOf(placeHolder);
- ret.splice(index, 1, ...files);
+ ret.splice.apply(ret, [index, 1].concat(_toConsumableArray(files)));
});
return ret;
});
});
-
}
_toModuleTransport(_ref12)
@@ -653,7 +716,12 @@ class Bundler {
if (module.isAsset()) {
moduleTransport = this._generateAssetModule(
- bundle, module, moduleId, assetPlugins, transformOptions.platform);
+ bundle,
+ module,
+ moduleId,
+ assetPlugins,
+ transformOptions.platform);
+
}
if (moduleTransport) {
@@ -663,15 +731,14 @@ class Bundler {
return Promise.all([
module.getName(),
module.read(transformOptions)]).
- then((_ref13) =>
-
- {var _ref14 = _slicedToArray(_ref13, 2);let name = _ref14[0];var _ref14$ = _ref14[1];let code = _ref14$.code,dependencies = _ref14$.dependencies,dependencyOffsets = _ref14$.dependencyOffsets,map = _ref14$.map,source = _ref14$.source;const
+ then((_ref13) => {var _ref14 = _slicedToArray(_ref13, 2);let name = _ref14[0];var _ref14$ = _ref14[1];let code = _ref14$.code,dependencies = _ref14$.dependencies,dependencyOffsets = _ref14$.dependencyOffsets,map = _ref14$.map,source = _ref14$.source;const
preloadedModules = options.preloadedModules;
const isPolyfill = module.isPolyfill();
const preloaded =
module.path === entryFilePath ||
isPolyfill ||
- preloadedModules && hasOwnProperty.call(preloadedModules, module.path);
+ preloadedModules &&
+ hasOwnProperty.call(preloadedModules, module.path);
return new ModuleTransport({
name,
@@ -701,9 +768,15 @@ class Bundler {
const isImage = isAssetTypeAnImage(extname(module.path).slice(1));
- return this._assetServer.getAssetData(localPath, platform).then(assetData => {
- return Promise.all([isImage ? sizeOf(assetData.files[0]) : null, assetData]);
- }).then(res => {
+ return this._assetServer.
+ getAssetData(localPath, platform).
+ then(assetData => {
+ return Promise.all([
+ isImage ? sizeOf(assetData.files[0]) : null,
+ assetData]);
+
+ }).
+ then(res => {
const dimensions = res[0];
const assetData = res[1];
const scale = assetData.scales[0];
@@ -721,8 +794,13 @@ class Bundler {
return this._applyAssetPlugins(assetPlugins, asset);
- }).then(asset => {var _generateAssetTransfo =
- generateAssetTransformResult(asset);const code = _generateAssetTransfo.code,dependencies = _generateAssetTransfo.dependencies,dependencyOffsets = _generateAssetTransfo.dependencyOffsets;
+ }).
+ then(asset => {var _generateAssetTransfo =
+
+
+
+
+ generateAssetTransformResult(this._opts.assetRegistryPath, asset);const code = _generateAssetTransfo.code,dependencies = _generateAssetTransfo.dependencies,dependencyOffsets = _generateAssetTransfo.dependencyOffsets;
return {
asset,
code,
@@ -789,14 +867,22 @@ class Bundler {
+
{var _this2 = this;return _asyncToGenerator(function* () {
const getDependencies = function (entryFile) {return (
- _this2.getDependencies(_extends({}, options, { entryFile })).
+ _this2.getDependencies(_extends({},
+ options, {
+ entryFile,
+ rootEntryFile: entryFile })).
then(function (r) {return r.dependencies.map(function (d) {return d.path;});}));};const
dev = options.dev,hot = options.hot,platform = options.platform;
const extraOptions = _this2._getTransformOptions ?
- yield _this2._getTransformOptions(mainModuleName, { dev, hot, platform }, getDependencies) :
+ yield _this2._getTransformOptions(
+ mainModuleName,
+ { dev, hot, platform },
+ getDependencies) :
+
{};var _extraOptions$transfo =
extraOptions.transform;const transform = _extraOptions$transfo === undefined ? {} : _extraOptions$transfo;
@@ -807,6 +893,7 @@ class Bundler {
minify: options.minify,
platform,
transform: {
+ enableBabelRCLookup: options.enableBabelRCLookup,
dev,
generateSourceMaps: options.generateSourceMaps,
hot,
@@ -825,7 +912,6 @@ class Bundler {
}}
-
function verifyRootExists(root) {
// Verify that the root exists.
assert(fs.statSync(root).isDirectory(), 'Root has to be a valid directory');
@@ -840,8 +926,8 @@ function createModuleIdFactory() {
const fileToIdMap = Object.create(null);
return (_ref17) => {let modulePath = _ref17.path;
if (!(modulePath in fileToIdMap)) {
- var moddedPath = modulePath.substring(modulePath.indexOf('fk-react-native'), modulePath.length);
- fileToIdMap[modulePath] = hashCode(moddedPath);
+ var moddedPath = modulePath.substring(modulePath.indexOf('fk-react-native'), modulePath.length);
+ fileToIdMap[modulePath] = hashCode(moddedPath);
}
return fileToIdMap[modulePath];
};
diff --git a/package.json b/package.json
index 9ae9205..0058904 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "dus-deployer",
- "version": "1.47.11",
+ "version": "1.49.0",
"description": "Deployment system for DUS",
"main": "index.js",
"scripts": {
@@ -22,10 +22,8 @@
"url": "https://github.com/Flipkart/DUS/issues"
},
"homepage": "https://github.com/Flipkart/DUS#readme",
- "peerDependencies": {
- "react-native": "^0.47.2"
- },
"dependencies": {
+ "react-native": "^0.49.5",
"fs-extra": "^5.0.0",
"md5": "^2.2.1",
"shelljs": "^0.7.8",