-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parcel fails to bundle require('node:stream/web')
used in node-fetch
: gets transformed to import "8a78abd0b0f7c0d4:stream/web";
#7387
Labels
Comments
I'm having this issue too with the node: prefix. Webpack also crashed because of this |
danieltroger
changed the title
Parcel can't bundle
Parcel fails to bundle Dec 4, 2021
node-fetch
: @parcel/optimizer-terser: "Import" statement may only appear at the top levelrequire('node:stream/web')
used in node-fetch
: gets transformed to import "8a78abd0b0f7c0d4:stream/web";
Apparently both of these cases are broken: try {
// const process = require("node:process");
const process = require("process");
} catch (error) {} The first line results in import "2df1dca29011f67b:process";
try {
const process = $2df1dca29011f67b$import$e54fe5b0f43758f7;
// const process = require("process");
} catch (error) {
} and the second one in try {
// const process = require("node:process");
const process = $2df1dca29011f67b$import$e54fe5b0f43758f7;
} catch (error) {
} |
I just got this which also seems related, when using
|
evanw
added a commit
to rtsao/esbuild
that referenced
this issue
Oct 15, 2023
Bundling `alias` with `engine: node` needs `includeNodeModules: true` or aliases are ignored. See parcel-bundler/parcel#7387 (comment) for more info.
evanw
added a commit
to evanw/esbuild
that referenced
this issue
Oct 15, 2023
Bundling `alias` with `engine: node` needs `includeNodeModules: true` or aliases are ignored. See parcel-bundler/parcel#7387 (comment) for more info.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐛 bug report
I'm trying to bundle a node project into a single file. However, since including
node-fetch
it no longer works because they do this: https://github.com/node-fetch/fetch-blob/blob/c5c2b5215446334bf496733d4cdb48a981b4c440/streams.cjs#L10🎛 Configuration (.babelrc, package.json, cli command)
Package.json:
🤔 Expected Behavior
An epic build happens and then when you run the file in
dist
it logs a Response😯 Current Behavior
The issue is that they do this:
which becomes this:
Which is wrong and then kills terser
💁 Possible Solution
Idk what this magic new require syntax is but somehow fix that it works 👀
🔦 Context
I just wanted to fetch an url 😭
Also when bundling with
--no-optimize
it does some code splitting, is it possible to disable that? It'd be nice to have a single output file and I think that's even the point of"includeNodeModules": true
?💻 Code Sample
Please see this .zip file:
parcel-weird-imports.zip
Run
yarn install
thenyarn build
🌍 Your Environment
The text was updated successfully, but these errors were encountered: