mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-30 03:09:10 -06:00
* refactor: use babel overrides to transpile babel runtime helpers As recommended in babel/babel#9903. Get rid of the module-resolver plugin, may fix #3928. Seems to have fixed #4742 as well. There may be a small breaking change: as we now use `excludes` & `includes`, babel requires `filename` option to be present (introduced in https://github.com/babel/babel/pull/10181/files). So users who call `babel.transformSync` directly may encounter an error. However, as we explicitly stated that this preset is only used for Vue CLI internally, I don't expect too many such use cases there. And the error messages are clear enough. Considering the benefits that this PR brings, I think it's an acceptable tradeoff. test: update tests for babel * test: fix windows tests * test: remove unused variables * fix: fix scope package paths on Windows * test: wait some time in router tests in case dom hasn't updated in time
@vue/cli-plugin-babel
babel plugin for vue-cli
Configuration
Uses Babel 7 + babel-loader + @vue/babel-preset-app by default, but can be configured via babel.config.js to use any other Babel presets or plugins.
By default, babel-loader excludes files inside node_modules dependencies. If you wish to explicitly transpile a dependency module, you will need to add it to the transpileDependencies option in vue.config.js:
module.exports = {
transpileDependencies: [
// can be string or regex
'my-dep',
/other-dep/
]
}
Caching
cache-loader is enabled by default and cache is stored in <projectRoot>/node_modules/.cache/babel-loader.
Parallelization
thread-loader is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting parallel: false in vue.config.js.
Installing in an Already Created Project
vue add babel
Injected webpack-chain Rules
config.rule('js')config.rule('js').use('babel-loader')config.rule('js').use('cache-loader')