From 59584c3a570f175913dd3572fb39a99e392f7ec9 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Mon, 13 May 2024 18:55:58 +0100 Subject: [PATCH] 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. --- scripts/gulpfiles/package_tasks.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/gulpfiles/package_tasks.js b/scripts/gulpfiles/package_tasks.js index 0c634e880..48dfd5b84 100644 --- a/scripts/gulpfiles/package_tasks.js +++ b/scripts/gulpfiles/package_tasks.js @@ -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});