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

Differents services or inner polyfill-service #4

Closed
flintforge opened this issue Oct 26, 2017 · 3 comments
Closed

Differents services or inner polyfill-service #4

flintforge opened this issue Oct 26, 2017 · 3 comments

Comments

@flintforge
Copy link

Any way to get some polyfills in one service and the other with the polyfill-service delivered in the package ?

something like this perhaps ?

 new PolyfillInjectorPlugin([{
        polyfills: ['Promise'],
        service:'./js/promise.min.js'
    }, 
    {
        polyfills: [
            'String/prototype/startsWith',
        ],
    }])
@SebastianS90
Copy link
Owner

I'm currently working on the next release of this plugin. It will be possible to create one asset for each combination of needed polyfills. For example, if you configure that polyfills A, B and C are required, then webpack bundles assets for A, B, C, AB, AC, BC, ABC and the entry chunk will load the required one. The server does not need to do anything special because it just serves a static file that is contained in the bundle.
Of course, the overall bundle size will increase, but only one file per client is needed and it does not contain unnecessary polyfills, so it actually saves bandwidth.

Would that fit your needs, or do you need to rely on a polyfill-service that dynamically serves the files instead of generating every possible option at build time?

(There will still be the option to bundle only a single file contrasting all polyfills)

@SebastianS90
Copy link
Owner

The new version 1.0.0 with the change mentioned above is currently in the develop branch and can be installed using the @beta tag:

yarn add webpack-polyfill-injector@beta --dev
npm install webpack-polyfill-injector@beta --save-dev

Does that fit the needs requested here?

@SebastianS90 SebastianS90 mentioned this issue Dec 14, 2017
6 tasks
@SebastianS90
Copy link
Owner

1.0.0 has been released and supports the following configuration:

    entry: {
        entry1: `webpack-polyfill-injector?${JSON.stringify({
            modules: ['./src/entry1.js'],
            polyfills: ['Promise', 'Array.prototype.find'],
        })}!`,
        entry2: `webpack-polyfill-injector?${JSON.stringify({
            modules: ['./some-vendor-script-that-will-be-loaded-first.js', './src/entry2.js'],
            polyfills: ['String.prototype.startsWith'],
        })}!`,
    },

If you have other requirements that are not possible with the new update then please open a new issue explaining the use-case. Thanks!

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

No branches or pull requests

2 participants