Skip to content

Commit

Permalink
js: fix cjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
dr497 committed Aug 6, 2024
1 parent e676e32 commit 52162ed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
14 changes: 7 additions & 7 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"dist"
],
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.cjs",
"types": "./dist/types/index.d.ts"
}
},
"repository": {
Expand All @@ -23,7 +23,7 @@
"homepage": "https://sns.guide",
"scripts": {
"dev": "tsc && node --trace-warnings dist/test.js",
"build": "rm -rf dist && rollup -c",
"build": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --outDir dist/types",
"prepublish": "rm -rf dist && rollup -c",
"prepack": "rm -rf dist && rollup -c",
"lint": "yarn pretty && eslint .",
Expand Down
21 changes: 18 additions & 3 deletions js/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@ export default {
],
output: [
{
dir: "dist/",
dir: "dist/esm",
format: "esm",
sourcemap: true,
entryFileNames: "[name].mjs",
exports: "named",
preserveModules: true,
preserveModulesRoot: "src",
},
{
dir: "dist/cjs",
format: "cjs",
sourcemap: true,
entryFileNames: "[name].cjs",
exports: "named",
preserveModules: true,
preserveModulesRoot: "src",
},
{ dir: "dist/", format: "cjs", sourcemap: true },
],
external: ["@solana/web3.js"],
plugins: [
Expand All @@ -42,7 +52,12 @@ export default {
dedupe: ["borsh", "@solana/spl-token", "bn.js", "buffer"],
}),
commonjs(),
typescript(),
typescript({
tsconfig: "./tsconfig.json",
declaration: false,
outDir: null,
declarationDir: null,
}),
babel({ babelHelpers: "bundled" }),
json(),
replace({
Expand Down
4 changes: 3 additions & 1 deletion js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es2019",
"outDir": "dist",
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"declarationDir": "dist/types",
"emitDeclarationOnly": true,
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
Expand Down

0 comments on commit 52162ed

Please sign in to comment.