nitro-nightly 3.0.1-20251127-112821-2989d6be → 3.0.1-20251201-105914-0f08396c

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.
@@ -23,7 +23,7 @@ import { n as writeBuildInfo } from "./common.mjs";
23
23
  import { a as watch$1 } from "../_libs/chokidar.mjs";
24
24
  import "../_libs/estree-walker.mjs";
25
25
  import "../_libs/plugin-commonjs.mjs";
26
- import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/CGEOOxsU.mjs";
26
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/Qe19FNKf.mjs";
27
27
  import "../_libs/remapping.mjs";
28
28
  import "../_libs/unwasm.mjs";
29
29
  import "../_libs/plugin-replace.mjs";
@@ -25,7 +25,7 @@ import { t as alias } from "../_libs/plugin-alias.mjs";
25
25
  import "../_libs/estree-walker.mjs";
26
26
  import { t as commonjs } from "../_libs/plugin-commonjs.mjs";
27
27
  import { t as inject } from "../_libs/plugin-inject.mjs";
28
- import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/CGEOOxsU.mjs";
28
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/Qe19FNKf.mjs";
29
29
  import "../_libs/remapping.mjs";
30
30
  import "../_libs/unwasm.mjs";
31
31
  import "../_libs/plugin-replace.mjs";
@@ -47,26 +47,26 @@ import "../_libs/is-core-module.mjs";
47
47
  import { watch } from "node:fs";
48
48
  import { defu } from "defu";
49
49
  import { transform } from "oxc-transform";
50
- import { minify } from "oxc-minify";
50
+ import { minifySync } from "oxc-minify";
51
51
 
52
52
  //#region src/build/plugins/oxc.ts
