@sveltejs/vite-plugin-svelte 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/vite-plugin-svelte",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "src",
@@ -39,14 +39,18 @@ export function loadCompiledCss(api) {
39
39
  if (!svelteRequest) {
40
40
  return;
41
41
  }
42
- let cachedCss = this.getModuleInfo(svelteRequest.filename)?.meta.svelte?.css;
42
+ // we need to re-resolve the ID in case the dep has been optimised by Vite
43
+ // since it would now have a ?v=... query string suffix
44
+ const resolvedId = await this.resolve(svelteRequest.filename);
45
+ const moduleId = resolvedId?.id ?? svelteRequest.filename;
46
+ let cachedCss = this.getModuleInfo(moduleId)?.meta.svelte?.css;
43
47
  // in `build --watch` or dev ssr reloads getModuleInfo only returns changed module data.
44
48
  // To ensure virtual css is loaded unchanged, we cache it here separately
45
49
  if (useLocalCache) {
46
50
  if (cachedCss) {
47
- buildWatchCssCache.set(svelteRequest.filename, cachedCss);
51
+ buildWatchCssCache.set(moduleId, cachedCss);
48
52
  } else {
49
- cachedCss = buildWatchCssCache.get(svelteRequest.filename);
53
+ cachedCss = buildWatchCssCache.get(moduleId);
50
54
  }
51
55
  }
52
56
 
package/src/preprocess.js CHANGED
@@ -49,15 +49,12 @@ function viteScript() {
49
49
  const lang = /** @type {'ts'} */ (attributes.lang);
50
50
  const { code, map } = await transformWithOxc(content, filename, {
51
51
  lang,
52
- target: 'esnext'
53
- // TODO, how to pass tsconfig compilerOptions (or not needed as config is loaded for file
54
- /*tsconfigRaw: {
55
- compilerOptions: {
56
- // svelte typescript needs this flag to work with type imports
57
- importsNotUsedAsValues: 'preserve',
58
- preserveValueImports: true
59
- }
60
- }*/
52
+ target: 'esnext',
53
+ // oxc strips value imports it considers unused, but in Svelte files
54
+ // these imports may be referenced in the template which oxc cannot see.
55
+ // onlyRemoveTypeImports tells oxc to only strip type-only imports
56
+ // (import type {...}, import { type X }) and preserve all value imports.
57
+ typescript: { onlyRemoveTypeImports: true }
61
58
  });
62
59
 
63
60
  mapToRelative(map, filename);