parcel
parcel copied to clipboard
non-static `import()` becomes a regular `require`
This no longer works:
const url = 'https://cdn.skypack.dev/jszip@^3.10.0';
const {default: JSZip} = await import(url);
because import
is turned into a require
![Screen Shot 5](https://user-images.githubusercontent.com/1402241/179344926-a5cce2d6-76d8-46db-8b9a-bf5ae184f218.png)
I just found out that this is even documented: https://en.parceljs.org/javascript.html
![Screen Shot 8](https://user-images.githubusercontent.com/1402241/179345372-af397281-9d6b-4514-acdf-62f5b1adff04.png)
but it fails as is:
![Screen Shot 7](https://user-images.githubusercontent.com/1402241/179345377-c9676d02-03d8-45de-ac73-35cc368c3bd6.png)
Generated code:
![Screen Shot 6](https://user-images.githubusercontent.com/1402241/179345379-9bafad1c-5b17-4e5e-b00f-941faf6b571b.png)
Originally posted by @fregante in https://github.com/parcel-bundler/parcel/issues/7064#issuecomment-1186107582
I just found out that this is even documented: en.parceljs.org/javascript.html
(That are the docs for Parcel 1.x.)
As an egregious workaround, the dynamic import can be wrapped inside an eval
:
await eval(`import("https://cdn.jsdelivr.net/pyodide/v0.23.2/full/pyodide.js")`);