feat(nestjs): add CJS output for CommonJS NestJS projects#39
Open
CaioCesarPS wants to merge 1 commit into
Open
feat(nestjs): add CJS output for CommonJS NestJS projects#39CaioCesarPS wants to merge 1 commit into
CaioCesarPS wants to merge 1 commit into
Conversation
…rojects NestJS uses "module": "commonjs" by default. The package was ESM-only, causing ERR_PACKAGE_PATH_NOT_EXPORTED whenever a standard NestJS app tried to import it. - Add "cjs" to tsup formats so dist/index.cjs is emitted on build - Add "require": "./dist/index.cjs" condition to the exports field
|
@CaioCesarPS is attempting to deploy a commit to the Pontus Abrahamsson's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a CommonJS build (
dist/index.cjs) to@getworkbench/nestjsby enabling thecjsformat in tsup and adding arequirecondition to theexportsfield.Why
NestJS projects use
"module": "commonjs"intsconfig.jsonby default. With the package being ESM-only, any standard NestJS app importing@getworkbench/nestjswould crash at startup with:This happens because TypeScript with
"module": "commonjs"compilesimportstatements (including dynamicimport()) torequire(), which cannot load ESM-only packages.Adding
"cjs"to the tsupformatarray emitsdist/index.cjsalongside the existingdist/index.js. Therequirecondition inexportsthen routes CommonJS consumers to the CJS build while ESM consumers continue using the existingdist/index.js.Checklist
bun run typecheck)bun run lint)bun run build)CHANGELOG.mdupdated if this affects users