mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-22 20:38:55 -05:00
feat(babel): expose loose option
This commit is contained in:
@@ -50,3 +50,7 @@ This is the default Babel preset used in all Vue CLI projects.
|
||||
- **jsx**
|
||||
|
||||
Default: `true`. Set to `false` to disable JSX support.
|
||||
|
||||
- **loose**
|
||||
|
||||
Default: `false`. Setting this to `true` will generate code that is more performant but less spec-compliant.
|
||||
|
||||
@@ -14,12 +14,20 @@ module.exports = (context, options = {}) => {
|
||||
)
|
||||
}
|
||||
|
||||
const {
|
||||
loose = false,
|
||||
useBuiltIns = 'usage',
|
||||
modules = false,
|
||||
targets,
|
||||
decoratorsLegacy
|
||||
} = options
|
||||
|
||||
const envOptions = {
|
||||
modules: options.modules || false,
|
||||
targets: options.targets,
|
||||
useBuiltIns: typeof options.useBuiltIns === 'undefined' ? 'usage' : options.useBuiltIns
|
||||
loose,
|
||||
modules,
|
||||
targets,
|
||||
useBuiltIns
|
||||
}
|
||||
delete envOptions.jsx
|
||||
// target running node version (this is set by unit testing plugins)
|
||||
if (process.env.VUE_CLI_BABEL_TARGET_NODE) {
|
||||
envOptions.targets = { node: 'current' }
|
||||
@@ -37,8 +45,9 @@ module.exports = (context, options = {}) => {
|
||||
// stage 2. This includes some important transforms, e.g. dynamic import
|
||||
// and rest object spread.
|
||||
presets.push([require('@babel/preset-stage-2'), {
|
||||
useBuiltIns: true,
|
||||
decoratorsLegacy: options.decoratorsLegacy !== false
|
||||
loose,
|
||||
useBuiltIns: useBuiltIns !== false,
|
||||
decoratorsLegacy: decoratorsLegacy !== false
|
||||
}])
|
||||
|
||||
// transform runtime, but only for helpers
|
||||
|
||||
Reference in New Issue
Block a user