Skip to content

Build your personal knowledge base with Trilium Notes

fix(web-clipper): restore complete Firefox sources zip under wxt 0.21

Elian Doran1a793a81e0ed
diff --git a/apps/web-clipper/package.json b/apps/web-clipper/package.json
index 7ff26d18f2..c7a837fc5d 100644
--- a/apps/web-clipper/package.json
+++ b/apps/web-clipper/package.json
@@ -16,6 +16,7 @@
"packageManager": "[email protected]",
"devDependencies": {
"@wxt-dev/auto-icons": "1.1.1",
+ "jszip": "3.10.1",
"wxt": "0.21.1"
},
"dependencies": {
diff --git a/apps/web-clipper/wxt.config.ts b/apps/web-clipper/wxt.config.ts
index 4ce8c84b0f..f512bfa65f 100644
--- a/apps/web-clipper/wxt.config.ts
+++ b/apps/web-clipper/wxt.config.ts
@@ -1,4 +1,5 @@
import { copyFile, readFile, rm, writeFile } from "fs/promises";
+import JSZip from "jszip";
import { defineConfig } from "wxt";
let originalTsConfig: object;
@@ -56,10 +57,7 @@ export default defineConfig({
}
}),
zip: {
- artifactTemplate: "trilium-web-clipper-{{version}}-{{browser}}.zip",
- includeSources: [
- "entrypoints/offscreen/index.html"
- ]
+ artifactTemplate: "trilium-web-clipper-{{version}}-{{browser}}.zip"
},
hooks: {
'zip:sources:start': async () => {
@@ -74,12 +72,21 @@ export default defineConfig({
await writeFile("./tsconfig.json", JSON.stringify(adjustedTsConfig, null, 4), 'utf-8');
},
- "zip:sources:done": async () => {
+ "zip:sources:done": async (_wxt, sourcesZipPath) => {
// Restore original tsconfig.json
await writeFile("./tsconfig.json", JSON.stringify(originalTsConfig, null, 4), 'utf-8');
// Remove the copied tsconfig.base.json
await rm("./tsconfig.base.json");
+
+ // wxt always excludes skipped entrypoints (offscreen is Chrome-only) from the
+ // sources zip, but AMO needs complete sources to reproduce the build.
+ const archive = await JSZip.loadAsync(await readFile(sourcesZipPath));
+ archive.file("entrypoints/offscreen/index.html", await readFile("entrypoints/offscreen/index.html"));
+ await writeFile(sourcesZipPath, await archive.generateAsync({
+ type: "nodebuffer",
+ compression: "DEFLATE"
+ }));
}
}
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index cc8cbbca9d..a5b973e6c5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1042,6 +1042,9 @@ importers:
'@wxt-dev/auto-icons':
specifier: 1.1.1
+ jszip:
+ specifier: 3.10.1
+ version: 3.10.1
wxt:
specifier: 0.21.1