parcel
parcel copied to clipboard
[bug] Parcel 2.9 is incompatible with Ant Design 5
🎛 Configuration
package.json
{
"dependencies": {
"@ant-design/cssinjs": "^1.10.1",
"@ant-design/icons": "^5.1.4",
"antd": "^5.6.1",
"browser-unhandled-rejection": "^1.0.2",
"koajax": "^0.8.4",
"lodash": "^4.17.21",
"mobx": "^5.15.7",
"mobx-i18n": "^0.3.15",
"mobx-react": "^6.3.1",
"mobx-restful": "^0.6.5",
"mobx-restful-table": "^1.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^6.12.0",
"react-router-class-tools": "^0.1.3",
"react-router-dom": "^6.12.0",
"web-utility": "^4.0.0"
},
"devDependencies": {
"@octokit/openapi-types": "^17.2.0",
"@parcel/packager-raw-url": "~2.9.1",
"@parcel/transformer-webmanifest": "~2.9.1",
"@types/lodash": "^4.14.195",
"@types/node": "^16.18.34",
"@types/react": "^17.0.60",
"@types/react-dom": "^17.0.20",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"parcel": "~2.9.1",
"prettier": "^2.8.8",
"process": "^0.11.10",
"typescript": "~5.1.3",
"workbox-cli": "^7.0.0"
},
"scripts": {
"start": "parcel src/index.html --open",
"pack": "parcel build src/index.html --public-url .",
"build": "rm -rf dist/ && npm run pack && workbox generateSW"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "ES2020",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"jsx": "react-jsx",
"lib": ["ES2020", "DOM"]
}
}
🤔 Expected Behavior
Build Ant Design 5 projects successfully.
😯 Current Behavior
- Dev mode works well.
- Build mode failed with the error shown below:
> parcel build src/index.html --public-url .
🚨 Build failed.
@parcel/optimizer-swc: cannot reassign to a variable declared with `const`
23333 | $parcel$export($d17d0f546e850da0$exports, "defaultPrefixCls", () => $d17d0f546e850da0$export$e4ec87ea71
> 23334 |
> | ^
23335 | $parcel$export($d17d0f546e850da0$exports, "default", () => $d17d0f546e850da0$export$2e2bcd8739ae039);
23336 | $parcel$export($d17d0f546e850da0$exports, "ConfigConsumer", () => $d17d0f546e850da0$re_export$ConfigCon
💁 Possible Solution
If I downgrade to Parcel 2.8.3, this bug disappeared.
💻 Code Sample
https://github.com/idea2app/React-MobX-Ant-Design-ts/pull/6/commits/7da1093cec23897d749e0d4e499f7eaa14025c1a
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.9.1 |
Node | 16.20.0 |
PNPM | 8.6.1 |
Operating System | Windows 10 Pro 22H2 |
I also have the same issue. I am using javascript instead of typescript. Please provide a solution.
I am also facing the same problem. Request you to kindly fix the problem.
Node version v18.16.0
antd v5.6.2
Parcel v2.9.2
Mac os ventura 13.4
Here is a minimal reproduction: https://github.com/doronrosenberg/-parcel-antd
❯ parcel-antd (main) ✘ npx parcel build index.html
🚨 Build failed.
@parcel/optimizer-swc: cannot reassign to a variable declared with `const`
9916 |
> 9917 |
> | ^
9918 | var $7ed5e10e08c170f8$exports = {};
9919 |
Updating my .parcelrc
worked. For now I'm falling back to the esbuild optimizer:
//.parcelrc
{
...
"optimizers": {
"*.js": ["@parcel/optimizer-esbuild"]
}
}
This is also blocking our project, resolving the swc/core package to latest version didn't change anything either
Are there any updates? In Parcel 2.9.3 + Antd 5.9.3 the issue is still present.
Unfortunately/Fortunately I ended up ditching parcel and using esbuild. It needed some work but it was worth ditching parcel as now the build time is faster and the build size also decreased.
I'm not even using Antd
and I have this problem :-(.
@parcel/optimizer-swc: cannot reassign to a variable declared with `const`
7000 |
> 7001 |
> | ^
7002 | parcelRegister("2QHqB", function(module, exports) {
7003 |
It's particularly rough because I have no idea how to debug this. What file of mine is even causing this? parcelRegister
doesn't exist anywhere in my code base.
With Parcel 2.12.0 and Antd 5.14.2 the issue is resolved. No need to need to switch to esbuild optimizer anymore.