-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[feat] differential legacy builds #2745
Conversation
|
In my experimental implementation, I use a global init function for both Without legacy option:Output: <html>
<head>
...
<link rel="modulepreload" href="/_app/start-45fd8323.js">
<link rel="modulepreload" href="/_app/chunks/vendor-7bab4fb1.js">
<link rel="stylesheet" href="/_app/assets/start-61d1577b.css">
<script>
window._sveltekit_init = (start, imt, nodes)=> {
start({
target: document.querySelector("#app"),
paths: {"base":"","assets":""},
session: {},
host: location.host,
route: true,
spa: true,
trailing_slash: "never",
hydrate: null
});
}
</script>
<script type="module">
import { start } from "/_app/start-45fd8323.js";
window._sveltekit_init(start, m=>import(m), "");
</script>
</head>
...
</html> With legacy:
|
@smertelny is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
@@ -10,6 +10,7 @@ | |||
"type": "module", | |||
"dependencies": { | |||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", | |||
"@vitejs/plugin-legacy": "^1.6.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could @vitejs/plugin-legacy become an optional dependency?
That would keep the installation fast for non legacy projects
See my bug report sveltejs/svelte#7723 and the PR which fixes it sveltejs/svelte#7724. |
@@ -67,7 +67,7 @@ export class Renderer { | |||
* @param {{ | |||
* Root: CSRComponent; | |||
* fallback: [CSRComponent, CSRComponent]; | |||
* target: Node; | |||
* target: Element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why needed?
Trying to solve #12 using @vitejs/legacy-plugin
I was testing it on
examples/hn.svelte.dev
and it is already working for IE11 with some configuration forsvelte.config.js
:There are several challenges I could not solve by myself:
import { start } from "/_app/start-[hash].js";
), as Safari will execute this code anyway for bothtype="module"
andnomodule
scripts. Vite is adding some code checking for dynamic import support and for preventing Safari from executing nomodule scripts, but all scripts must be in separate js files (more on this in Safari nomodule gist and @vitejs/legacy-plugin) but start function execution is injected into html template.svelte.config.js
filepnpm-lock.yaml
: after installing @vitejs/plugin-legacy+typescript@4.4.4
was deleted. Was it my bad?Thank you for reading this wall of text =)