mirror of
https://github.com/kamranahmedse/driver.js.git
synced 2026-10-31 20:31:43 +08:00
- Generate the bundled dist/driver.js.d.ts during `vite build` via vite-plugin-dts (bundleTypes), dropping the separate dts-bundle-generator step and its config - Explicitly re-export the public types (Config, Popover, Side, etc.) from the entry so the bundled .d.ts keeps the same export surface; api-extractor only exports what the entry exports Verified: the generated .d.ts has an identical export surface and semantically identical type bodies to the previous output (12 types).
45 lines
983 B
TypeScript
45 lines
983 B
TypeScript
/// <reference types="vitest/config" />
|
|
import path from "path";
|
|
import { defineConfig } from "vite";
|
|
import dts from "vite-plugin-dts";
|
|
|
|
const packageName = "driver.js";
|
|
|
|
const fileName = {
|
|
es: `${packageName}.mjs`,
|
|
cjs: `${packageName}.cjs`,
|
|
iife: `${packageName}.iife.js`,
|
|
};
|
|
|
|
const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
|
|
|
|
export default defineConfig({
|
|
base: "./",
|
|
plugins: [
|
|
dts({
|
|
bundleTypes: true,
|
|
tsconfigPath: "./tsconfig.json",
|
|
}),
|
|
],
|
|
build: {
|
|
target: "es2020",
|
|
lib: {
|
|
entry: path.resolve(__dirname, "src/driver.ts"),
|
|
name: packageName,
|
|
formats,
|
|
fileName: format => fileName[format],
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
assetFileNames: assetInfo => {
|
|
const name = assetInfo.names?.[0] ?? assetInfo.name;
|
|
return name?.endsWith(".css") ? `driver.css` : (name as string);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
environment: "jsdom",
|
|
},
|
|
});
|