-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build output includes unused JS with static adapter #1371
Comments
For this purpose I have this line in my build pipeline: |
The user would still get a "100% static, no-JS" page as you mentioned, all those unused files would only exists in the server and won't be shipped to the user. But, what happens when some of the pages used it, would we need to scan for all the generated html files and see if there's any JS files that aren't linked or used? I'm guessing this would increase the build time significantly, thus I'm not sure what our best approach should be here. |
This is applicable to all pages, prerendered without router and hydration. Also slightly related #1197 |
There's not really any harm in this and it's not straightforward to change, so I don't think we'd change this |
This isn't strictly true. The harm is that you can't really rsync deploy the build output because it needs to be fixed in a separate build step. If I, the user, set |
Describe the bug
Using
adapter-static
and the config options:hydrate: false
androuter: false
—and no JS within any components—.js
files that aren't used are still output in./build
when runningnpm run build
.E.g. with this
svelte.config.js
:I get an output
index.html
that includes nolink
orscript
tags (as expected), but there are output.js
files such as./build/start-*.js
and.build/pages/index.svelte-*.js
.To Reproduce
adapter-static
and add it tosvelte.config.js
hydrate: false
androuter: false
insvelte.config.js
npm run build
Here's a reproduction example repo with the above configuration: https://github.com/matthew-ia/svelte-static-mvp
Expected behavior
Any files that aren't necessary for the build should not be included within
./build
Severity
Low
– while this behavior was confusing—I was under the impression the site needed all that JS which led me down a rabbit hole trying to figure out how to remove it—the outputindex.html
is still correct, and the use-case for having a 100% static, no-JS output is likely pretty niche.The text was updated successfully, but these errors were encountered: