Skip to content

Commit 60e7534

Browse files
committed
build: Publish NPM package with type commonjs
1 parent dda427f commit 60e7534

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "git",
1414
"url": "git+https://github.com/coderline/alphaTab.git"
1515
},
16-
"type": "module",
16+
"type": "commonjs",
1717
"main": "dist/alphaTab.js",
1818
"module": "dist/alphaTab.mjs",
1919
"typings": "dist/alphaTab.d.ts",
@@ -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)