Problem
Sveltekit doesn't support the transformIndexHtml Vite hook. This is where @collagejs/vite-im collects import map information and injects it into the page. Since Sveltekit projects don't run this hook, the plug-in doesn't work with it.
Proposed Solution
Until the day the Vite hook is supported, I see no other way than creating a new plug-in, @collagejs/vite-kit, that:
- During development (
npm run dev), uses a brute-force method to intercept all generated HTML responses to inject the import map
- During build, provides the transformPageChunk server hook to perform the same injection
This is the only way I see ATM to beat Vite's HMR client script injection (that renders import maps useless).
Problem
Sveltekit doesn't support the
transformIndexHtmlVite hook. This is where@collagejs/vite-imcollects import map information and injects it into the page. Since Sveltekit projects don't run this hook, the plug-in doesn't work with it.Proposed Solution
Until the day the Vite hook is supported, I see no other way than creating a new plug-in,
@collagejs/vite-kit, that:npm run dev), uses a brute-force method to intercept all generated HTML responses to inject the import mapThis is the only way I see ATM to beat Vite's HMR client script injection (that renders import maps useless).