From 7f3090e4530cc87c73ae7b3cdbdd6b28c8172ed7 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Wed, 1 Nov 2017 05:27:52 -0700 Subject: [PATCH] react-native: move out the hardcoded import() transform Reviewed By: davidaurelio Differential Revision: D6196869 fbshipit-source-id: 237cd269a2f382851102e3e1ba3208f1460f8c0a --- babel-preset/configs/main.js | 3 -- .../transforms/transform-dynamic-import.js | 32 ------------------- 2 files changed, 35 deletions(-) delete mode 100644 babel-preset/transforms/transform-dynamic-import.js diff --git a/babel-preset/configs/main.js b/babel-preset/configs/main.js index 7ba9288c8..1e80c902f 100644 --- a/babel-preset/configs/main.js +++ b/babel-preset/configs/main.js @@ -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'); diff --git a/babel-preset/transforms/transform-dynamic-import.js b/babel-preset/transforms/transform-dynamic-import.js deleted file mode 100644 index a402f6bb7..000000000 --- a/babel-preset/transforms/transform-dynamic-import.js +++ /dev/null @@ -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;