Lib exports
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-06 00:04:40 +01:00
parent db15ee23ba
commit 23a6c6cfe4
4 changed files with 49 additions and 22 deletions

View File

@@ -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": {

View File

@@ -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"),
]

View File

@@ -1,5 +1,6 @@
export {
abstract, expression, trait,
type Implements,
type Trait,
type TraitExpression
} from "."

6
src/util/lib.ts Normal file
View File

@@ -0,0 +1,6 @@
export {
Extend,
ExtendFn,
Extendable,
ExtendableFn
} from "."