Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 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 edmorley added the feature label Sep 29, 2019
@edmorley

This comment has been minimized.

Copy link
Member

@edmorley edmorley commented Sep 29, 2019

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

This comment has been minimized.

Copy link
Contributor Author

@timkelty 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

This comment has been minimized.

Copy link
Contributor Author

@timkelty timkelty commented Oct 10, 2019

@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

This comment has been minimized.

Copy link
Member

@edmorley 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

This comment has been minimized.

Copy link
Contributor Author

@timkelty timkelty commented Nov 3, 2019

K, I'll PR today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.