diff --git a/CHANGELOG.md b/CHANGELOG.md index b24923c..83c11b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,12 @@ ## Unreleased - Added a lite version of Fastboard where `@netless/app-slide` is not registered.\ - You can save about 2 MB of the bundle size. + You can save about 1.8 MB of the bundle size. If you do not want to use PPTX or want to load it dynamically, import `@netless/fastboard/lite` to use it. + > [!NOTE] + > You set set `jspdf` as an external dependency to save another 1 MB if you do not need the export PDF function. + ## 0.3.12 - Fixed an error when UI config is updated to `{ toolbar: undefined }`. diff --git a/packages/buildtool/index.mjs b/packages/buildtool/index.mjs index ead26cf..ac5b355 100644 --- a/packages/buildtool/index.mjs +++ b/packages/buildtool/index.mjs @@ -100,7 +100,12 @@ export async function build({ if (!name.endsWith("-ui")) { let bundle = await rollup.rollup({ input: name.endsWith("-core") ? "src/lite.ts" : main, - plugins: [esbuildPlugin([], { "@netless/fastboard-core": "@netless/fastboard-core/lite" })], + plugins: [ + esbuildPlugin([], { + "@netless/fastboard-core": "@netless/fastboard-core/lite", + "@netless/fastboard-ui": "@netless/fastboard-ui/lite", + }), + ], external: [/^[@a-z]/], }); @@ -150,9 +155,10 @@ export async function build({ if (name.endsWith("-core")) { await dts.build("src/lite.ts", "dist/lite.d.ts", { exclude: ["svelte", "svelte/internal"] }); console.log("Built dist/lite.d.ts in", Date.now() - start + "ms"); - } else if (!name.endsWith("-ui")) { + } else { let code = fs.readFileSync("dist/index.d.ts", "utf-8"); code = code.replace(/@netless\/fastboard-core/g, "@netless/fastboard-core/lite"); + code = code.replace(/@netless\/fastboard-ui/g, "@netless/fastboard-ui/lite"); fs.writeFileSync("dist/lite.d.ts", code); console.log("Built dist/lite.d.ts in", Date.now() - start + "ms"); } diff --git a/packages/fastboard-ui/lite.d.ts b/packages/fastboard-ui/lite.d.ts new file mode 100644 index 0000000..5da62ac --- /dev/null +++ b/packages/fastboard-ui/lite.d.ts @@ -0,0 +1 @@ +export * from "./dist/lite"; diff --git a/packages/fastboard-ui/package.json b/packages/fastboard-ui/package.json index 59b4f66..fa4bb8b 100644 --- a/packages/fastboard-ui/package.json +++ b/packages/fastboard-ui/package.json @@ -6,7 +6,8 @@ "svelte": "dist/index.svelte.mjs", "files": [ "src", - "dist" + "dist", + "lite.d.ts" ], "repository": "netless-io/fastboard", "scripts": { @@ -22,7 +23,17 @@ "publishConfig": { "main": "dist/index.js", "module": "dist/index.mjs", - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.mjs" + }, + "./lite": { + "types": "./dist/lite.d.ts", + "default": "./dist/index.mjs" + } + } }, "dependencies": { "tippy.js": "^6.3.7"