Closed TechQuery closed 1 year ago
I can confirm this is happening to me as well. I have a prroject that seems to use a lot of parcel plugins when first built, and the only workaround is to install each missing dependency manually (the ones I can read in the console), re-run the build/watch and if more errors appear install the next missing dependency.
Another case is now with Node builtin polyfills:
so
import buffer from "buffer";
console.log(process, buffer);
with
{
"scripts": {
"start": "parcel example.js"
},
"dependencies": {
"parcel": "^2.8.2"
}
}
and pnpm also fails with pnpm failed to install modules
My problem is this issue also happens even if I put this in package.json:
"alias": {
"process": false,
"Buffer": false,
"buffer": false
},
EDIT: or
"alias": {
"process": {
"global": "{}"
},
"Buffer": {
"global": "{}"
},
"buffer": {
"global": "{}"
}
},
parcel still reads the JS, tries to resolve those, and asks pnpm to install them.
Is that a separate issue?
My problem is this issue also happens even if I put this in package.json:
Are you using a monorepo? For these globals, it needs to be put in the project root package.json
(And just process
and buffer
lower case is enough)
Are you using a monorepo?
I use a separate package.json per project, with zero cross-project relations, workspaces, or anything fancy.
Then please share a reproduction.
Then please share a reproduction.
Sure, this does it for me. Essentially import { fabric } from "fabric"
in a JS file.
issue-8304.zip
EDIT: Unzip, pnpm up
, and pnpm run deploy
should be enough to reproduce.
I didn't try to reduce down the @parcel/* imports in package.json, but I'm fairly sure you've got those under control.
@folknor
$ pnpm i && pnpm run deploy
βWARNβ deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
βWARNβ deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
Packages: +386
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /Users/niklas/Library/pnpm/store/v3
Virtual store is at: node_modules/.pnpm
Progress: resolved 411, reused 385, downloaded 0, added 386, done
devDependencies:
+ @parcel/config-default 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/core 2.0.0-nightly.1263 (2.8.3 is available)
+ @parcel/optimizer-cssnano 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/packager-css 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/packager-html 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/packager-raw-url 2.8.4-nightly.2888
+ @parcel/packager-svg 2.8.4-nightly.2888
+ @parcel/packager-xml 2.8.4-nightly.2888
+ @parcel/transformer-css 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-html 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-image 2.8.4-nightly.2888
+ @parcel/transformer-js 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-postcss 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-posthtml 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-raw 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-sass 2.0.0-nightly.1265 (2.8.3 is available)
+ @parcel/transformer-webmanifest 2.8.4-nightly.2888
+ @parcel/transformer-xml 2.8.4-nightly.2888
+ fabric 5.3.0
+ parcel 2.0.0-nightly.1263 (2.8.3 is available)
+ rimraf 4.4.0
+ sharp 0.31.3
Done in 7.3s
> test@1.0.0 deploy /Users/niklas/Downloads/issue-8304
> NODE_ENV=production pnpm run build
> test@1.0.0 build /Users/niklas/Downloads/issue-8304
> pnpm run -s clean && pnpm run parcel:build
> test@1.0.0 parcel:build /Users/niklas/Downloads/issue-8304
> parcel build index.html --no-source-maps --detailed-report 0 --target web
β¨ Built in 2.60s
dist/index.html 436 B 537ms
dist/index.5b1a866d.js 301.2 KB 993ms
There is indeed a message if I remove the alias
field. What OS are you on?
That is indeed weird. When I tried the testcase on a different computer it works as expected. I must have some kind of local pnpm configuration issue on that computer. Apologies for the confusion.
I run Linux on both.
Parcel detected a PNPM project, but failed to install Bundler modules automatically.
π Configuration
package.json
π€ Expected Behavior
Install missing Bundler modules automatically as NPM & Yarn projects does.
π― Current Behavior
pnpm build
pnpm i @parcel/transformer-typescript-types -D
π Possible Solution
I installed all the missing Bundler modules manually to make it work.
π¦ Context
idea2app/Idea-React#16
π Your Environment