Fix unusable CJS build by scoping module type per dist directory#34
Fix unusable CJS build by scoping module type per dist directory#34NullVoxPopuli with Copilot wants to merge 5 commits into
Conversation
|
@copilot this is the worst approach you've ever done to a thing. you cannot ship additional package.jsons like this as it will break loads of other tools. Emit the cjs output correctly, as cjs. this should be very simple |
Switched approach: dropped the nested |
|
@copilot do we need a second tsconfig for cjs output? writing a whole node script for file renames is silly |
A second tsconfig alone won't do it — Dropped the standalone script and inlined the rename step directly into Happy to take a different direction if you'd prefer, e.g. renaming |
|
@copilot yea, time for rolldown |
Done — swapped |
The package declares
"type": "module"at the root but ships CommonJS output asdist/cjs/*.js, so Node parses the CJS entry as ESM and everyrequire('@handlebars/parser')throwsReferenceError: exports is not defined in ES module scope.Change
package.json— extendbuild:cjsandbuild:esmto emit a nestedpackage.jsonin each output directory, overriding the roottypeon a per-directory basis. No changes toexports,main,module, or file extensions.Resulting layout:
This is option #2 from the issue — the least invasive of the three suggested fixes, requiring no rename of build artifacts and no rewrite of the
exportsmap.