Skip to content

[Bug]: production mode doesn't work if a version of formidable 1.x exists in the import graph for target: node #10005

@Aghassi

Description

@Aghassi

System Info

macOS or linux

rspack/core

any browser, this is target for node

Details

There exists a known issue in any package that depends on formidable 1.x where it expects some global to be set for production bundling. We happen to be using superagent v3.x transitively in our node_modules, and that depends on formidable 1.x. In webpack, it will ignore the require as it can't be statically analyzed so it still completes the production build. However, rspack fails with

ERROR in × JavaScript parsing error: Invalid assignment target
      ╭─[6839:19]
 6837 │ }),
 6838 │ "2666": (function (module, __unused_webpack_exports, __webpack_require__) {
 6839 │ if (global.GENTLY) __webpack_require__(145) = GENTLY.hijack(__webpack_require__(145));
      ·                    ────────────────────────
 6840 │ 
 6841 │ var util = __webpack_require__(3837),
      ╰────


ERROR in × JavaScript parsing error: The left-hand side of an assignment expression must be a variable or a property access.
      ╭─[6839:19]
 6837 │ }),
 6838 │ "2666": (function (module, __unused_webpack_exports, __webpack_require__) {
 6839 │ if (global.GENTLY) __webpack_require__(145) = GENTLY.hijack(__webpack_require__(145));
      ·                    ────────────────────────
 6840 │ 
 6841 │ var util = __webpack_require__(3837),

This should contain parity with webpack even if it is technically wrong.

Reproduce link

https://github.com/Aghassi/rspack-node-app-production-bundle-bug

Reproduce Steps

  1. Clone repo
  2. pnpm i
  3. pnpm run build:rspack
  4. See failure
  5. pnpm run build:webpack
  6. See success with warnings

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions