Skip to content

Commit 236cc68

Browse files
committed
Fix exported extensions in package.json
Before adding the “module” package type in #21, `tsup` was generating CJS files as `.js` and ESM files as `.mjs`. After the PR, `tsup` started doing the opposite — i.e. CJS files as `.cjs` and ESM files as `.js` meaning our `package.json` was pointing to the wrong files. This PR fixes this by updating the `package.json` accordingly but also defining the extension logic explicitly so we don’t get this sort of surprise in the future.
1 parent a1c406f commit 236cc68

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.changeset/giant-taxis-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-solana-program": patch
3+
---
4+
5+
Fix exported extensions in package.json

template/clients/js/clients/js/package.json.njk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"version": "0.0.0",
44
"description": "JavaScript client for the {{ programName | titleCase }} program",
55
"sideEffects": false,
6-
"module": "./dist/src/index.mjs",
7-
"main": "./dist/src/index.js",
6+
"module": "./dist/src/index.js",
7+
"main": "./dist/src/index.cjs",
88
"types": "./dist/types/src/index.d.ts",
99
"type": "module",
1010
"exports": {
1111
".": {
1212
"types": "./dist/types/src/index.d.ts",
13-
"import": "./dist/src/index.mjs",
14-
"require": "./dist/src/index.js"
13+
"import": "./dist/src/index.js",
14+
"require": "./dist/src/index.cjs"
1515
}
1616
},
1717
"files": [

template/clients/js/clients/js/tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const SHARED_OPTIONS: Options = {
77
entry: ['./src/index.ts'],
88
inject: [path.resolve(__dirname, 'env-shim.ts')],
99
outDir: './dist/src',
10+
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.js' }),
1011
sourcemap: true,
1112
treeshake: true,
1213
};

0 commit comments

Comments
 (0)