Closed ouksal closed 2 days ago
The intention is that the browser would request the .js
files for everything, and the server would automatically select the appropriate one, based on the encodings the browser says it can accept. The file would then reference other files with the .js
extension. The browser would never be requesting a filename with the .gz
or .br
extensions.
Describe the bug
When using @sveltejs/adapter-static with precompress: true, the .br and .gz files generated during the build process still reference the uncompressed versions of imported files. This breaks expected functionality because compressed files are served instead of their uncompressed counterparts, causing errors.
For instance, if foo.js imports bar.js, the generated foo.js.br and foo.js.gz still reference foo.js instead of foo.js.br or foo.js.gz. This makes the compressed files unusable without manual intervention.
Reproduction
src/lib/foo.js
src/lib/bar.js
console.log('This is bar.js');
Build the app using
npm run build
Inspect the generated output by either: Uncompressing one of the .gz or .br files to examine the import statements directly. or: Opening DevTools, navigating to the Network tab, enabling the "Content-Encoding" column, and verifying that files are incorrectly served with the wrong encoding references.
Logs
gzip -d start.TFu5MEUB.js.gz
import{c as a}from"../chunks/entry.BAIdZgoF.js";export{a as start};
System Info
Severity
blocking all usage of SvelteKit
Additional Information
Expected Behavior: The .br and .gz files should reference the corresponding compressed versions of imported files (bar.js.br or bar.js.gz), ensuring correct behavior when serving compressed files directly.