Skip to content

Commit

Permalink
build: remove unused vite manifest for consistent build reproducibili…
Browse files Browse the repository at this point in the history
…ty (#1670)

# Motivation

No `vite-manifest.json`, no build reproducibility issue 😉.

See commented code for details.

# Changes

- delete `vite-manifest.json` with a post build script
- remove `make-reproducible` as it becomes unused 

# Notes

I opened today two issues in SvelteKit repo to share what we discovered:

- sveltejs/kit#8290
- sveltejs/kit#8291
  • Loading branch information
peterpeterparker committed Jan 11, 2023
1 parent bc149c2 commit 56c59b4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"build:csp": "node scripts/build.csp.mjs",
"build:robots": "node scripts/build.robots.mjs",
"build:preload": "node scripts/build.preload.mjs",
"build:reproducible": "node scripts/build.reproducible.mjs",
"build:post-process": "npm run build:robots && npm run build:csp && npm run build:reproducible",
"i18n": "node --experimental-json-modules scripts/i18n.types.js",
"dev": "npm run i18n && vite dev",
"build": "npm run i18n && vite build && npm run build:robots && npm run build:csp && ./scripts/make-reproducible",
"build": "npm run i18n && vite build && npm run build:post-process",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
Expand Down
25 changes: 25 additions & 0 deletions frontend/scripts/build.reproducible.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node
import { rmSync } from "fs";
import { join } from "path";

const dir = join(process.cwd(), "public");
const viteManifestFile = join(dir, "vite-manifest.json");

const deleteViteManifest = () =>
rmSync(viteManifestFile, {
force: true,
});

/**
* We are facing various issues with build reproducibility all linked with the `vite-manifest.json` that is generated by SvelteKit + ViteJS.
*
* Those open are:
* - https://github.com/sveltejs/kit/issues/8290
* - https://github.com/sveltejs/kit/issues/8291
*
* We can solve above issues with workarounds, but, as we actually do not need the `vite-manifest.json` as we do not process it in the backend, we can just remove it.
* See https://vitejs.dev/guide/backend-integration.html for some explanation about the usage of the file.
*
* Note that we do this "manually" because SvelteKit has currently no option to disable the script.
*/
deleteViteManifest();
5 changes: 0 additions & 5 deletions frontend/scripts/make-reproducible

This file was deleted.

0 comments on commit 56c59b4

Please sign in to comment.