react-native: move out the hardcoded import() transform

Reviewed By: davidaurelio

Differential Revision: D6196869

fbshipit-source-id: 237cd269a2f382851102e3e1ba3208f1460f8c0a
This commit is contained in:
Jean Lauliac 2017-11-01 05:27:52 -07:00 committed by Facebook Github Bot
parent cd67cd4794
commit 64645cbaab
3 changed files with 0 additions and 47 deletions

View File

@ -118,10 +118,6 @@ function require(moduleId: ModuleID | VerboseModuleNameForDev) {
: guardedLoadModule(moduleIdReallyIsNumber, module); : guardedLoadModule(moduleIdReallyIsNumber, module);
} }
require.async = function(moduleId: ModuleID | VerboseModuleNameForDev) {
return Promise.resolve().then(() => require(moduleId));
};
let inGuard = false; let inGuard = false;
function guardedLoadModule(moduleId: ModuleID, module) { function guardedLoadModule(moduleId: ModuleID, module) {
if (!inGuard && global.ErrorUtils) { if (!inGuard && global.ErrorUtils) {

View File

@ -36,12 +36,6 @@ function _require(moduleId) {
return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module); return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module);
} }
_require.async = function (moduleId) {
return Promise.resolve().then(function () {
return _require(moduleId);
});
};
var inGuard = false; var inGuard = false;
function guardedLoadModule(moduleId, module) { function guardedLoadModule(moduleId, module) {
if (!inGuard && global.ErrorUtils) { if (!inGuard && global.ErrorUtils) {
@ -203,12 +197,6 @@ function _require(moduleId) {
return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module); return module && module.isInitialized ? module.exports : guardedLoadModule(moduleIdReallyIsNumber, module);
} }
_require.async = function (moduleId) {
return Promise.resolve().then(function () {
return _require(moduleId);
});
};
var inGuard = false; var inGuard = false;
function guardedLoadModule(moduleId, module) { function guardedLoadModule(moduleId, module) {
if (!inGuard && global.ErrorUtils) { if (!inGuard && global.ErrorUtils) {

View File

@ -1,31 +0,0 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
const template = require('babel-template');
const makeAsyncRequire = template('require.async(ARGS)');
const plugin = {
inherits: require('babel-plugin-syntax-dynamic-import'),
visitor: {
CallExpression(path) {
if (path.node.callee.type !== 'Import') {
return;
}
const newImport = makeAsyncRequire({ARGS: path.node.arguments});
path.replaceWith(newImport);
},
},
};
module.exports = plugin;