Skip to content

Commit

Permalink
feat(babel): expose loose option
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 26, 2018
1 parent 6af7bbe commit 7a125d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/@vue/babel-preset-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
21 changes: 15 additions & 6 deletions packages/@vue/babel-preset-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand All @@ -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
Expand Down

0 comments on commit 7a125d4

Please sign in to comment.