Document runtime exclusions and verify offline transfer savings

This commit is contained in:
Jonathan Sykes
2026-10-09 14:56:31 +08:00
parent dd09f66578
commit 8a4144eb00
11 changed files with 22411 additions and 3 deletions

View File

@@ -55,7 +55,6 @@ export function createAssetManifest(publicDir = './public', { hashing = true, bu
else {
const content = readFileSync(path);
bytes.set(url, content);
}
}
}
@@ -91,7 +90,7 @@ export function createAssetManifest(publicDir = './public', { hashing = true, bu
const swSource = bytes.get('/sw.js')?.toString() ?? null;
// Derived build metadata cannot be an input to its own hash. Canonicalize
// the index meta and SW injected tag, then publish hashes of the final bytes.
// All original bytes (including index/SW source) remain inputs via source hashes.
// All runtime source bytes (including index/SW source) remain inputs via source hashes.
let canonicalIndex = source === null ? null : stampIndex(embedAssets(source, files, groups, '__BUILD_TAG__', hashing), files, { hashing });
const canonical = { assetSync, files: { ...files }, groups, contracts };
if (canonicalIndex !== null && hashing) canonical.files['/index.html'] = { ...files['/index.html'], h: assetHash(canonicalIndex), s: Buffer.byteLength(canonicalIndex), source: files['/index.html'].h };

View File

@@ -94,7 +94,7 @@ test('non-runtime files stay deliverable but never affect manifest or build iden
for (const hashing of [true, false]) {
const first = createAssetManifest(dir, { hashing });
mkdirSync(join(dir, 'perf'), { recursive: true });
for (const name of ['app.test.js', 'app.test.mjs', 'README.md', 'license.txt', 'admin.html', 'perf/fixture.js']) {
for (const name of ['app.test.js', 'app.test.mjs', 'README.md', 'license.txt', 'admin.html', 'perf/fixture.js', 'sha256.c', 'framework.entry.js']) {
writeFileSync(join(dir, name), 'non-runtime');
const next = createAssetManifest(dir, { hashing });
expect(next.manifest.buildTag).toBe(first.manifest.buildTag);