chore(build): Set "type": "commonjs" in dist/package.json (#8097)

Set "type": "commonjs" in the generated dist/package.json file,
since the .js files in the package root are CJS. This should be a
no-op since that's the default, but by setting it explicitly we
ensure that any change to the repository top-level
package.json to set "type": "module" won't break the
published package accidentally.
This commit is contained in:
Christopher Allen
2024-05-13 18:55:58 +01:00
committed by GitHub
parent c0298652af
commit 59584c3a57

View File

@@ -178,6 +178,12 @@ function packageJSON(done) {
const json = JSON.parse(JSON.stringify(getPackageJson()));
// Remove unwanted entries.
delete json['scripts'];
// Set "type": "commonjs", since that's what .js files in the
// package root are. This should be a no-op since that's the
// default, but by setting it explicitly we ensure that any chage to
// the repository top-level package.json to set "type": "module"
// won't break the published package accidentally.
json.type = 'commonjs';
// Write resulting package.json file to release directory.
if (!fs.existsSync(RELEASE_DIR)) {
fs.mkdirSync(RELEASE_DIR, {recursive: true});