@sveltejs/vite-plugin-svelte 7.1.0 → 7.1.2

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.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "src",
@@ -39,7 +39,17 @@ export function loadCompiledCss(api) {
39
39
  if (!svelteRequest) {
40
40
  return;
41
41
  }
42
+
42
43
  let cachedCss = this.getModuleInfo(svelteRequest.filename)?.meta.svelte?.css;
44
+ if (!cachedCss) {
45
+ // some module IDs have a ?v=... query string suffix in addition to the
46
+ // filename. We can retrieve this by running resolve again
47
+ const resolvedId = await this.resolve(svelteRequest.filename);
48
+ if (resolvedId?.id) {
49
+ cachedCss = this.getModuleInfo(resolvedId.id)?.meta.svelte?.css;
50
+ }
51
+ }
52
+
43
53
  // in `build --watch` or dev ssr reloads getModuleInfo only returns changed module data.
44
54
  // To ensure virtual css is loaded unchanged, we cache it here separately
45
55
  if (useLocalCache) {
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);