-
-
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: provide Vite hooks api #5694
Conversation
🦋 Changeset detectedLatest commit: 6300815 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I have also excluded IntelliJ/WebStorm stuff in |
Maybe we can reverse the control, just registering the plugin names in the kit config or kit vite plugin options, and find them in the call, and so kit will control it, vite plugins will not need to do anything: kit logic will just check for api.hook function in each configured plugin. |
chore: move some logic to utils module
I just added in prerendering test a log with a dummy plugin: https://imgur.com/AekOLxE |
chore: provide kit and vite config to the hooks
you should change the netlify adapter build script, it is failing in Windows (it is using |
Thank you but can you please open an issue before creating very large PRs like this? It adds a lot of code and complexity and it's completely unclear to me what it does or what problem it solves. |
I'll try to link a new issue later |
Created issue: since SvelteKit has removed the EDIT: the |
I think https://github.com/vitejs/vite/discussions/9442 is a better solution to this problem, so let's see what happens there first |
Came here to post the same thing as @benmccann. This is a problem that should be solved at the Vite level. Will close this PR, thanks |
This PR will expose some hooks to avoid race condition on Vite, since all plugins will run in parallel and some will need the prerender process to finish: pwa plugin and sitemap for example.
There is a thread in Vite Discord server: https://discord.com/channels/804011606160703521/1000700061094776832
The latest changes @benmccann is making to the alignment of Vite and SvelteKit will not work with some plugins, even though the
process.exit
in thecloseBundle
has been removed. The main problem is that the async and parallel types of the plugins involved cause a race condition to exist on eitherwriteBundle
orcloseBundle
.I also send a PR to include a new
preCloseBundle
hook: vitejs/vite#9326closes #5709
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. All changesets should bepatch
until SvelteKit 1.0