Permalink
Browse files

feat(experimental): dynamic import

  • Loading branch information...
h13i32maru committed Nov 26, 2016
1 parent 8803005 commit d729f5f4e6ad7d7693888b43ab5d42cb78bc15dd
View
@@ -26,7 +26,7 @@
"cheerio": "0.20.0",
"color-logger": "0.0.3",
"escape-html": "1.0.3",
- "babylon": "6.11.2",
+ "babylon": "6.14.1",
"babel-generator": "6.11.4",
"babel-traverse": "6.12.0",
"fs-extra": "0.30.0",
View
@@ -69,6 +69,7 @@ export default class ESParser {
if (experimental.asyncGenerators) option.plugins.push('asyncGenerators');
if (experimental.decorators) option.plugins.push('decorators');
if (experimental.exportExtensions) option.plugins.push('exportExtensions');
+ if (experimental.dynamicImport) option.plugins.push('dynamicImport');
}
return option;
View
@@ -37,6 +37,7 @@
* @property {boolean} experimentalProposal.asyncGenerators
* @property {boolean} experimentalProposal.decorators
* @property {boolean} experimentalProposal.exportExtensions
+ * @property {boolean} experimentalProposal.dynamicImport
* @see https://esdoc.org/config.html
*/
@@ -0,0 +1,5 @@
+for (let i = 0; i < 10; i++) {
+ import(`mod${$i}.js`)
+ .then(module => console.log(module))
+ .catch(err => console.log(err));
+}
@@ -27,4 +27,9 @@ describe('ESParser', ()=>{
const ast = ESParser.parse({experimentalProposal: {exportExtensions: true}}, './test/fixture/syntax/ExportExtensions.js');
assert(ast.program.sourceType === 'module');
});
+
+ it('can parse "dynamic import"', ()=>{
+ const ast = ESParser.parse({experimentalProposal: {dynamicImport: true}}, './test/fixture/syntax/DynamicImport.js');
+ assert(ast.program.sourceType === 'module');
+ });
});

0 comments on commit d729f5f

Please sign in to comment.