@phantom-labs/parcel-optimizer-suspend-amd
v0.0.3
Published
Suspends and then reenables usage of AMD for parcel generated js files
Downloads
23
Readme
parcel-optimizer-suspend-amd
What it fixes: Parcel breaks isolation by always exposing modules, causing a "Mismatched anonymous define()" error. if script is loaded any other way than via require.
Background of this optimizer is the following issue: https://github.com/parcel-bundler/parcel/issues/2451
This plugin wraps your bundle to:
- Caches reference to global define object to avoid conflicts with other global define objects (such as AMD's define function) before your content
- Restores global define object after your content
Usage
// .parcelrc
{
"extends": "@parcel/config-default",
"optimizers": {
"*.js": ["@parcel/optimizer-terser", "@phantom-labs/parcel-optimizer-suspend-amd"]
}
}
Thanks
Inspired by
- https://github.com/glomex/parcel-optimizer-disable-amd
- https://github.com/albinotonnina/parcel-plugin-wrapper
License
Apache 2.0 License