Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Make it easier to use useBuiltIns: 'usage' #1470

Closed
timkelty opened this issue Sep 26, 2019 · 5 comments · Fixed by #1484
Closed

Make it easier to use useBuiltIns: 'usage' #1470

timkelty opened this issue Sep 26, 2019 · 5 comments · Fixed by #1484
Labels
Milestone

Comments

@timkelty
Copy link
Contributor

timkelty commented Sep 26, 2019

AFAIK, if you want to change @babel/preset-env's useBuiltIns option, you have to pass the preset config in its entirety, e.g.:

const web = require('@neutrinojs/web');
module.exports = {
  use: [
    (neutrino) => neutrino.use(
      web({
        babel: {
          presets: [
            [
              require.resolve('@babel/preset-env'),
              {
                useBuiltIns: 'usage',
                debug: neutrino.options.debug,
                corejs: 3,
              },
            ],
          ],
        },
      })
    )
  ]
}

…would it be worth it to make this easier to change via options (similar to how we have options.targets)?

@edmorley
Copy link
Member

Perhaps we should switch from entry to usage by default? iirc the reason I didn't use usage in the past (which upgrading to Babel 7) was that (a) it was more buggy then, (b) it was harder for people to opt out if they didn't need to use a polyfill at all.

However since then, I'm presuming the bugs have been worked out solving (a), and we now dynamically set it to false based on whether core-js is found, which resolves (b).

Either way we should probably also now replace the @babel/polyfill references in the docs with core-js.

The description of entry vs usage can be seen here.

@timkelty
Copy link
Contributor Author

timkelty commented Sep 30, 2019

Perhaps we should switch from entry to usage by default

Sounds like that could be a good move. It used to be noted as "experimental" in Babel docs, but doesn't seem to be any longer.

I just started using it has seemed to work great so far, and dropped my bundle size significantly.

Either way we should probably also now replace the @babel/polyfill references in the docs with core-js.

Yep!

@timkelty
Copy link
Contributor Author

@edmorley I can squeeze in a PR tomorrow if you think changing this to usage would be good for v9. /cc @neutrinojs/core-contributors

@edmorley
Copy link
Member

edmorley commented Nov 3, 2019

@timkelty yeah let's do it :-)

@edmorley edmorley changed the title Make it easier to change the useBuiltIns option Make it easier to use useBuiltIns: 'usage' Nov 3, 2019
@edmorley edmorley added this to the Neutrino 9 milestone Nov 3, 2019
@timkelty
Copy link
Contributor Author

timkelty commented Nov 3, 2019

K, I'll PR today!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

2 participants