You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable ES6 modules through setting "type": "module" in package.json
Rename babel.config.js to babel.config.cjs and vue.config.js to vue.config.cjs (do similar for others if applicable)
Add a system under test (e.g. App.vue) that uses top-level await.
Run npm run build -- --mode test
What is expected?
Successful build
What is actually happening?
Build fails
I have debugged this and it fails due to this code:
// Though in the vue-cli repo, we only use the two environment variables
// for tests, users may have relied on them for some features,
// dropping them may break some projects.
// So in the following blocks we don't directly test the `NODE_ENV`.
// Rather, we turn it into the two commonly used feature flags.
if (!process.env.VUE_CLI_TEST && process.env.NODE_ENV === 'test') {
// Both Jest & Mocha set NODE_ENV to 'test'.
// And both requires the `node` target.
process.env.VUE_CLI_BABEL_TARGET_NODE = 'true'
// Jest runs without bundling so it needs this.
// With the node target, tree shaking is not a necessity,
// so we set it for maximum compatibility.
process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = 'true'
}
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.
- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
the `.cjs` extension:
- `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
- `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
- `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
eslint/eslint#14137)
- `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
- Provide a workaround for Vue CLI & Mocha ES6 modules conflict in
Vue configuration file (vuejs/vue-cli#7417).
Configure project to use ES6 modules to enable top-level await
capabilities. This change helps project to align well with modern JS
standards.
- Set `type` to `module` in `package.json`.
- Use import/export syntax in Cypress configuration files.
- Rename configurations files that do not support modules to use
the `.cjs` extension:
- `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477).
- `babel.config.js` to `babel.config.cjs (babel/babel-loader#894)
- `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440,
eslint/eslint#14137)
- `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771)
- Provide a workaround for Vue CLI & Mocha ES6 modules conflict in
Vue configuration file (vuejs/vue-cli#7417).
Version
5.0.8
Reproduction link
github.com
Environment info
Steps to reproduce
"type": "module"
in package.jsonnpm run build -- --mode test
What is expected?
Successful build
What is actually happening?
Build fails
I have debugged this and it fails due to this code:
Exactly this line is causing the error
process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = 'true'
.Setting this variable forces
envOptions.modules = 'commonjs'
which breaks the project.My current workaround to add following to vue.config file to force if statement to be false:
Hope it helps others with same setup.
The text was updated successfully, but these errors were encountered: