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

is it possible to generate the polyfills for multiple bundles in one file? #547

Closed
enmanuelduran opened this issue May 17, 2019 · 4 comments
Labels

Comments

@enmanuelduran
Copy link

enmanuelduran commented May 17, 2019

We are using core-js 3 to polyfill our bundles in a multi-page application but it is adding 400k+ extra to our final js folder. We were thinking if maybe there is a way to add all the polyfills required in a single file so the same polyfills are not repeated in our individual bundles.

we are using these options:

{
    useBuiltIns: 'usage',
    corejs: 3,
    targets: {
        ie: '11',
    },
}

and we pass our entries like objects:

{
    chunkName: path,
    chunkName2: path2,
    ...
}

It is polyfilling all the bundles correctly but repeating the polyfills individually per bundle which is expected, we were wondering if there is maybe a way to move all polyfills to a single file (polyfills.js) to avoid repetitions?

@zloirock
Copy link
Owner

In your case could be better to use useBuiltIns: 'entry' and load required parts of core-js to a separate bundle.

@enmanuelduran
Copy link
Author

enmanuelduran commented May 18, 2019

This would have to be a manual process right? I mean I would have to manually add the polyfills into a polyfills file with manual requires?

@zloirock
Copy link
Owner

It's manual adding of core-js entries. Even if you add just core-js/stable and apply useBuiltIns: 'entry' for optimization for the target engines it will be much better than current 400k+. You can optimize it if you know which features can be used in your project and instead of core-js/stable to use more granular entry points.

@zloirock
Copy link
Owner

Your initial question about a kind of the second point from this, but at this moment we have no tool for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants