SSR bundle fails to load with rspack 2.3.2

Open
#2,093 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript

Research direction

Start with the SSR configuration in rspack.config.js and reproduce the failure with npm ci, npm run build, then node build/ssr.js on the Dependabot branch. Compare the minified bundle with the lit-html source and review the linked upstream issue and PR. Done when the SSR bundle loads with @rspack/core 2.3.2 or later and the test checks pass without disabling module concatenation or minimization.

Written by the indexing model from the issue text.

Description

needs triage
What information was incorrect, unhelpful, or incomplete?

The SSR bundle fails to load with @rspack/core 2.3.2 and 2.3.3 (2.3.1 works). @rspack/cli is not affected: main currently pairs @rspack/cli 2.3.2 with @rspack/core 2.3.1:

ReferenceError: Cannot access 'L' before initialization
    at lit-html/node/lit-html.js
    at lit-html/node/directives/unsafe-html.js
    at insane/toMap.js

This breaks npm run preview and npx @mdn/fred ssr, so the test checks fail on the Dependabot bump.

What did you expect to see?

The SSR bundle loads with @rspack/core 2.3.2 and later, so the bump can be merged.

Do you have any supporting links, references, or citations?

Related to https://github.com/mdn/fred/pull/2091

Related upstream issue: https://github.com/web-infra-dev/rspack/issues/16586

Do you have anything more you want to share?

Steps to reproduce: check out the PR branch, run npm ci, npm run build, then node build/ssr.js.

Setting optimization.concatenateModules: false (or minimize: false) on ssrConfig in rspack.config.js avoids the error with 2.3.2.

The minified SSR bundle contains let M=class I extends I{...} where the source is class I extends H in lit-html. The minifier renames H to I, which clashes with the class's own kept name (mangle: { keep_classnames: true }), so extends I refers to the class itself. This is the same bug family as the upstream issue above, whose fix (rspack 2.3.3) does not cover the extends clause. A new upstream issue is still needed.

Dominant language
JavaScript
Stars
242
Forks
66
Avg merge
1d 2m
Merged PRs (30d)
49

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mdn/fred

All issues in mdn/fred

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.