Skip to content

Commit

Permalink
feat([publish]): pass "useBuiltIns" option to preset-env
Browse files Browse the repository at this point in the history
Using "useBuiltIns: 'entry'" makes babel import only polyfills that are used in code
  • Loading branch information
andrey-skl committed Sep 11, 2018
1 parent 0e5f8d8 commit cfc75a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable complexity */
const MIN_BABEL_VERSION = 7;

module.exports = function preset(api, opts) {
api.assertVersion(MIN_BABEL_VERSION);

const transformRuntime = opts.transformRuntime || false;
const useBuiltIns = opts.useBuiltIns || false;
const angularSupport = opts.angular || false;

return {
presets: [
require('@babel/preset-react'),
[require('@babel/preset-env'), {
useBuiltIns,
include: angularSupport
? ['transform-parameters'] // This fixes issue with transforming Angular code like `constructor(...args)`
: []
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-plugin-angularjs-annotate": "0.9.0"
},
"peerDependencies": {
Expand Down

0 comments on commit cfc75a6

Please sign in to comment.