refactor: switch to generated .d.ts (#835)

* build: generate d.ts

* fix: preserve PublicMethods

* fix: avoid exposing types of attrs

* refactor: use existing setoption type

* fix: expose root and chart

* feat: use symbol as injection key

* chore: add comment for the type casting of the exposed
This commit is contained in:
Yue JIN
2025-06-01 12:29:26 +08:00
committed by GitHub
parent 8be19fe2a5
commit f7ed1e1b7d
9 changed files with 229 additions and 613 deletions

View File

@@ -2,6 +2,7 @@ import replace from "@rollup/plugin-replace";
import esbuild from "rollup-plugin-esbuild";
import { dts } from "rollup-plugin-dts";
import css from "rollup-plugin-import-css";
import { defineConfig } from "rollup";
/**
* Modifies the Rollup options for a build to support strict CSP
@@ -73,12 +74,24 @@ const builds = [
},
];
export default [
export default defineConfig([
...builds.map((options) => configBuild(options, false)),
...builds.map((options) => configBuild(options, true)),
{
input: "src/index.d.ts",
plugins: [dts()],
input: "src/index.ts",
plugins: [
dts({
// https://github.com/unjs/unbuild/pull/57/files
compilerOptions: {
preserveSymlinks: false,
},
}),
{
load(id) {
if (id.endsWith(".css")) return "";
},
},
],
output: [
{
file: "dist/index.d.ts",
@@ -90,4 +103,4 @@ export default [
},
],
},
];
]);