Skip to content

Commit

Permalink
Fix exported extensions in package.json (#24)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lorisleiva authored Mar 14, 2024
1 parent a1c406f commit 289ccfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-taxis-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-solana-program": patch
---

Fix exported extensions in package.json
8 changes: 4 additions & 4 deletions template/clients/js/clients/js/package.json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"version": "0.0.0",
"description": "JavaScript client for the {{ programName | titleCase }} program",
"sideEffects": false,
"module": "./dist/src/index.mjs",
"main": "./dist/src/index.js",
"module": "./dist/src/index.js",
"main": "./dist/src/index.cjs",
"types": "./dist/types/src/index.d.ts",
"type": "module",
"exports": {
".": {
"types": "./dist/types/src/index.d.ts",
"import": "./dist/src/index.mjs",
"require": "./dist/src/index.js"
"import": "./dist/src/index.js",
"require": "./dist/src/index.cjs"
}
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions template/clients/js/clients/js/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const SHARED_OPTIONS: Options = {
entry: ['./src/index.ts'],
inject: [path.resolve(__dirname, 'env-shim.ts')],
outDir: './dist/src',
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.js' }),
sourcemap: true,
treeshake: true,
};
Expand Down

0 comments on commit 289ccfd

Please sign in to comment.