webpack - Making all combinations of a polyfill bundle -
i want detect features on browser , load specific chunk exact polyfills need. example, assuming there 2 polyfills (lets call them , b), need 3 bundles created:
- polyfillbundle1.js - contains a
- polyfillbundle2.js - contains b
- polyfillbundle3.js - contains both , b
the idea load exact polyfillbundle based on modernizr has detected on browser. example, if browser 1 not polyfills, browser 2 needs module b , browser 3 needs everything, browser 2 polyfillbundle2.js , browser 3 polyfillbundle3.js
is there plugin doing this? if not, how go doing such thing?
one, naive way achieve write entry configuration this:
entry: { bundle1: "./bundle1", bundle2: "./bundle2", bundle3: "./bundle3", },
then @ each entry file require polyfills want each bundle.
i assume next step generate configuration , bundles dynamically (generate permutations etc.) think above serve starting point.
it's not enough generate these bundles you'll need smart way make browser load right one...
note there services such polyfills.io solve lot of you. depending on case might 1 way go. alternatively generate worst case bundle (shims quite small) , serve each user.
Comments
Post a Comment