@nuxt/vite-builder-nightly 4.4.7-29652887.e4d5cc70 → 4.5.0-29657113.e77d3dbf

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.d.mts CHANGED
@@ -2,6 +2,11 @@ import { EnvironmentOptions } from "vite";
2
2
  import { ViteConfig } from "nuxt/schema";
3
3
  import { NuxtBuilder } from "@nuxt/schema";
4
4
  declare const bundle: NuxtBuilder["bundle"];
5
+ /**
6
+ * Reuse Vite's `server.watcher` (chokidar) to drive `builder:watch` instead of
7
+ * spinning up a second FS watcher in Nuxt core. Only active in `dev` mode.
8
+ */
9
+ declare const setupWatcher: NonNullable<NuxtBuilder["setupWatcher"]>;
5
10
  declare module "nuxt/schema" {
6
11
  interface ViteOptions extends ViteConfig {
7
12
  $client?: EnvironmentOptions;
@@ -14,4 +19,4 @@ declare module "nuxt/schema" {
14
19
  };
15
20
  }
16
21
  }
17
- export { bundle };
22
+ export { bundle, setupWatcher };
package/dist/index.mjs CHANGED
@@ -522,8 +522,8 @@ function sendError(socket, id, error) {
522
522
  if (err) {}
523
523
  });
524
524
  }
525
- const PREFIX = "virtual:public?";
526
- const PREFIX_RE = /^virtual:public\?/;
525
+ const PREFIX = "\0virtual:public?";
526
+ const PREFIX_RE = /^\0virtual:public\?/;
527
527
  const CSS_URL_RE = /url\((\/[^)]+)\)/g;
528
528
  const CSS_URL_SINGLE_RE = /url\(\/[^)]+\)/;
