nodejs/package.cjs.json
@repobuddy/typescript/nodejs/package.cjs.json is a package.json fragment that sets "type": "commonjs". Copy it
into a CommonJS build’s output folder as package.json.
Content
Section titled “Content”{ "type": "commonjs"}The package exports it under ./nodejs/*, so you can resolve it by name:
node -e "console.log(require.resolve('@repobuddy/typescript/nodejs/package.cjs.json'))"Two commands copy it for you:
buddy ts build cjsrunstscand then copies it tocjs/package.json.buddy ts copy-cjs-package-json <dir> [cwd]copies it to<cwd>/<dir>/package.json.
Behavior
Section titled “Behavior”- Node.js reads
.jsfiles by thetypefield of the nearestpackage.json. In a package whose rootpackage.jsonhas"type": "module", acjs/package.jsonwith"type": "commonjs"makes Node.js load the.jsfiles undercjs/as CommonJS. - The file has no other fields, so it does not change the package’s name, version, or
exports.