Skip to content
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

[bug] Parcel 2.9 is incompatible with Ant Design 5 #9081

Closed
TechQuery opened this issue Jun 8, 2023 · 9 comments
Closed

[bug] Parcel 2.9 is incompatible with Ant Design 5 #9081

TechQuery opened this issue Jun 8, 2023 · 9 comments

Comments

@TechQuery
Copy link

TechQuery commented Jun 8, 2023

🎛 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

  1. Dev mode works well.
  2. 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

idea2app/React-MobX-Ant-Design-ts@7da1093

🌍 Your Environment

Software Version(s)
Parcel 2.9.1
Node 16.20.0
PNPM 8.6.1
Operating System Windows 10 Pro 22H2
@Zillionr
Copy link

Zillionr commented Jun 9, 2023

I also have the same issue. I am using javascript instead of typescript. Please provide a solution.

@aamiriqubal
Copy link

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

@doronrosenberg
Copy link

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 |

@jotoh98
Copy link

jotoh98 commented Jul 14, 2023

Updating my .parcelrc worked. For now I'm falling back to the esbuild optimizer:

//.parcelrc
{
...
  "optimizers": {
      "*.js": ["@parcel/optimizer-esbuild"]
  }
}

@maximgeerinck
Copy link

This is also blocking our project, resolving the swc/core package to latest version didn't change anything either

@eugene-khyst
Copy link

eugene-khyst commented Sep 26, 2023

Are there any updates?
In Parcel 2.9.3 + Antd 5.9.3 the issue is still present.

@aamiriqubal
Copy link

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.

eugene-khyst added a commit to eugene-khyst/artistassistapp that referenced this issue Sep 26, 2023
@rsshilli
Copy link

rsshilli commented Jan 8, 2024

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.

@eugene-khyst
Copy link

With Parcel 2.12.0 and Antd 5.14.2 the issue is resolved.
No need to need to switch to esbuild optimizer anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants