-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(babel): better Babel polyfill defaults
- Now includes polyfills for Promise and Object.assign by default; - New option "polyfills" for @vue/babel-preset-app allows customization of included-by-default polyfills.
- Loading branch information
Showing
4 changed files
with
113 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// add polyfill imports to the first file encountered. | ||
module.exports = ({ types }) => { | ||
let entryFile | ||
return { | ||
name: 'vue-cli-inject-polyfills', | ||
visitor: { | ||
Program (path, state) { | ||
if (!entryFile) { | ||
entryFile = state.filename | ||
} else if (state.filename !== entryFile) { | ||
return | ||
} | ||
|
||
const { polyfills } = state.opts | ||
const { createImport } = require('@babel/preset-env/lib/utils') | ||
polyfills.forEach(p => { | ||
createImport(path, p) | ||
}) | ||
} | ||
} | ||
} | ||
} |