@vizejs/vite-plugin 0.714.0 → 0.716.0

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as vize } from "./plugin-3vU6ECAI.mjs";
1
+ import { t as vize } from "./plugin-B9Ur73M0.mjs";
2
2
  import { u as rewriteStaticAssetUrls } from "./vue-version-B0qUneRk.mjs";
3
3
  import { a as resolveViteConfigExport, i as resolveConfigExport, n as defineConfig, o as vizeConfigStore, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-CnsxzXW5.mjs";
4
4
  //#region src/index.ts
@@ -1133,10 +1133,23 @@ function clearBuildCaches(state) {
1133
1133
  state.ssrCache.clear();
1134
1134
  state.collectedCss.clear();
1135
1135
  state.precompileMetadata.clear();
1136
+ state.ssrPrecompileMetadata?.clear();
1136
1137
  state.pendingHmrUpdateTypes.clear();
1137
1138
  state.viteResolveCache?.clear();
1138
1139
  }
1139
1140
  //#endregion
1141
+ //#region src/plugin/cache-path.ts
1142
+ /**
1143
+ * Stable cache identity for an SFC path.
1144
+ *
1145
+ * tinyglobby reports absolute paths with forward slashes on Windows while
1146
+ * Vite and node:path may report the same file with backslashes. Cache keys
1147
+ * must not depend on which producer supplied the path.
1148
+ */
1149
+ function normalizeCachePath(file) {
1150
+ return file.replaceAll("\\", "/");
1151
+ }
1152
+ //#endregion
1140
1153
  //#region src/plugin/path-identity.ts
1141
1154
  /**
1142
1155
  * Every stable filesystem identity Vite may use for one authored path.
@@ -1179,7 +1192,14 @@ var CompiledModuleCache = class extends Map {
1179
1192
  constructor() {
1180
1193
  super();
1181
1194
  }
1195
+ get(file) {
1196
+ return super.get(normalizeCachePath(file));
1197
+ }
1198
+ has(file) {
1199
+ return super.has(normalizeCachePath(file));
1200
+ }
1182
1201
  set(file, compiled) {
1202
+ file = normalizeCachePath(file);
1183
1203
  this.#unindex(file);
1184
1204
  super.set(file, compiled);
1185
1205
  const dependencies = /* @__PURE__ */ new Set();
@@ -1200,6 +1220,7 @@ var CompiledModuleCache = class extends Map {
1200
1220
  return this;
1201
1221
  }
1202
1222
  delete(file) {
1223
+ file = normalizeCachePath(file);
1203
1224
  this.#unindex(file);
1204
1225
  return super.delete(file);
1205
1226
  }
@@ -1216,7 +1237,7 @@ var CompiledModuleCache = class extends Map {
1216
1237
  * The next `set` reconciles that retained snapshot with the new compilation.
1217
1238
  */
1218
1239
  evict(file) {
1219
- return super.delete(file);
1240
+ return super.delete(normalizeCachePath(file));
1220
1241
  }
1221
1242
  /** The cached SFCs that `src`-import `resolvedDependency`. */
1222
1243
  ownersOf(resolvedDependency) {
@@ -1231,6 +1252,7 @@ var CompiledModuleCache = class extends Map {
1231
1252
  return [...owners];
1232
1253
  }
1233
1254
  #unindex(file) {
1255
+ file = normalizeCachePath(file);
1234
1256
  for (const dependency of this.#dependenciesByOwner.get(file) ?? []) {
1235
1257
  const owners = this.#ownersByDependency.get(dependency);
1236
1258
  if (!owners) continue;
@@ -1976,7 +1998,7 @@ function decodePrecompileManifest(bytes, options) {
1976
1998
  if (end > payload.length) return reject("index overruns payload");
1977
1999
  const module = decodeRecord(payload.subarray(offset, end));
1978
2000
  offset = end;
1979
- if (module !== null) entries.set(path.resolve(root, relative), {
2001
+ if (module !== null) entries.set(normalizeCachePath(path.resolve(root, relative)), {
1980
2002
  hash,
1981
2003
  module
1982
2004
  });
@@ -2047,10 +2069,12 @@ function openPrecompileCache(options) {
2047
2069
  return {
2048
2070
  file,
2049
2071
  get(filePath, sourceHash) {
2072
+ filePath = normalizeCachePath(filePath);
2050
2073
  const entry = entries.get(filePath);
2051
2074
  return entry && entry.hash === sourceHash ? entry.module : void 0;
2052
2075
  },
2053
2076
  set(filePath, sourceHash, module) {
2077
+ filePath = normalizeCachePath(filePath);
2054
2078
  if (!isPersistablePrecompileModule(module)) {
2055
2079
  if (entries.delete(filePath)) dirty = true;
2056
2080
  return;
@@ -2064,10 +2088,11 @@ function openPrecompileCache(options) {
2064
2088
  dirty = true;
2065
2089
  },
2066
2090
  delete(filePath) {
2091
+ filePath = normalizeCachePath(filePath);
2067
2092
  if (entries.delete(filePath)) dirty = true;
2068
2093
  },
2069
2094
  retain(files) {
2070
- const keep = files instanceof Set ? files : new Set(files);
2095
+ const keep = new Set(Array.from(files, normalizeCachePath));
2071
2096
  for (const filePath of entries.keys()) if (!keep.has(filePath)) {
2072
2097
  entries.delete(filePath);
2073
2098
  dirty = true;
@@ -2145,10 +2170,10 @@ function writeManifest(file, container, onDiagnostic) {
2145
2170
  }
2146
2171
  //#endregion
2147
2172
  //#region src/plugin/precompile-scopes.ts
2148
- function compileScopedBatch(files, state) {
2173
+ function compileScopedBatch(files, state, ssr = false) {
2149
2174
  const groups = /* @__PURE__ */ new Map();
2150
2175
  for (const file of files) {
2151
- const options = getCompileOptionsForRequest(state, false, file.path);
2176
+ const options = getCompileOptionsForRequest(state, ssr, file.path);
2152
2177
  const key = JSON.stringify(buildCompileBatchOptions(options));
2153
2178
  const group = groups.get(key);
2154
2179
  if (group) group.files.push(file);
@@ -2160,7 +2185,7 @@ function compileScopedBatch(files, state) {
2160
2185
  const results = [];
2161
2186
  let timeMs = 0;
2162
2187
  for (const group of groups.values()) {
2163
- const result = compileBatch(group.files, state.cache, group.options);
2188
+ const result = compileBatch(group.files, getEnvironmentCache(state, ssr), group.options);
2164
2189
  results.push(...result.results);
2165
2190
  timeMs += result.timeMs;
2166
2191
  }
@@ -2229,8 +2254,8 @@ var PrecompileDiagnosticsError = class extends Error {
2229
2254
  * Also the input to the cache key, so the two can never drift: a new option
2230
2255
  * that reaches the native compiler reaches the key with it.
2231
2256
  */
2232
- function resolvePrecompileBatchOptions(state) {
2233
- return getCompileOptionsForRequest(state, false);
2257
+ function resolvePrecompileBatchOptions(state, ssr) {
2258
+ return getCompileOptionsForRequest(state, ssr);
2234
2259
  }
2235
2260
  function openCacheForRun(state, batchOptions) {
2236
2261
  if (!state.root) return createDisabledPrecompileCache();
@@ -2247,7 +2272,7 @@ function openCacheForRun(state, batchOptions) {
2247
2272
  /**
2248
2273
  * Pre-compile all Vue files matching scan patterns.
2249
2274
  */
2250
- async function compileAll(state, owners = [], resolve, addWatchFile) {
2275
+ async function compileAll(state, owners = [], resolve, addWatchFile, ssr = false) {
2251
2276
  const startTime = performance.now();
2252
2277
  const sfcFiles = (await glob(state.scanPatterns, {
2253
2278
  cwd: state.root,
@@ -2265,7 +2290,9 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2265
2290
  } catch (e) {
2266
2291
  state.logger.error(`Failed to stat ${file}:`, e);
2267
2292
  }
2268
- const { changedFiles: changed, deletedFiles } = diffPrecompileFiles(sfcFiles, currentMetadata, state.precompileMetadata);
2293
+ const targetCache = getEnvironmentCache(state, ssr);
2294
+ const targetMetadata = ssr ? state.ssrPrecompileMetadata ??= /* @__PURE__ */ new Map() : state.precompileMetadata;
2295
+ const { changedFiles: changed, deletedFiles } = diffPrecompileFiles(sfcFiles, currentMetadata, targetMetadata);
2269
2296
  const changedFiles = owners.length > 0 ? sfcFiles : changed;
2270
2297
  const cachedFileCount = sfcFiles.length - changedFiles.length;
2271
2298
  for (const file of deletedFiles) {
@@ -2273,6 +2300,7 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2273
2300
  state.ssrCache.delete(file);
2274
2301
  if (state.extractCss) state.collectedCss.delete(file);
2275
2302
  state.precompileMetadata.delete(file);
2303
+ state.ssrPrecompileMetadata?.delete(file);
2276
2304
  state.pendingHmrUpdateTypes.delete(file);
2277
2305
  }
2278
2306
  state.logger.info(`Pre-compiling ${sfcFiles.length} Vue files... (${changedFiles.length} changed, ${cachedFileCount} cached, ${deletedFiles.length} removed)`);
@@ -2285,7 +2313,7 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2285
2313
  if (state.extractCss) state.collectedCss.delete(file);
2286
2314
  state.pendingHmrUpdateTypes.delete(file);
2287
2315
  }
2288
- const cache = openCacheForRun(state, resolvePrecompileBatchOptions(state));
2316
+ const cache = openCacheForRun(state, resolvePrecompileBatchOptions(state, ssr));
2289
2317
  const cacheEnabled = cache.file !== null;
2290
2318
  let successCount = 0;
2291
2319
  let restoredCount = 0;
@@ -2308,6 +2336,7 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2308
2336
  state.ssrCache.delete(file);
2309
2337
  state.collectedCss.delete(file);
2310
2338
  state.precompileMetadata.delete(file);
2339
+ state.ssrPrecompileMetadata?.delete(file);
2311
2340
  cache.delete(file);
2312
2341
  precompileFailures.push(`[vize] Failed to read ${file}: ${formatUnknownError$2(e)}`);
2313
2342
  state.logger.error(`Failed to read ${file}:`, e);
@@ -2318,6 +2347,7 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2318
2347
  state.ssrCache.delete(file);
2319
2348
  state.collectedCss.delete(file);
2320
2349
  state.precompileMetadata.delete(file);
2350
+ state.ssrPrecompileMetadata?.delete(file);
2321
2351
  cache.delete(file);
2322
2352
  continue;
2323
2353
  }
@@ -2328,9 +2358,9 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2328
2358
  ...stored,
2329
2359
  source
2330
2360
  };
2331
- state.cache.set(file, restored);
2361
+ targetCache.set(file, restored);
2332
2362
  const metadata = currentMetadata.get(file);
2333
- if (metadata) state.precompileMetadata.set(file, metadata);
2363
+ if (metadata) targetMetadata.set(file, metadata);
2334
2364
  syncCollectedCssForFile({
2335
2365
  ...state,
2336
2366
  extractCss: state.extractCss && !isPluginVueCustomElement(state.mergedOptions, file)
@@ -2346,7 +2376,7 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2346
2376
  }
2347
2377
  if (fileContents.length === 0) continue;
2348
2378
  if (resolve) for (const file of fileContents) await prepareSfcSrcRequests(state, resolve, file.path, file.source);
2349
- const result = compileScopedBatch(fileContents, state);
2379
+ const result = compileScopedBatch(fileContents, state, ssr);
2350
2380
  const chunkFailedCount = result.results.filter((fileResult) => fileResult.errors.length > 0).length;
2351
2381
  failedCount += chunkFailedCount;
2352
2382
  successCount += result.results.length - chunkFailedCount;
@@ -2358,13 +2388,14 @@ async function compileAll(state, owners = [], resolve, addWatchFile) {
2358
2388
  state.ssrCache.delete(fileResult.path);
2359
2389
  state.collectedCss.delete(fileResult.path);
2360
2390
  state.precompileMetadata.delete(fileResult.path);
2391
+ state.ssrPrecompileMetadata?.delete(fileResult.path);
2361
2392
  cache.delete(fileResult.path);
2362
2393
  precompileFailures.push(formatCompileErrorMessage(fileResult.path, fileResult.errors));
2363
2394
  continue;
2364
2395
  }
2365
- if (metadata) state.precompileMetadata.set(fileResult.path, metadata);
2366
- const compiled = state.cache.get(fileResult.path);
2367
- watchTypeProject(state.cache, fileResult.typeProject, addWatchFile);
2396
+ if (metadata) targetMetadata.set(fileResult.path, metadata);
2397
+ const compiled = targetCache.get(fileResult.path);
2398
+ watchTypeProject(targetCache, fileResult.typeProject, addWatchFile);
2368
2399
  const sourceHash = sourceHashes.get(fileResult.path);
2369
2400
  if (fileResult.warnings.length > 0) cache.delete(fileResult.path);
2370
2401
  else if (compiled && sourceHash !== void 0) cache.set(fileResult.path, sourceHash, compiled);
@@ -4812,6 +4843,13 @@ function aliasSortKey(find) {
4812
4843
  function resolveHookSsr(context, options) {
4813
4844
  return options?.ssr ?? (context.environment?.name === "ssr" || context.environment?.name === "server");
4814
4845
  }
4846
+ /** Build hooks lack an SSR argument in Vite 7; Vite 8 names the environment. */
4847
+ function resolveBuildStartSsr(context, fallback) {
4848
+ const name = context.environment?.name;
4849
+ if (name === "ssr" || name === "server") return true;
4850
+ if (name === "client" || name === "browser") return false;
4851
+ return !!fallback?.build?.ssr;
4852
+ }
4815
4853
  //#endregion
4816
4854
  //#region src/plugin/compiler-config.ts
4817
4855
  function mergeCompilerOptions(options, sharedConfig, defaults = {}) {
@@ -5125,6 +5163,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
5125
5163
  ssrCache: new CompiledModuleCache(),
5126
5164
  collectedCss: /* @__PURE__ */ new Map(),
5127
5165
  precompileMetadata: /* @__PURE__ */ new Map(),
5166
+ ssrPrecompileMetadata: /* @__PURE__ */ new Map(),
5128
5167
  pendingHmrUpdateTypes: /* @__PURE__ */ new Map(),
5129
5168
  viteResolveCache: /* @__PURE__ */ new Map(),
5130
5169
  isProduction: false,
@@ -5257,7 +5296,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
5257
5296
  await compileAll({
5258
5297
  ...state,
5259
5298
  extractCss: shouldExtractCssForBuild(state, this)
5260
- }, precompileInputOwners(this, precompileConfig), (request, importer) => this.resolve(request, importer, { skipSelf: true }), this.addWatchFile.bind(this));
5299
+ }, precompileInputOwners(this, precompileConfig), (request, importer) => this.resolve(request, importer, { skipSelf: true }), this.addWatchFile.bind(this), resolveBuildStartSsr(this, precompileConfig));
5261
5300
  } catch (error) {
5262
5301
  if (!(error instanceof PrecompileDiagnosticsError)) throw error;
5263
5302
  state.logger.warn(`${error.message}\nStartup scan diagnostics are deferred until import.`);
@@ -0,0 +1,2 @@
1
+ import { t as vize } from "./plugin-B9Ur73M0.mjs";
2
+ export { vize };
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
400
400
  const legacy = compiler !== false && (await import("./vue-version-DL5NF2G-.mjs")).isLegacyVueCompatibilityMode(compiler);
401
401
  const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
402
402
  if (compiler !== false) {
403
- const { vize } = await import("./plugin-CaOyzUlE.mjs");
403
+ const { vize } = await import("./plugin-D7LXn_Ld.mjs");
404
404
  plugins.push(vize({
405
405
  ...plugin,
406
406
  configMode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.714.0",
3
+ "version": "0.716.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -51,13 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@vizejs/native": "0.714.0",
55
- "@vizejs/unplugin": "0.714.0",
54
+ "@vizejs/native": "0.716.0",
55
+ "@vizejs/unplugin": "0.716.0",
56
56
  "jsonc-parser": "^3.3.1",
57
57
  "oxc-parser": "0.144.0",
58
58
  "picomatch": "4.0.5",
59
59
  "tinyglobby": "0.2.17",
60
- "vize": "0.714.0"
60
+ "vize": "0.716.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "25.9.2",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-3vU6ECAI.mjs";
2
- export { vize };