[feat] differential legacy builds#2745
[feat] differential legacy builds#2745smertelny wants to merge 2 commits intosveltejs:masterfrom smertelny:legacy-builds
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. |
| "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.
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. |
| * Root: CSRComponent; | ||
| * fallback: [CSRComponent, CSRComponent]; | ||
| * target: Node; | ||
| * target: Element; |
Trying to solve #12 using @vitejs/legacy-plugin
I was testing it on
examples/hn.svelte.devand 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"andnomodulescripts. 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.jsfilepnpm-lock.yaml: after installing @vitejs/plugin-legacy+typescript@4.4.4was deleted. Was it my bad?Thank you for reading this wall of text =)