You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: v5 loader-bundle with cjs: true calls _interopNamespace, which is not defined #7040
No component of the CommonJS build of a loader-bundle output target (cjs: true) can be loaded. Loading the first one throws:
ReferenceError: _interopNamespace is not defined
at …/dist/loader-bundle/cjs/runtime-Cvx3TWGo.js:299:65
Error: Constructor for "repro-cjs#undefined" was not found
The runtime chunk calls the helper once per component and defines it nowhere:
The CommonJS build loads its components, e.g. in Node with jsdom for unit tests.
4.45.1 does, with a dist output target and extras.enableImportInjection: its CommonJS core chunk defines _interopNamespace, and the same component renders.
System Info
System: node 22.21.0
Platform: darwin (27.0.0)
CPU Model: Apple M2 Pro (12 cpus)
Stencil: 5.0.0-rc.9 🏐
TypeScript: 6.0.3
Rolldown: 1.3.3
Terser: 5.51.4
DOM: jsdom 27.4.0
It builds the project and requires dist/loader-bundle/loader/index.cjs in Node with jsdom. Expected output is shadow root content: "<p>rendered</p>", actual output is the error above and an empty shadow root.
generateCaseClauseCjs() in packages/core/src/compiler/output-targets/dist-lazy/generate-lazy-module.ts writes _interopNamespace(require(…)) as text. That is a helper Rollup added to CommonJS output; the Rolldown output doesn't contain it. Import injection is on by default in v5 (compat.enableImportInjection), so every cjs: true build is affected.
Workaround: compat: { enableImportInjection: false }. The component in the reproduction renders with it.
The code is the same in 5.0.0-rc.10; I only ran rc.9 (and first saw this with rc.1).
The same error was reported in #6270 and fixed in #6272.
Activity
johnjenkins commentedon Nov 25, 2026
TYSM for trying out v5. This was fixed in 5.0.0-rc.11 🥳