Skip to content

Commit

Permalink
playing with cjs exports
Browse files Browse the repository at this point in the history
  • Loading branch information
frolic committed Feb 4, 2025
1 parent 2762cef commit 39a1ae4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
7 changes: 5 additions & 2 deletions packages/abi-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"license": "MIT",
"type": "module",
"exports": {
"./internal": "./dist/exports/internal.js"
"./internal": {
"import": "./dist/exports/internal.js",
"default": "./dist/exports/internal.cjs"
}
},
"typesVersions": {
"*": {
Expand All @@ -20,7 +23,7 @@
}
},
"bin": {
"abi-ts": "./bin/abi-ts.js"
"abi-ts": "./bin/abi-ts.cjs"
},
"files": [
"bin",
Expand Down
13 changes: 2 additions & 11 deletions packages/abi-ts/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { defineConfig } from "tsup";
import { baseConfig } from "../../tsup.config.base";

export default defineConfig((opts) => ({
...baseConfig(opts),
entry: ["src/exports/internal.ts", "src/bin/abi-ts.ts"],
target: "esnext",
format: ["esm"],
sourcemap: true,
minify: true,
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
}));
17 changes: 17 additions & 0 deletions tsup.config.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Options } from "tsup";

export function baseConfig(opts: Options): Options {
return {
target: "esnext",
format: ["esm", "cjs"],
minify: true,
sourcemap: true,
// don't generate DTS during watch mode because it's slow
// we're likely using TS source in this mode anyway
dts: !opts.watch,
// don't clean during watch mode to avoid removing
// previously-built DTS files, which other build tasks
// depend on
clean: !opts.watch,
};
}

0 comments on commit 39a1ae4

Please sign in to comment.