-
-
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
feat: migrate to vite environment API #13357
base: main
Are you sure you want to change the base?
Conversation
Moves the vite dev server to use the new environments API. This changes the following: - `vite.moduleGraph` is replaced by `vite.environments.ssr.moduleGraph` - `vite.ssrLoadModule` is replaced by `vite.environments.ssr.runner.import(url)`
|
@@ -64,9 +70,13 @@ export async function dev(vite, vite_config, svelte_config) { | |||
let manifest_error = null; | |||
|
|||
/** @param {string} url */ | |||
async function loud_ssr_load_module(url) { | |||
async function load_ssr_load_module(url) { | |||
if (!isRunnableDevEnvironment(viteEnv)) { |
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.
repeated logic because these functions are all hoisted before we've done our type guard on L38
AFAIK we can only do this when we do SvelteKit 3 and bump the Vite peer dependency to 6+ |
makes sense to me! 👍 happy to leave this or close it, up to you folks. i can pick it up again once we're ready if nobody else does |
@@ -33,6 +33,12 @@ const vite_css_query_regex = /(?:\?|&)(?:raw|url|inline)(?:&|$)/; | |||
export async function dev(vite, vite_config, svelte_config) { | |||
installPolyfills(); | |||
|
|||
const viteEnv = vite.environments.ssr; |
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.
should probably be named sth like vite_env_ssr
(internally we use snake_case)
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.
this is just the default environment vite sets up
nevermind i misread! yes you're right
Moves the vite dev server to use the new environments API.
This changes the following:
vite.moduleGraph
is replaced byvite.environments.ssr.moduleGraph
vite.ssrLoadModule
is replaced byvite.environments.ssr.runner.import(url)
Draft for now
These things are only deprecated with
future: true
, so we don't actually need to make the changes yet.Also i don't work with svelte often so this PR could be way off. Same for vite internals. I was doing this as a learning task.
If it turns out you want to do this another way, or i've done it completely wrong, let's close the PR 👍
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits