-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metro-bundler: transform import() to basic require()
Reviewed By: mjesun Differential Revision: D5631078 fbshipit-source-id: a8d4955a723c1846b9406e734c3e3fa2c0df3fb7
- Loading branch information
1 parent
fedc002
commit aaae99e
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* 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; |
aaae99e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I found an error, I think maybe it's in this commit. I do not know much about the modules, sorry for any confusion on my part. The error is this:
Bundling
index.android.js
[development, non-minified, hmr disabled]Bundling
index.android.js
[development, non-minified, hmr disabled] 0.0% (0/1), failed.Bundling
index.android.js
[development, non-minified, hmr disabled]error: bundling failed: "TransformError: C:\projects\jokenpo\joke\index.android.js: Unexpected token ) (While processing preset: "C:\\projects\\jokenpo\\joke\\node_modules\\babel-preset-react-native\\index.js")"
aaae99e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leomeneguzzi this issue is not because of this commit, see the PR – #15517, and issue – #15513 (comment)