Skip to content

Commit

Permalink
fix: add lite.d.ts to the UI package
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Feb 29, 2024
1 parent ff42965 commit 2e907e6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
## Unreleased

- Added a <q>lite</q> 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 }`.
Expand Down
10 changes: 8 additions & 2 deletions packages/buildtool/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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]/],
});

Expand Down Expand Up @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions packages/fastboard-ui/lite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./dist/lite";
15 changes: 13 additions & 2 deletions packages/fastboard-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"svelte": "dist/index.svelte.mjs",
"files": [
"src",
"dist"
"dist",
"lite.d.ts"
],
"repository": "netless-io/fastboard",
"scripts": {
Expand All @@ -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"
Expand Down

0 comments on commit 2e907e6

Please sign in to comment.