Skip to content

Commit 09ed0b1

Browse files
committed
feat: support dynamic import in jest tests (close #922)
1 parent 57ce32a commit 09ed0b1

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: packages/@vue/babel-preset-app/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module.exports = (context, options = {}) => {
2727
// cli-plugin-jest sets this to true because Jest runs without bundling
2828
if (process.env.VUE_CLI_BABEL_TRANSPILE_MODULES) {
2929
envOptions.modules = 'commonjs'
30+
// necessary for dynamic import to work in tests
31+
plugins.push(require('babel-plugin-dynamic-import-node'))
3032
}
3133

3234
// pass options along to babel-preset-env

Diff for: packages/@vue/babel-preset-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@babel/preset-stage-2": "^7.0.0-0",
2828
"@babel/runtime": "^7.0.0-0",
2929
"babel-helper-vue-jsx-merge-props": "^2.0.3",
30+
"babel-plugin-dynamic-import-node": "^1.2.0",
3031
"babel-plugin-jsx-event-modifiers": "^2.0.5",
3132
"babel-plugin-jsx-v-model": "^2.0.3",
3233
"babel-plugin-transform-vue-jsx": "^3.5.1"

Diff for: yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,12 @@ babel-messages@^6.23.0:
11891189
dependencies:
11901190
babel-runtime "^6.22.0"
11911191

1192+
babel-plugin-dynamic-import-node@^1.2.0:
1193+
version "1.2.0"
1194+
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.2.0.tgz#f91631e703e0595e47d4beafbb088576c87fbeee"
1195+
dependencies:
1196+
babel-plugin-syntax-dynamic-import "^6.18.0"
1197+
11921198
babel-plugin-istanbul@^4.1.4, babel-plugin-istanbul@^4.1.5:
11931199
version "4.1.5"
11941200
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"
@@ -1213,6 +1219,10 @@ babel-plugin-jsx-v-model@^2.0.3:
12131219
html-tags "^2.0.0"
12141220
svg-tags "^1.0.0"
12151221

1222+
babel-plugin-syntax-dynamic-import@^6.18.0:
1223+
version "6.18.0"
1224+
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da"
1225+
12161226
babel-plugin-syntax-jsx@^6.18.0:
12171227
version "6.18.0"
12181228
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"

0 commit comments

Comments
 (0)