A polyfill for
fetch to keep Parcel working for those without it.
Why This Is Needed
TL;DR: multiple bundle support in Parcel, such as using the ability to require html partial files, makes direct use of both the
fetch APIs, directly.
This plugin is born of my frustaration with the scenario outline in parcel issue #2364. This requires additional intervention, since the native requirement of the potentially un-polyfilled APIs is prior to any polyfill via
babel-polyfill and isn't something that can be influenced inside the application source itself; at least not without convoluted efforts.
npm install --save-dev parcel-plugin-goodie-bag
No additional configuration required. If your app is being bundled by parcel and you have this plugin installed, the processed application will build with:
scripttag in its head pointing to the "goodie bag` script (the two polyfills)
- a "goodie bag" script file, placed in the destination directory (
outDirto parcel, defaults to
- the script tag will respect your configured
publicUrloption with Parcel (e.g.- prefixed with default
/or no root slash in the case of
I made use of a simple reproducible repository I had set up for tracking this issue.
If you see something fundamentally wrong with this, feel free to submit a PR.
Parcel is an amazing bundler with superpowers. The fact that my ability to support IE(11), a requirement for my day job, was hampered by this limitation of a multiple bundle scenario meant that I had to solve the problem myself. It is my hope that one day the configuration of Parcel will allow for the surfacing of base level APIs, such as
fetch to make this plugin unnecessary. Until then, I'll keep this available to provide some sanity.