Skip to content

Commit 2f55f48

Browse files
author
Ives van Hoorne
committed
Support dynamic imports
1 parent d3fbd1b commit 2f55f48

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"dependencies": {
7272
"@emmetio/codemirror-plugin": "^0.3.5",
7373
"axios": "^0.16.2",
74+
"babel-plugin-dynamic-import-node": "^1.0.2",
7475
"babel-plugin-system-import": "^1.1.5",
7576
"babel-plugin-system-import-transformer": "3.1.0",
7677
"babel-plugin-transform-async-to-generator": "^6.24.1",

src/sandbox/eval/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const evalModule = (
5151
depth: number = 0,
5252
) => {
5353
if (depth > MAX_DEPTH) {
54-
throw new Error(`Exceeded the maximum require depth of ${MAX_DEPTH}.`);
54+
throw new Error(
55+
`Exceeded the maximum require depth of ${MAX_DEPTH}, there are probably two files depending on eachother.`,
56+
);
5557
}
5658
try {
5759
return doEval(mainModule, modules, directories, externals, depth);

src/sandbox/eval/js/babel-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import asyncPlugin from 'babel-plugin-transform-async-to-generator';
55
import restSpreadPlugin from 'babel-plugin-transform-object-rest-spread';
66
import classPropertiesPlugin from 'babel-plugin-transform-class-properties';
77
import decoratorsPlugin from 'babel-plugin-transform-decorators-legacy';
8+
import dynamicImportPlugin from 'babel-plugin-dynamic-import-node';
89

910
import evalModule from '../';
1011
import resolveDependency from './dependency-resolver';
@@ -18,13 +19,14 @@ const DEFAULT_BABEL_CONFIG = {
1819
asyncPlugin,
1920
restSpreadPlugin,
2021
classPropertiesPlugin,
22+
dynamicImportPlugin,
2123
],
2224
retainLines: true,
2325
};
2426

2527
const resolvePlugin = (plugin: string, externals) => {
2628
try {
27-
return resolveDependency(plugin, externals)
29+
return resolveDependency(plugin, externals);
2830
} catch (e) {
2931
return resolveDependency(`babel-plugin-${plugin}`, externals);
3032
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,14 @@ babel-plugin-check-es2015-constants@^6.22.0:
676676
dependencies:
677677
babel-runtime "^6.22.0"
678678

679+
babel-plugin-dynamic-import-node@^1.0.2:
680+
version "1.0.2"
681+
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.0.2.tgz#adb5bc8f48a89311540395ae9f0cc3ed4b10bb2e"
682+
dependencies:
683+
babel-plugin-syntax-dynamic-import "^6.18.0"
684+
babel-template "^6.24.1"
685+
babel-types "^6.24.1"
686+
679687
babel-plugin-istanbul@^4.0.0:
680688
version "4.1.1"
681689
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.1.tgz#c12de0fc6fe42adfb16be56f1ad11e4a9782eca9"

0 commit comments

Comments
 (0)