Skip to content

Commit dd60935

Browse files
authored
build: Publish NPM package with type commonjs (#2047)
1 parent dda427f commit dd60935

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
"test-csharp": "cd src.csharp && dotnet test -c Release",
6161
"test-kotlin": "node scripts/gradlew.mjs testReleaseUnitTest --info",
6262
"test-accept-reference": "tsx scripts/accept-new-reference-files.ts",
63-
"typecheck": "tsc --noEmit"
63+
"typecheck": "tsc --noEmit",
64+
"prepack": "node scripts/prepack.mjs"
6465
},
6566
"devDependencies": {
6667
"@biomejs/biome": "^1.9.4",

scripts/prepack.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import path from 'node:path';
2+
import url from 'node:url';
3+
import fs from 'node:fs';
4+
5+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
6+
const packageJsonPath = path.resolve(__dirname, '..', 'package.json');
7+
8+
9+
let packageJsonContent = await fs.promises.readFile(packageJsonPath, 'utf-8');
10+
packageJsonContent = packageJsonContent.replace('"type": "module"', '"type": "commonjs"');
11+
await fs.promises.writeFile(packageJsonPath, packageJsonContent);

0 commit comments

Comments
 (0)