529
529
  const RENDER_CHUNK_RE = /(?<= = )['"`]/;
@@ -553,7 +553,7 @@ const PublicDirsPlugin = (options) => {
553
553
  order: "pre",
554
554
  filter: { id: PREFIX_RE },
555
555
  handler(id) {
556
- return `import { publicAssetsURL } from '#internal/nuxt/paths';export default publicAssetsURL(${JSON.stringify(decodeURIComponent(id.slice(15)))})`;
556
+ return `import { publicAssetsURL } from '#internal/nuxt/paths';export default publicAssetsURL(${JSON.stringify(decodeURIComponent(id.slice(16)))})`;
557
557
  }
558
558
  },
559
559
  resolveId: {
@@ -702,7 +702,7 @@ function createViteLogger(config, ctx = {}) {
702
702
  }
703
703
  function formatIncludeSnippet(deps, cjsDeps) {
704
704
  if (!deps.length) return "[]";
705
- return `[\n${[...deps].sort().map((d) => {
705
+ return `[\n${deps.toSorted().map((d) => {
706
706
  return ` '${d}',${cjsDeps?.has(d) ? " // CJS" : ""}`;
707
707
  }).join("\n")}\n ]`;
708
708
  }
@@ -1168,6 +1168,7 @@ const clientEnvironment = (nuxt, entry) => {
1168
1168
  "import.meta.server": false,
1169
1169
  "import.meta.client": true,
1170
1170
  "import.meta.browser": true,
1171
+ "import.meta.envName": JSON.stringify(nuxt.options.envName),
1171
1172
  "import.meta.nitro": false,
1172
1173
  "import.meta.prerender": false,
1173
1174
  "module.hot": false,
@@ -1401,6 +1402,7 @@ function ssrEnvironment(nuxt, serverEntry) {
1401
1402
  "import.meta.server": true,
1402
1403
  "import.meta.client": false,
1403
1404
  "import.meta.browser": false,
1405
+ "import.meta.envName": JSON.stringify(nuxt.options.envName),
1404
1406
  "window": "undefined",
1405
1407
  "document": "undefined",
1406
1408
  "navigator": "undefined",
@@ -1856,8 +1858,7 @@ function LayerDepOptimizePlugin(nuxt) {
1856
1858
  const delimitedRootDir = nuxt.options.rootDir + "/";
1857
1859
  for (const dirs of getLayerDirectories(nuxt)) if (dirs.app !== nuxt.options.srcDir && !dirs.app.startsWith(delimitedRootDir)) layerDirs.push(dirs.app);
1858
1860
  if (layerDirs.length > 0) {
1859
- layerDirs.sort().reverse();
1860
- const dirs = [...layerDirs];
1861
+ const dirs = layerDirs.toSorted().reverse();
1861
1862
  return {
1862
1863
  name: "nuxt:optimize-layer-deps",
1863
1864
  enforce: "pre",
@@ -2426,7 +2427,9 @@ async function handleEnvironments(nuxt, config) {
2426
2427
  }
2427
2428
  nuxt._perf?.startPhase("vite:dev-server");
2428
2429
  await withLogs(async () => {
2429
- await (await createServer(config)).environments.ssr.pluginContainer.buildStart({});
2430
+ const server = await createServer(config);
2431
+ nuxt.hook("close", () => server.close());
2432
+ await server.environments.ssr.pluginContainer.buildStart({});
2430
2433
  }, "Vite dev server built");
2431
2434
  nuxt._perf?.endPhase("vite:dev-server");
2432
2435
  }
@@ -2451,4 +2454,33 @@ async function withLogs(fn, message, enabled = true) {
2451
2454
  const duration = performance.now() - start;
2452
2455
  logger.success(`${message} in ${Math.round(duration)}ms`);
2453
2456
  }
2454
- export { bundle };
2457
+ const setupWatcher = (nuxt) => {
2458
+ if (!nuxt.options.dev) return;
2459
+ const isIgnored = createIsIgnored(nuxt);
2460
+ const extraPaths = /* @__PURE__ */ new Set();
2461
+ for (const layer of getLayerDirectories(nuxt)) {
2462
+ extraPaths.add(layer.app);
2463
+ if (!layer.server.startsWith(layer.app.replace(/\/?$/, "/"))) extraPaths.add(layer.server);
2464
+ }
2465
+ const srcDir = nuxt.options.srcDir.replace(/\/?$/, "/");
2466
+ for (const pattern of nuxt.options.watch) {
2467
+ if (typeof pattern !== "string") continue;
2468
+ const path = resolve(nuxt.options.srcDir, pattern);
2469
+ if (!path.startsWith(srcDir)) extraPaths.add(path);
2470
+ }
2471
+ nuxt.hook("vite:serverCreated", async (server, { isClient }) => {
2472
+ if (!isClient) return;
2473
+ const watcher = server.watcher;
2474
+ watcher.on("all", (event, path) => {
2475
+ const normalized = normalize(path);
2476
+ if (isIgnored(normalized)) return;
2477
+ nuxt.callHook("builder:watch", event, normalized);
2478
+ });
2479
+ if (extraPaths.size) {
2480
+ const ready = new Promise((resolve) => watcher.once("ready", resolve));
2481
+ watcher.add([...extraPaths]);
2482
+ await ready;
2483
+ }
2484
+ });
2485
+ };
2486
+ export { bundle, setupWatcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/vite-builder-nightly",
3
- "version": "4.4.7-29652887.e4d5cc70",
3
+ "version": "4.5.0-29657113.e77d3dbf",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.7-29652887.e4d5cc70",
26
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.5.0-29657113.e77d3dbf",
27
27
  "@rollup/plugin-replace": "^6.0.3",
28
28
  "@vitejs/plugin-vue": "^6.0.7",
29
29
  "@vitejs/plugin-vue-jsx": "^5.1.5",
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@babel/plugin-proposal-decorators": "7.29.0",
57
57
  "@babel/plugin-syntax-jsx": "7.28.6",
58
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.7-29652887.e4d5cc70",
58
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.5.0-29657113.e77d3dbf",
59
59
  "h3": "1.15.11",
60
60
  "h3-next": "npm:h3@2.0.1-rc.22",
61
61
  "nitropack": "2.13.4",
@@ -68,7 +68,7 @@
68
68
  "peerDependencies": {
69
69
  "@babel/plugin-proposal-decorators": "^7.25.0",
70
70
  "@babel/plugin-syntax-jsx": "^7.25.0",
71
- "nuxt": "npm:nuxt-nightly@4.4.7-29652887.e4d5cc70",
71
+ "nuxt": "npm:nuxt-nightly@4.5.0-29657113.e77d3dbf",
72
72
  "rolldown": "^1.0.0-beta.38",
73
73
  "rollup-plugin-visualizer": "^6.0.0 || ^7.0.1",
74
74
  "vue": "^3.3.4"