parcel: Parcel 2.0.0-alpha.3.2: * could not be cloned.
🐛 bug report
I have usual react project with webpack, babel@7, postcss@7 etc. And I tries to use parcel now. Parcel@1 is working good. But parcel@next show misterious error (see below).
- I found, that
fn(...args, function (err, ...re
is from@parcel/utils/lib/promisify.js:4:17
- Next I added more useful stacktrace using
console.error(new Error("i'm here"))
in lib/promisify.js (see below original error) - I had not found any
'could not be cloned'
in node_modules, so looks it comes from Node.js. DOMException says about it too.
❯ parcel build src/index.jsx
DOMException [DataCloneError]: function (...args) {
return new Promise(function (resolve, reject) {
fn(...args, function (err, ...re...<omitted>... } could not be cloned.
at Worker.postMessage (internal/worker.js:223:23)
at ThreadsWorker.send (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/threads/ThreadsWorker.js:62:17)
at Worker.send (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/Worker.js:81:17)
at Worker.call (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/Worker.js:91:10)
at WorkerFarm.processQueue (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/WorkerFarm.js:225:16)
at Worker.<anonymous> (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/WorkerFarm.js:182:35)
at Worker.emit (events.js:210:5)
at Worker.fork (/Users/mxtnr/rocket/felix/front/node_modules/@parcel/core/node_modules/@parcel/workers/lib/Worker.js:77:10)
useful stacktrace:
at module.exports (/Users/mxtnr/rocket/felix/front/node_modules/parcel/node_modules/@parcel/utils/lib/promisify.js:4:17)
at new NodeFS (/Users/mxtnr/rocket/felix/front/node_modules/parcel/node_modules/@parcel/fs/lib/NodeFS.js:48:58)
at Command.run (/Users/mxtnr/rocket/felix/front/node_modules/parcel/lib/cli.js:97:63)
at Command.listener (/Users/mxtnr/rocket/felix/front/node_modules/commander/index.js:315:8)
at Command.emit (events.js:210:5)
at Command.parseArgs (/Users/mxtnr/rocket/felix/front/node_modules/commander/index.js:654:12)
at Command.parse (/Users/mxtnr/rocket/felix/front/node_modules/commander/index.js:474:21)
at Object.<anonymous> (/Users/mxtnr/rocket/felix/front/node_modules/parcel/lib/cli.js:85:9)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
🎛 Configuration
Ok, I attached my configs, by parcel fails before it read any of them. When I install parcel into empty directory all going perfect.
cli command, .babelrc, .postcssrc, package.json,,,
parcel build test.jsx
.babelrc
{
"plugins": [],
"presets": [
["@babel/env", {
"targets": {
},
"modules": false,
"useBuiltIns": false,
"loose": true
}],
]
}
package.json (part)
{
"name": "front",
"version": "0.0.0",
"main": "src/index.jsx",
"dependencies": {
"react": "^16.11.0",
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"parcel": "^2.0.0-alpha.3.2",
"postcss-modules": "^1.4.1",
},
"alias": {
"src": "./src",
"utils": "./src/utils",
"components": "./src/components",
"public": "./src/public",
"layouts": "./src/layouts",
"actions": "./src/actions",
"containers": "./src/containers",
"pages": "./src/pages",
"reducers": "./src/reducers",
"widgets": "./src/widgets"
},
.postcssrc
{
"modules": true,
"plugins": {
"postcss-import": {},
"postcss-preset-env": {
"features": {},
"autoprefixer": {
"flexbox": false,
}
},
"postcss-nested": {}
},
"sourceMap": true,
}
.browserslistrc
last 2 Chrome version
last 1 Safari version
💁 Possible Solution
Looks like parcel tried to send function via PostMessage…
💻 Code Sample
it’s no matter, parcel fails before it can read any source code
src/test.jsx
export function foo () {}
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.0.0-alpha.3.2 |
Node | v12.13.0 |
npm/Yarn | 6.12.1/1.13.0 |
Operating System | macos 10.14.6 mojave |
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 18 (12 by maintainers)
TL;DR: As a workaround, use yarn instead of npm 😬
@fregante Great!
I think I’ve found the problem (it works with Yarn and is broken with npm): Some Parcel classes like
MemoryFS
orNodePackageManager
register themselves to make sure they are serialized properly (because the structured cloning algorithm between worker threads doesn’t support among others functions). For that, the individual plugins calledThe worker delegation in
@parcel/core
would then use that list of classes to prepare objects:Yarn hoists the dependencies and so
@parcel/utils
(and the classes list) exists only once.With npm however, every package get's its own list, so that objects of these classes aren't replaced and therefore cloning fails
Mh, which npm version are you using? I just tried it again and:
I’m having that issue here https://github.com/sindresorhus/refined-github/tree/WIP-parcel
Run
npm run build
It’s not a minimal example but perhaps it can be useful.
I’m just running
parcel build source/content.ts
and the error appears even ifcontent.ts
is empty. It must be some configuration or dependency conflict.Node v10.18.1 (or v12.14.1) Parcel 2.0.0-alpha.3.2 macOS 10.15.2
Also seen on GitHub Actions (Node 10) https://github.com/sindresorhus/refined-github/runs/387639076