Skip to content

Commit

Permalink
feat: support dynamic import in jest tests (close #922)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 3, 2018
1 parent 57ce32a commit 09ed0b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@vue/babel-preset-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module.exports = (context, options = {}) => {
// cli-plugin-jest sets this to true because Jest runs without bundling
if (process.env.VUE_CLI_BABEL_TRANSPILE_MODULES) {
envOptions.modules = 'commonjs'
// necessary for dynamic import to work in tests
plugins.push(require('babel-plugin-dynamic-import-node'))
}

// pass options along to babel-preset-env
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/babel-preset-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@babel/preset-stage-2": "^7.0.0-0",
"@babel/runtime": "^7.0.0-0",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-jsx-event-modifiers": "^2.0.5",
"babel-plugin-jsx-v-model": "^2.0.3",
"babel-plugin-transform-vue-jsx": "^3.5.1"
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,12 @@ babel-messages@^6.23.0:
dependencies:
babel-runtime "^6.22.0"

babel-plugin-dynamic-import-node@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.2.0.tgz#f91631e703e0595e47d4beafbb088576c87fbeee"
dependencies:
babel-plugin-syntax-dynamic-import "^6.18.0"

babel-plugin-istanbul@^4.1.4, babel-plugin-istanbul@^4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"
Expand All @@ -1213,6 +1219,10 @@ babel-plugin-jsx-v-model@^2.0.3:
html-tags "^2.0.0"
svg-tags "^1.0.0"

babel-plugin-syntax-dynamic-import@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da"

babel-plugin-syntax-jsx@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
Expand Down

0 comments on commit 09ed0b1

Please sign in to comment.