53
53
  function oxc(options) {
54
- const filter = (id) => !/node_modules/.test(id) && /\.[mj]?[jt]sx?$/.test(id);
55
54
  return {
56
55
  name: "nitro:oxc",
57
- async transform(code, id) {
58
- if (!filter(id)) return null;
59
- return transform(id, code, {
60
- sourcemap: options.sourcemap,
61
- ...options.transform
62
- });
56
+ transform: {
57
+ filter: { id: /^(?!.*\/node_modules\/).*\.m?[jt]sx?$/ },
58
+ handler(code, id) {
59
+ return transform(id, code, {
60
+ sourcemap: options.sourcemap,
61
+ ...options.transform
62
+ });
63
+ }
63
64
  },
64
- async renderChunk(code, chunk) {
65
- if (options.minify) return minify(chunk.fileName, code, {
65
+ renderChunk(code, chunk) {
66
+ if (options.minify) return minifySync(chunk.fileName, code, {
66
67
  sourcemap: options.sourcemap,
67
68
  ...typeof options.minify === "object" ? options.minify : {}
68
69
  });
69
- return null;
70
70
  }
71
71
  };
72
72
  }
@@ -33,7 +33,7 @@ import "../_libs/plugin-alias.mjs";
33
33
  import "../_libs/estree-walker.mjs";
34
34
  import "../_libs/plugin-commonjs.mjs";
35
35
  import "../_libs/plugin-inject.mjs";
36
- import "../_chunks/CGEOOxsU.mjs";
36
+ import "../_chunks/Qe19FNKf.mjs";
37
37
  import "../_libs/remapping.mjs";
38
38
  import "../_libs/unwasm.mjs";
39
39
  import "../_libs/plugin-replace.mjs";
@@ -10,7 +10,7 @@ import { i as NodeDevWorker, r as NitroDevApp } from "../_dev.mjs";
10
10
  import { a as watch$1 } from "../_libs/chokidar.mjs";
11
11
  import { t as alias } from "../_libs/plugin-alias.mjs";
12
12
  import { t as inject } from "../_libs/plugin-inject.mjs";
13
- import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/CGEOOxsU.mjs";
13
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/Qe19FNKf.mjs";
14
14
  import { t as assetsPlugin } from "../_libs/vite-plugin-fullstack.mjs";
15
15
  import consola$1 from "consola";
16
16
  import { join, resolve } from "node:path";
@@ -137,40 +137,53 @@ function routeToFsPath(route) {
137
137
  return route.split("/").slice(1).map((s) => `${s.replace(/[:*]+/g, "$").replace(/[^$a-zA-Z0-9_.[\]/]/g, "_")}`).join("/") || "index";
138
138
  }
139
139
 
140
+ //#endregion
141
+ //#region src/utils/regex.ts
142
+ function escapeRegExp(string) {
143
+ return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
144
+ }
145
+
140
146
  //#endregion
141
147
  //#region src/build/plugins/route-meta.ts
142
- const virtualPrefix = "\0nitro-handler-meta:";
148
+ const PREFIX$2 = "\0nitro:route-meta:";
143
149
  function routeMeta(nitro) {
144
150
  return {
145
151
  name: "nitro:route-meta",
146
- async resolveId(id, importer, resolveOpts) {
147
- if (id.startsWith("\0")) return;
148
- if (id.endsWith(`?meta`)) {
149
- const resolved = await this.resolve(id.replace(`?meta`, ``), importer, resolveOpts);
150
- if (!resolved) return;
151
- return virtualPrefix + resolved.id;
152
+ resolveId: {
153
+ filter: { id: /^(?!\u0000)(.+)\?meta$/ },
154
+ async handler(id, importer, resolveOpts) {
155
+ if (id.endsWith("?meta")) {
156
+ const resolved = await this.resolve(id.replace("?meta", ""), importer, resolveOpts);
157
+ if (!resolved) return;
158
+ return PREFIX$2 + resolved.id;
159
+ }
152
160
  }
153
161
  },
154
- load(id) {
155
- if (id.startsWith(virtualPrefix)) return readFile(id.slice(20), { encoding: "utf8" });
162
+ load: {
163
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
164
+ handler(id) {
165
+ if (id.startsWith(PREFIX$2)) return readFile(id.slice(18), { encoding: "utf8" });
166
+ }
156
167
  },
157
- async transform(code, id) {
158
- if (!id.startsWith(virtualPrefix)) return;
159
- let meta = null;
160
- try {
161
- const jsCode = transformSync(id, code).code;
162
- const ast = this.parse(jsCode);
163
- for (const node of ast.body) if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "defineRouteMeta" && node.expression.arguments.length === 1) {
164
- meta = astToObject(node.expression.arguments[0]);
165
- break;
168
+ transform: {
169
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
170
+ async handler(code, id) {
171
+ let meta = null;
172
+ try {
173
+ const jsCode = transformSync(id, code).code;
174
+ const ast = this.parse(jsCode);
175
+ for (const node of ast.body) if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "defineRouteMeta" && node.expression.arguments.length === 1) {
176
+ meta = astToObject(node.expression.arguments[0]);
177
+ break;
178
+ }
179
+ } catch (error) {
180
+ nitro.logger.warn(`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`);
166
181
  }
167
- } catch (error) {
168
- nitro.logger.warn(`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`);
182
+ return {
183
+ code: `export default ${JSON.stringify(meta)};`,
184
+ map: null
185
+ };
169
186
  }
170
- return {
171
- code: `export default ${JSON.stringify(meta)};`,
172
- map: null
173
- };
174
187
  }
175
188
  };
176
189
  }
@@ -203,15 +216,9 @@ function serverMain(nitro) {
203
216
  };
204
217
  }
205
218
 
206
- //#endregion
207
- //#region src/utils/regex.ts
208
- function escapeRegExp(string) {
209
- return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
210
- }
211
-
212
219
  //#endregion
213
220
  //#region src/build/plugins/virtual.ts
214
- const PREFIX = "\0virtual:";
221
+ const PREFIX$1 = "\0nitro:virtual:";
215
222
  function virtual(input) {
216
223
  const modules = /* @__PURE__ */ new Map();
217
224
  for (const mod of input) {
@@ -226,21 +233,21 @@ function virtual(input) {
226
233
  api: { modules },
227
234
  resolveId: {
228
235
  order: "pre",
229
- filter: { id: { include: /* @__PURE__ */ new RegExp(`^(${[...modules.keys()].map((id) => escapeRegExp(id)).join("|")})$`) } },
236
+ filter: { id: /* @__PURE__ */ new RegExp(`^(${[...modules.keys()].map((id) => escapeRegExp(id)).join("|")})$`) },
230
237
  handler: (id) => {
231
238
  const mod = modules.get(id);
232
239
  if (!mod) return null;
233
240
  return {
234
- id: PREFIX + id,
241
+ id: PREFIX$1 + id,
235
242
  moduleSideEffects: mod.module.moduleSideEffects ?? false
236
243
  };
237
244
  }
238
245
  },
239
246
  load: {
240
247
  order: "pre",
241
- filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX)}`) },
248
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$1)}`) },
242
249
  handler: async (id) => {
243
- const idNoPrefix = id.slice(9);
250
+ const idNoPrefix = id.slice(15);
244
251
  const mod = modules.get(idNoPrefix);
245
252
  if (!mod) throw new Error(`Virtual module ${idNoPrefix} not found.`);
246
253
  return {
@@ -265,7 +272,7 @@ function nitroResolveIds() {
265
272
  resolveId: {
266
273
  order: "pre",
267
274
  handler(id, importer, rOpts) {
268
- if (importer && importer.startsWith("\0virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
275
+ if (importer && importer.startsWith("\0nitro:virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
269
276
  const mappedId = subpathMap[id];
270
277
  if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
271
278
  }
@@ -293,30 +300,37 @@ function sourcemapMinify() {
293
300
 
294
301
  //#endregion
295
302
  //#region src/build/plugins/raw.ts
296
- const HELPER_ID = "virtual:raw-helpers";
297
- const RESOLVED_RAW_PREFIX = "virtual:raw:";
303
+ const HELPER_ID = "\0nitro-raw-helpers";
304
+ const RESOLVED_PREFIX = "\0nitro:raw:";
305
+ const PREFIX = "raw:";
298
306
  function raw() {
299
307
  return {
300
- name: "raw",
308
+ name: "nitro:raw",
301
309
  resolveId: {
302
310
  order: "pre",
311
+ filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${PREFIX}`)] },
303
312
  async handler(id, importer, resolveOpts) {
304
313
  if (id === HELPER_ID) return id;
305
- if (id.startsWith("raw:")) return { id: RESOLVED_RAW_PREFIX + (await this.resolve(id.slice(4), importer, resolveOpts))?.id };
314
+ if (id.startsWith(PREFIX)) {
315
+ const resolvedId = (await this.resolve(id.slice(4), importer, resolveOpts))?.id;
316
+ if (!resolvedId) return null;
317
+ return { id: RESOLVED_PREFIX + resolvedId };
318
+ }
306
319
  }
307
320
  },
308
321
  load: {
309
322
  order: "pre",
323
+ filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`)] },
310
324
  handler(id) {
311
325
  if (id === HELPER_ID) return getHelpers();
312
- if (id.startsWith(RESOLVED_RAW_PREFIX)) return promises.readFile(id.slice(12), isBinary(id) ? "binary" : "utf8");
326
+ if (id.startsWith(RESOLVED_PREFIX)) return promises.readFile(id.slice(11), isBinary(id) ? "binary" : "utf8");
313
327
  }
314
328
  },
315
329
  transform: {
316
330
  order: "pre",
331
+ filter: { id: /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`) },
317
332
  handler(code, id) {
318
- if (!id.startsWith(RESOLVED_RAW_PREFIX)) return;
319
- const path = id.slice(12);
333
+ const path = id.slice(11);
320
334
  if (isBinary(id)) return {
321
335
  code: `import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
322
336
  map: rawAssetMap(path)
@@ -337,7 +351,7 @@ function isBinary(id) {
337
351
  return true;
338
352
  }
339
353
  function getHelpers() {
340
- return String.raw`
354
+ return `
341
355
  export function base64ToUint8Array(str) {
342
356
  const data = atob(str);
343
357
  const size = data.length;
package/dist/vite.mjs CHANGED
@@ -33,7 +33,7 @@ import "./_libs/plugin-alias.mjs";
33
33
  import "./_libs/estree-walker.mjs";
34
34
  import "./_libs/plugin-commonjs.mjs";
35
35
  import "./_libs/plugin-inject.mjs";
36
- import "./_chunks/CGEOOxsU.mjs";
36
+ import "./_chunks/Qe19FNKf.mjs";
37
37
  import "./_libs/remapping.mjs";
38
38
  import "./_libs/unwasm.mjs";
39
39
  import "./_libs/plugin-replace.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251127-112821-2989d6be",
3
+ "version": "3.0.1-20251201-105914-0f08396c",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",