diff --git a/package.json b/package.json index 50a6587..8402d8d 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,16 @@ "types": "./dist/lib.d.cts", "default": "./dist/lib.cjs" } + }, + "./util": { + "import": { + "types": "./dist/util.d.mts", + "default": "./dist/util.mjs" + }, + "require": { + "types": "./dist/util.d.cts", + "default": "./dist/util.cjs" + } } }, "scripts": { diff --git a/rollup.config.ts b/rollup.config.ts index 22d5101..67c2c78 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -5,30 +5,40 @@ import ts from "rollup-plugin-ts" import pkg from "./package.json" assert { type: "json" } -export default defineConfig({ - input: "src/lib.ts", +export const createBundleConfig = ( + input: string, + name: keyof typeof pkg.exports, +) => ( + defineConfig({ + input, - output: [ - { - file: pkg.exports["."].import.default, - format: "esm", - }, + output: [ + { + file: pkg.exports[name].import.default, + format: "esm", + }, + { + file: pkg.exports[name].require.default, + format: "cjs", + }, + ], - { - file: pkg.exports["."].require.default, - format: "cjs", - }, - ], + external: id => !/^[./]/.test(id), - external: id => !/^[./]/.test(id), + plugins: [ + nodeResolve(), + ts(), - plugins: [ - nodeResolve(), - ts(), + cleanup({ + comments: "jsdoc", + extensions: ["ts"], + }), + ], + }) +) - cleanup({ - comments: "jsdoc", - extensions: ["ts"], - }), - ], -}) + +export default [ + createBundleConfig("src/lib.ts", "."), + createBundleConfig("src/util/lib.ts", "./util"), +] diff --git a/src/lib.ts b/src/lib.ts index c929b01..0f31a88 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -1,5 +1,6 @@ export { abstract, expression, trait, + type Implements, type Trait, type TraitExpression } from "." diff --git a/src/util/lib.ts b/src/util/lib.ts new file mode 100644 index 0000000..4e2038a --- /dev/null +++ b/src/util/lib.ts @@ -0,0 +1,6 @@ +export { + Extend, + ExtendFn, + Extendable, + ExtendableFn +} from "."