react-native: move out the hardcoded import() transform
Reviewed By: davidaurelio Differential Revision: D6196869 fbshipit-source-id: 237cd269a2f382851102e3e1ba3208f1460f8c0a
This commit is contained in:
Родитель
0230672275
Коммит
7f3090e453
|
@ -76,9 +76,6 @@ const getPreset = (src, options) => {
|
|||
) {
|
||||
plugins.push('transform-react-display-name');
|
||||
}
|
||||
if (isNull || src.indexOf('import(')) {
|
||||
plugins.push(require('../transforms/transform-dynamic-import'));
|
||||
}
|
||||
|
||||
if (options && options.dev) {
|
||||
plugins.push('transform-react-jsx-source');
|
||||
|
|
|
@ -1,32 +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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const template = require('babel-template');
|
||||
|
||||
const buildImport = template('Promise.resolve().then(() => require(ARGS))');
|
||||
|
||||
const TYPE_IMPORT = 'Import';
|
||||
|
||||
const plugin = {
|
||||
inherits: require('babel-plugin-syntax-dynamic-import'),
|
||||
|
||||
visitor: {
|
||||
CallExpression(path) {
|
||||
if (path.node.callee.type !== TYPE_IMPORT) {
|
||||
return;
|
||||
}
|
||||
const newImport = buildImport({ARGS: path.node.arguments});
|
||||
path.replaceWith(newImport);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = plugin;
|
Загрузка…
Ссылка в новой задаче