You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parcel bundles the target with node context correctly (forced for demonstration by injecting node: "1"):
$ npm run build
> @vad-systems/[email protected] build
> npx parcel build
✨ Built in 292ms
build/server/index.js 149 B 46ms
build/server/foo.1d7c16ab.js 233 B 53ms
with generated build/server/index.js:
var a={};a=import("./foo.1d7c16ab.js").then(()=>parcelRequire("7e5iT"));const{default:e}=await a;
//# sourceMappingURL=index.js.map
😯 Current Behavior
parcel errors out with the import()-polyfill check:
$ npm run build
> @vad-systems/[email protected] build
> npx parcel build
🚨 Build failed.
@parcel/runtime-js: No import() polyfill available for context 'node'
Error: No import() polyfill available for context 'node'
💁 Possible Solution
Add node entry to supportData['dynamic-import'] as appropriate. I would argue this is 15.3 (the esm module was stabilized for 15.3.0, with backport to 14.17.0 and 12.22.0 - while it would be more accurate, I don't think it's necessary to include the backport versions at this point), and am about to provide a pull request to that effect.
🔦 Context
pointless prose for background
Granted, this is a somewhat odd setup, but I have quite a bit of shared code between the server and client bundles, and while it naturally doesn't make much sense to split the code on the server, code-splitting on the client is rather useful. If I make use of parcel-specific features (such as transformers for non-js files), `isLibrary: true` for the server target stops being a useful option without making the toolchain more complicated again. Similarly, I do need to compile the server for a `node` context because the non-shared code in that target relies on node dependencies. I could probably work around this by moving the shared code out to a library, but that also makes code-splitting more tedious.
I haven't populated the repro repo with these additional constraints, as the bug itself seems to just be the missing supportData entry. This is further supported by the fact that matchesEngine does have a branch for node which just returns false for lack of an entry, and the reference to caniuse-api can't be the source for the existing node entries for arrow-functions and global-this.
🐛 bug report
Because
supportData['dynamic-import']
doesn't have an entry fornode
, dynamic imports fornode
targets with esm output cause theimport()
-polyfill check to trigger.🎛 Configuration (package.json, cli command)
As per the repro repo:
package.json:
cli command:
🤔 Expected Behavior
parcel bundles the target with
node
context correctly (forced for demonstration by injectingnode: "1"
):with generated
build/server/index.js
:😯 Current Behavior
parcel errors out with the
import()
-polyfill check:💁 Possible Solution
Add
node
entry tosupportData['dynamic-import']
as appropriate. I would argue this is15.3
(the esm module was stabilized for 15.3.0, with backport to 14.17.0 and 12.22.0 - while it would be more accurate, I don't think it's necessary to include the backport versions at this point), and am about to provide a pull request to that effect.🔦 Context
pointless prose for background
Granted, this is a somewhat odd setup, but I have quite a bit of shared code between the server and client bundles, and while it naturally doesn't make much sense to split the code on the server, code-splitting on the client is rather useful. If I make use of parcel-specific features (such as transformers for non-js files), `isLibrary: true` for the server target stops being a useful option without making the toolchain more complicated again. Similarly, I do need to compile the server for a `node` context because the non-shared code in that target relies on node dependencies. I could probably work around this by moving the shared code out to a library, but that also makes code-splitting more tedious.
I haven't populated the repro repo with these additional constraints, as the bug itself seems to just be the missing
supportData
entry. This is further supported by the fact thatmatchesEngine
does have a branch fornode
which just returns false for lack of an entry, and the reference tocaniuse-api
can't be the source for the existingnode
entries forarrow-functions
andglobal-this
.💻 Code Sample
minimal repro repo
🌍 Your Environment
The text was updated successfully, but these errors were encountered: