Skip to content

Commit 71095b5

Browse files
committed
js: fix cjs build
1 parent 95063bb commit 71095b5

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

js/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package.json

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "@bonfida/spl-name-service",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"license": "MIT",
55
"files": [
66
"dist"
77
],
88
"type": "module",
9-
"main": "./dist/index.cjs",
10-
"module": "./dist/index.mjs",
11-
"types": "./dist/index.d.ts",
9+
"main": "./dist/cjs/index.cjs",
10+
"module": "./dist/esm/index.mjs",
11+
"types": "./dist/types/index.d.ts",
1212
"exports": {
1313
".": {
14-
"import": "./dist/index.mjs",
15-
"require": "./dist/index.cjs",
16-
"types": "./dist/index.d.ts"
14+
"import": "./dist/esm/index.mjs",
15+
"require": "./dist/cjs/index.cjs",
16+
"types": "./dist/types/index.d.ts"
1717
}
1818
},
1919
"repository": {
@@ -23,15 +23,14 @@
2323
"homepage": "https://sns.guide",
2424
"scripts": {
2525
"dev": "tsc && node --trace-warnings dist/test.js",
26-
"build": "rm -rf dist && rollup -c",
27-
"prepublish": "rm -rf dist && rollup -c",
28-
"prepack": "rm -rf dist && rollup -c",
26+
"build": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --outDir dist/types",
27+
"prepublish": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --outDir dist/types",
28+
"prepack": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --outDir dist/types",
2929
"lint": "yarn pretty && eslint .",
3030
"lint:fix": "yarn pretty:fix && eslint . --fix",
3131
"pretty": "prettier --check 'src/*.[jt]s'",
3232
"pretty:fix": "prettier --write 'src/*.[jt]s'",
33-
"test": "jest ./tests",
34-
"doc": "yarn typedoc src/index.ts"
33+
"test": "jest ./tests"
3534
},
3635
"devDependencies": {
3736
"@bonfida/prettier-config": "^1.0.0",

js/rollup.config.mjs

+18-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,23 @@ export default {
2525
],
2626
output: [
2727
{
28-
dir: "dist/",
28+
dir: "dist/esm",
2929
format: "esm",
3030
sourcemap: true,
3131
entryFileNames: "[name].mjs",
3232
exports: "named",
33+
preserveModules: true,
34+
preserveModulesRoot: "src",
35+
},
36+
{
37+
dir: "dist/cjs",
38+
format: "cjs",
39+
sourcemap: true,
40+
entryFileNames: "[name].cjs",
41+
exports: "named",
42+
preserveModules: true,
43+
preserveModulesRoot: "src",
3344
},
34-
{ dir: "dist/", format: "cjs", sourcemap: true },
3545
],
3646
external: ["@solana/web3.js"],
3747
plugins: [
@@ -42,7 +52,12 @@ export default {
4252
dedupe: ["borsh", "@solana/spl-token", "bn.js", "buffer"],
4353
}),
4454
commonjs(),
45-
typescript(),
55+
typescript({
56+
tsconfig: "./tsconfig.json",
57+
declaration: false,
58+
outDir: null,
59+
declarationDir: null,
60+
}),
4661
babel({ babelHelpers: "bundled" }),
4762
json(),
4863
replace({

js/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
"esModuleInterop": true,
1515
"allowSyntheticDefaultImports": true,
1616
"target": "es2019",
17-
"outDir": "dist",
17+
"outDir": "./dist",
1818
"rootDir": "./src",
1919
"declaration": true,
20+
"declarationDir": "dist/types",
21+
"emitDeclarationOnly": true,
2022
"noImplicitAny": false,
2123
"moduleResolution": "node",
2224
"sourceMap": true,

0 commit comments

Comments
 (0)