rspack in monorepo mode + CJS seems to drop exports in main.ts
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 465
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 46
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
rspack in monorepo mode + CJS ignores the exports in main.ts.
main.ts:
let handler = defineAPIGatewayHandler({
appModule: AppModule,
authConf: 'admin',
basePath: '/web/admin',
});
export { handler };
Output of main.js:
let handler = (0,_lib_cli__rspack_import_0.defineAPIGatewayHandler)({
appModule: _AppModule__rspack_import_1.AppModule,
authConf: 'admin',
basePath: '/web/admin'
});
})();
})()
;
//# sourceMappingURL=main.js.map
When running in ESM mode, the output emits export { } as expected.
Output of main.js:
let handler = (0,_lib_cli_index_js__rspack_import_0.defineAPIGatewayHandler)({
appModule: _AppModule_js__rspack_import_1.AppModule,
authConf: 'admin',
basePath: '/web/admin'
});
/* snip */
var __webpack_exports__ = __webpack_require__("./apps/admin/src/main.ts");
var __webpack_exports__handler = __webpack_exports__.handler;
export { __webpack_exports__handler as handler };
//# sourceMappingURL=main.js.map
When running tsc in CJS mode, the output emits export.handler = handler as expected.
Output of main.js:
let handler = (0, cli_1.defineAPIGatewayHandler)({
appModule: AppModule_1.AppModule,
authConf: 'admin',
basePath: '/web/admin',
});
exports.handler = handler;
//# sourceMappingURL=main.js.map
Minimum reproduction code
Steps to reproduce
No response
Expected behavior
export.handler = handler should be emitted.
Package version
12.0.1
NestJS version
12.0.1
Node.js version
v22.23.2
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported main.ts example and compare the CJS output with the ESM and tsc outputs shown in the issue. Reproduce the behavior using nest-cli 12.0.1 in monorepo mode, then trace the CJS bundling path to determine why the export is omitted. Done means the generated main.js emits export.handler = handler for the CJS case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100