nitro-nightly 3.0.1-20251203-124621-d38ffe1f → 3.0.1-20251203-231615-3a2d2662

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.
@@ -2,24 +2,24 @@ import "../_chunks/QkUO_zA6.mjs";
2
2
  import { O as relative, o as debounce, w as join } from "../_libs/c12.mjs";
3
3
  import "../_libs/gen-mapping.mjs";
4
4
  import "../_libs/acorn.mjs";
5
- import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
5
+ import { d as sanitizeFilePath } from "../_libs/local-pkg.mjs";
6
6
  import "../_libs/js-tokens.mjs";
7
7
  import "../_libs/unimport.mjs";
8
8
  import "../_libs/fdir.mjs";
9
9
  import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
10
10
  import "../_chunks/DJvLZH4H.mjs";
11
- import { i as scanHandlers, n as writeTypes } from "../_chunks/XHOrB-Xs.mjs";
11
+ import { i as scanHandlers, n as writeTypes } from "../_chunks/Ddt06bL8.mjs";
12
12
  import "../_libs/mime.mjs";
13
13
  import { n as writeBuildInfo } from "./common.mjs";
14
14
  import { a as watch$1 } from "../_libs/chokidar.mjs";
15
15
  import "../_libs/plugin-commonjs.mjs";
16
- import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/rU_kdJ2P.mjs";
16
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/BY3yPF44.mjs";
17
+ import "../_libs/etag.mjs";
17
18
  import "../_libs/remapping.mjs";
18
19
  import "../_libs/plugin-replace.mjs";
19
- import "../_libs/etag.mjs";
20
20
  import "../_libs/duplexer.mjs";
21
21
  import "../_libs/gzip-size.mjs";
22
- import { t as generateFSTree } from "../_chunks/C3_uRBf2.mjs";
22
+ import { t as generateFSTree } from "../_chunks/CytQIojr.mjs";
23
23
  import { builtinModules } from "node:module";
24
24
  import { watch } from "node:fs";
25
25
  import { defu } from "defu";
@@ -2,26 +2,26 @@ import "../_chunks/QkUO_zA6.mjs";
2
2
  import { C as isAbsolute, O as relative, o as debounce, w as join } from "../_libs/c12.mjs";
3
3
  import "../_libs/gen-mapping.mjs";
4
4
  import "../_libs/acorn.mjs";
5
- import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
5
+ import { d as sanitizeFilePath } from "../_libs/local-pkg.mjs";
6
6
  import "../_libs/js-tokens.mjs";
7
7
  import "../_libs/unimport.mjs";
8
8
  import "../_libs/fdir.mjs";
9
9
  import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
10
10
  import "../_chunks/DJvLZH4H.mjs";
11
- import { i as scanHandlers, n as writeTypes } from "../_chunks/XHOrB-Xs.mjs";
11
+ import { i as scanHandlers, n as writeTypes } from "../_chunks/Ddt06bL8.mjs";
12
12
  import "../_libs/mime.mjs";
13
13
  import { n as writeBuildInfo } from "./common.mjs";
14
14
  import { a as watch$1 } from "../_libs/chokidar.mjs";
15
15
  import { t as alias } from "../_libs/plugin-alias.mjs";
16
16
  import { t as commonjs } from "../_libs/plugin-commonjs.mjs";
17
17
  import { t as inject } from "../_libs/plugin-inject.mjs";
18
- import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/rU_kdJ2P.mjs";
18
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/BY3yPF44.mjs";
19
+ import "../_libs/etag.mjs";
19
20
  import "../_libs/remapping.mjs";
20
21
  import "../_libs/plugin-replace.mjs";
21
- import "../_libs/etag.mjs";
22
22
  import "../_libs/duplexer.mjs";
23
23
  import "../_libs/gzip-size.mjs";
24
- import { t as generateFSTree } from "../_chunks/C3_uRBf2.mjs";
24
+ import { t as generateFSTree } from "../_chunks/CytQIojr.mjs";
25
25
  import "../_libs/commondir.mjs";
26
26
  import "../_libs/is-reference.mjs";
27
27
  import { t as json } from "../_libs/plugin-json.mjs";
@@ -5,21 +5,21 @@ import "../_libs/acorn.mjs";
5
5
  import "../_libs/js-tokens.mjs";
6
6
  import "../_libs/unimport.mjs";
7
7
  import "../_libs/fdir.mjs";
8
- import { r as a } from "../_libs/std-env.mjs";
9
- import "../_chunks/_yl3G_3Y.mjs";
8
+ import { i as a } from "../_libs/std-env.mjs";
9
+ import "../_chunks/CvxEFBdh.mjs";
10
10
  import "../_libs/tsconfck.mjs";
11
11
  import "../_chunks/DJvLZH4H.mjs";
12
- import "../_chunks/XHOrB-Xs.mjs";
12
+ import "../_chunks/Ddt06bL8.mjs";
13
13
  import "../_libs/mime.mjs";
14
14
  import "./common.mjs";
15
15
  import "../_dev.mjs";
16
16
  import "../_libs/plugin-alias.mjs";
17
17
  import "../_libs/plugin-commonjs.mjs";
18
18
  import "../_libs/plugin-inject.mjs";
19
- import "../_chunks/rU_kdJ2P.mjs";
19
+ import "../_chunks/BY3yPF44.mjs";
20
+ import "../_libs/etag.mjs";
20
21
  import "../_libs/remapping.mjs";
21
22
  import "../_libs/plugin-replace.mjs";
22
- import "../_libs/etag.mjs";
23
23
  import { t as nitro } from "./vite.plugin.mjs";
24
24
  import "../_libs/vite-plugin-fullstack.mjs";
25
25
 
@@ -1,16 +1,16 @@
1
1
  import { C as isAbsolute$1, O as relative$1, b as basename$1, h as resolveModulePath, k as resolve$1, o as debounce, w as join$1, x as dirname$1 } from "../_libs/c12.mjs";
2
- import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
2
+ import { d as sanitizeFilePath } from "../_libs/local-pkg.mjs";
3
3
  import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
4
- import { n as T, r as a } from "../_libs/std-env.mjs";
5
- import { a as copyPublicAssets, i as prepare, s as createNitro } from "../_chunks/_yl3G_3Y.mjs";
4
+ import { i as a, r as T } from "../_libs/std-env.mjs";
5
+ import { a as copyPublicAssets, i as prepare, s as createNitro } from "../_chunks/CvxEFBdh.mjs";
6
6
  import { n as prettyPath } from "../_chunks/DJvLZH4H.mjs";
7
- import { i as scanHandlers } from "../_chunks/XHOrB-Xs.mjs";
7
+ import { i as scanHandlers } from "../_chunks/Ddt06bL8.mjs";
8
8
  import { n as writeBuildInfo, t as getBuildInfo } from "./common.mjs";
9
9
  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/rU_kdJ2P.mjs";
13
+ import { n as getChunkName, r as baseBuildConfig, t as baseBuildPlugins } from "../_chunks/BY3yPF44.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";
@@ -363,7 +363,11 @@ function createNitroEnvironment(ctx) {
363
363
  commonjsOptions: { ...ctx.nitro.options.commonJS }
364
364
  },
365
365
  resolve: {
366
- noExternal: ctx.nitro.options.dev ? [...ctx.rollupConfig.base.noExternal.filter((i) => typeof i === "string" || i instanceof RegExp), ...runtimeDependencies] : true,
366
+ noExternal: ctx.nitro.options.dev ? [
367
+ /^nitro$/,
368
+ /* @__PURE__ */ new RegExp(`^(${runtimeDependencies.join("|")})$`),
369
+ ...ctx.rollupConfig.base.noExternal
370
+ ] : true,
367
371
  conditions: ctx.nitro.options.exportConditions,
368
372
  externalConditions: ctx.nitro.options.exportConditions
369
373
  },
@@ -381,6 +385,7 @@ function createServiceEnvironment(ctx, name, serviceConfig) {
381
385
  emptyOutDir: true
382
386
  },
383
387
  resolve: {
388
+ noExternal: ctx.nitro.options.dev ? ctx.rollupConfig.base.noExternal : true,
384
389
  conditions: ctx.nitro.options.exportConditions,
385
390
  externalConditions: ctx.nitro.options.exportConditions
386
391
  },
@@ -1,28 +1,46 @@
1
1
  import { i as __toESM } from "./QkUO_zA6.mjs";
2
- import { O as relative, T as normalize, k as resolve, w as join, x as dirname } from "../_libs/c12.mjs";
3
- import { c as parseNodeModulePath } from "../_libs/local-pkg.mjs";
2
+ import { C as isAbsolute, O as relative, T as normalize, h as resolveModulePath, k as resolve, w as join } from "../_libs/c12.mjs";
3
+ import { s as parseNodeModulePath } from "../_libs/local-pkg.mjs";
4
4
  import { i as unplugin } from "../_libs/unimport.mjs";
5
5
  import { t as glob } from "../_libs/tinyglobby.mjs";
6
+ import { i as a, r as T, t as A } from "../_libs/std-env.mjs";
6
7
  import { t as src_default } from "../_libs/mime.mjs";
7
8
  import { i as genSafeVariableName, t as genImport } from "../_libs/knitwork.mjs";
8
- import { t as unwasm } from "../_libs/unwasm.mjs";
9
- import { t as replace } from "../_libs/plugin-replace.mjs";
10
9
  import { t as require_etag } from "../_libs/etag.mjs";
10
+ import { t as replace } from "../_libs/plugin-replace.mjs";
11
+ import { t as unwasm } from "../_libs/unwasm.mjs";
12
+ import { builtinModules, createRequire } from "node:module";
13
+ import { consola } from "consola";
11
14
  import { camelCase } from "scule";
12
15
  import { promises } from "node:fs";
13
16
  import { joinURL, withTrailingSlash } from "ufo";
14
- import { fileURLToPath } from "node:url";
17
+ import { fileURLToPath, pathToFileURL } from "node:url";
15
18
  import { readFile } from "node:fs/promises";
16
- import { defu } from "defu";
17
- import { pkgDir, presetsDir, runtimeDependencies, runtimeDir } from "nitro/meta";
19
+ import { pkgDir, runtimeDir } from "nitro/meta";
18
20
  import { hash } from "ohash";
19
21
  import { defineEnv } from "unenv";
20
- import { transformSync } from "oxc-transform";
21
- import { rollupNodeFileTrace } from "nf3";
22
22
  import { connectors } from "db0";
23
23
  import { RENDER_CONTEXT_KEYS, compileTemplateToString, hasTemplateSyntax } from "rendu";
24
24
  import { builtinDrivers, normalizeKey } from "unstorage";
25
+ import { transformSync } from "oxc-transform";
26
+
27
+ //#region src/utils/regex.ts
28
+ function escapeRegExp(string) {
29
+ return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
30
+ }
31
+ function pathRegExp(string) {
32
+ if (A) string = string.replace(/\\/g, "/");
33
+ let escaped = escapeRegExp(string);
34
+ if (A) escaped = escaped.replace(/\//g, String.raw`[/\\]`);
35
+ return escaped;
36
+ }
37
+ function toPathRegExp(input) {
38
+ if (input instanceof RegExp) return input;
39
+ if (typeof input === "string") return new RegExp(pathRegExp(input));
40
+ throw new TypeError("Expected a string or RegExp", { cause: input });
41
+ }
25
42
 
43
+ //#endregion
26
44
  //#region src/build/config.ts
27
45
  function baseBuildConfig(nitro) {
28
46
  const extensions = [
@@ -50,22 +68,6 @@ function baseBuildConfig(nitro) {
50
68
  ...Object.fromEntries(Object.entries(importMetaInjections).map(([key, val]) => [`import.meta.${key}`, JSON.stringify(val)])),
51
69
  ...nitro.options.replace
52
70
  };
53
- const noExternal = [
54
- "#",
55
- "~",
56
- "@/",
57
- "~~",
58
- "@@/",
59
- "virtual:",
60
- "nitro",
61
- pkgDir,
62
- nitro.options.serverDir,
63
- nitro.options.buildDir,
64
- dirname(nitro.options.entry),
65
- ...nitro.options.wasm === false ? [] : [(id) => id.endsWith(".wasm")],
66
- ...nitro.options.handlers.map((m) => m.handler).filter((i) => typeof i === "string"),
67
- ...nitro.options.dev || nitro.options.preset === "nitro-prerender" ? [] : runtimeDependencies
68
- ].filter(Boolean);
69
71
  const { env } = defineEnv({
70
72
  nodeCompat: isNodeless,
71
73
  resolve: true,
@@ -73,17 +75,27 @@ function baseBuildConfig(nitro) {
73
75
  overrides: { alias: nitro.options.alias }
74
76
  });
75
77
  return {
76
- presetsDir,
77
78
  extensions,
78
79
  isNodeless,
79
80
  replacements,
80
81
  env,
81
82
  aliases: resolveAliases({ ...env.alias }),
82
- noExternal
83
+ noExternal: getNoExternals(nitro)
83
84
  };
84
85
  }
86
+ function getNoExternals(nitro) {
87
+ const noExternal = [
88
+ /\.[mc]?tsx?$/,
89
+ /^(?:[\0#~.]|virtual:)/,
90
+ /* @__PURE__ */ new RegExp("^" + pathRegExp(pkgDir) + "(?!.*node_modules)"),
91
+ ...[nitro.options.rootDir, ...nitro.options.scanDirs.filter((dir) => dir.includes("node_modules") || !dir.startsWith(nitro.options.rootDir))].map((dir) => /* @__PURE__ */ new RegExp("^" + pathRegExp(dir) + "(?!.*node_modules)"))
92
+ ];
93
+ if (nitro.options.wasm !== false) noExternal.push(/\.wasm$/);
94
+ if (Array.isArray(nitro.options.noExternals)) noExternal.push(...nitro.options.noExternals.filter(Boolean).map((item) => toPathRegExp(item)));
95
+ return noExternal.sort((a$1, b) => a$1.source.length - b.source.length);
96
+ }
85
97
  function resolveAliases(_aliases) {
86
- const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a], [b]) => b.split("/").length - a.split("/").length || b.length - a.length));
98
+ const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a$1], [b]) => b.split("/").length - a$1.split("/").length || b.length - a$1.length));
87
99
  for (const key in aliases) for (const alias in aliases) {
88
100
  if (![
89
101
  "~",
@@ -137,243 +149,6 @@ function routeToFsPath(route) {
137
149
  return route.split("/").slice(1).map((s) => `${s.replace(/[:*]+/g, "$").replace(/[^$a-zA-Z0-9_.[\]/]/g, "_")}`).join("/") || "index";
138
150
  }
139
151
 
140
- //#endregion
141
- //#region src/utils/regex.ts
142
- function escapeRegExp(string) {
143
- return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
144
- }
145
-
146
- //#endregion
147
- //#region src/build/plugins/route-meta.ts
148
- const PREFIX$2 = "\0nitro:route-meta:";
149
- function routeMeta(nitro) {
150
- return {
151
- name: "nitro:route-meta",
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
- }
160
- }
161
- },
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
- }
167
- },
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}`);
181
- }
182
- return {
183
- code: `export default ${JSON.stringify(meta)};`,
184
- map: null
185
- };
186
- }
187
- }
188
- };
189
- }
190
- function astToObject(node) {
191
- switch (node.type) {
192
- case "ObjectExpression": {
193
- const obj = {};
194
- for (const prop of node.properties) if (prop.type === "Property") {
195
- const key = prop.key.name ?? prop.key.value;
196
- obj[key] = astToObject(prop.value);
197
- }
198
- return obj;
199
- }
200
- case "ArrayExpression": return node.elements.map((el) => astToObject(el)).filter(Boolean);
201
- case "Literal": return node.value;
202
- }
203
- }
204
-
205
- //#endregion
206
- //#region src/build/plugins/server-main.ts
207
- function serverMain(nitro) {
208
- return {
209
- name: "nitro:server-main",
210
- renderChunk(code, chunk) {
211
- if (chunk.isEntry) return {
212
- code: `globalThis.__nitro_main__ = import.meta.url; ${code}`,
213
- map: null
214
- };
215
- }
216
- };
217
- }
218
-
219
- //#endregion
220
- //#region src/build/plugins/virtual.ts
221
- const PREFIX$1 = "\0nitro:virtual:";
222
- function virtual(input) {
223
- const modules = /* @__PURE__ */ new Map();
224
- for (const mod of input) {
225
- const render = () => typeof mod.template === "function" ? mod.template() : mod.template;
226
- modules.set(mod.id, {
227
- module: mod,
228
- render
229
- });
230
- }
231
- return {
232
- name: "nitro:virtual",
233
- api: { modules },
234
- resolveId: {
235
- order: "pre",
236
- filter: { id: /* @__PURE__ */ new RegExp(`^(${[...modules.keys()].map((id) => escapeRegExp(id)).join("|")})$`) },
237
- handler: (id) => {
238
- const mod = modules.get(id);
239
- if (!mod) return null;
240
- return {
241
- id: PREFIX$1 + id,
242
- moduleSideEffects: mod.module.moduleSideEffects ?? false
243
- };
244
- }
245
- },
246
- load: {
247
- order: "pre",
248
- filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$1)}`) },
249
- handler: async (id) => {
250
- const idNoPrefix = id.slice(15);
251
- const mod = modules.get(idNoPrefix);
252
- if (!mod) throw new Error(`Virtual module ${idNoPrefix} not found.`);
253
- return {
254
- code: await mod.render(),
255
- map: null
256
- };
257
- }
258
- }
259
- };
260
- }
261
-
262
- //#endregion
263
- //#region src/build/plugins/resolve.ts
264
- const subpathMap = {
265
- "nitro/h3": "h3",
266
- "nitro/deps/h3": "h3",
267
- "nitro/deps/ofetch": "ofetch"
268
- };
269
- function nitroResolveIds() {
270
- return {
271
- name: "nitro:resolve-ids",
272
- resolveId: {
273
- order: "pre",
274
- handler(id, importer, rOpts) {
275
- if (importer && importer.startsWith("\0nitro:virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
276
- const mappedId = subpathMap[id];
277
- if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
278
- }
279
- }
280
- };
281
- }
282
-
283
- //#endregion
284
- //#region src/build/plugins/sourcemap-min.ts
285
- function sourcemapMinify() {
286
- return {
287
- name: "nitro:sourcemap-minify",
288
- generateBundle(_options, bundle) {
289
- for (const [key, asset] of Object.entries(bundle)) {
290
- if (!key.endsWith(".map") || !("source" in asset) || typeof asset.source !== "string") continue;
291
- const sourcemap = JSON.parse(asset.source);
292
- delete sourcemap.sourcesContent;
293
- delete sourcemap.x_google_ignoreList;
294
- if ((sourcemap.sources || []).some((s) => s.includes("node_modules"))) sourcemap.mappings = "";
295
- asset.source = JSON.stringify(sourcemap);
296
- }
297
- }
298
- };
299
- }
300
-
301
- //#endregion
302
- //#region src/build/plugins/raw.ts
303
- const HELPER_ID = "\0nitro-raw-helpers";
304
- const RESOLVED_PREFIX = "\0nitro:raw:";
305
- const PREFIX = "raw:";
306
- function raw() {
307
- return {
308
- name: "nitro:raw",
309
- resolveId: {
310
- order: "pre",
311
- filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${PREFIX}`)] },
312
- async handler(id, importer, resolveOpts) {
313
- if (id === HELPER_ID) return 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
- }
319
- }
320
- },
321
- load: {
322
- order: "pre",
323
- filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`)] },
324
- handler(id) {
325
- if (id === HELPER_ID) return getHelpers();
326
- if (id.startsWith(RESOLVED_PREFIX)) return promises.readFile(id.slice(11), isBinary(id) ? "binary" : "utf8");
327
- }
328
- },
329
- transform: {
330
- order: "pre",
331
- filter: { id: /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`) },
332
- handler(code, id) {
333
- const path = id.slice(11);
334
- if (isBinary(id)) return {
335
- code: `import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
336
- map: rawAssetMap(path)
337
- };
338
- return {
339
- code: `export default ${JSON.stringify(code)}`,
340
- map: rawAssetMap(path),
341
- moduleType: "js"
342
- };
343
- }
344
- }
345
- };
346
- }
347
- function isBinary(id) {
348
- const idMime = src_default.getType(id) || "";
349
- if (idMime.startsWith("text/")) return false;
350
- if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
351
- return true;
352
- }
353
- function getHelpers() {
354
- return `
355
- export function base64ToUint8Array(str) {
356
- const data = atob(str);
357
- const size = data.length;
358
- const bytes = new Uint8Array(size);
359
- for (let i = 0; i < size; i++) {
360
- bytes[i] = data.charCodeAt(i);
361
- }
362
- return bytes;
363
- }
364
- `;
365
- }
366
- function rawAssetMap(id) {
367
- return {
368
- version: 3,
369
- file: id,
370
- sources: [id],
371
- sourcesContent: [],
372
- names: [],
373
- mappings: ""
374
- };
375
- }
376
-
377
152
  //#endregion
378
153
  //#region src/build/virtual/database.ts
379
154
  function database(nitro) {
@@ -922,8 +697,403 @@ function virtualTemplates(nitro, _polyfills) {
922
697
  }
923
698
 
924
699
  //#endregion
925
- //#region src/build/plugins.ts
926
- function baseBuildPlugins(nitro, base) {
700
+ //#region src/build/plugins/route-meta.ts
701
+ const PREFIX$2 = "\0nitro:route-meta:";
702
+ function routeMeta(nitro) {
703
+ return {
704
+ name: "nitro:route-meta",
705
+ resolveId: {
706
+ filter: { id: /^(?!\u0000)(.+)\?meta$/ },
707
+ async handler(id, importer, resolveOpts) {
708
+ if (id.endsWith("?meta")) {
709
+ const resolved = await this.resolve(id.replace("?meta", ""), importer, resolveOpts);
710
+ if (!resolved) return;
711
+ return PREFIX$2 + resolved.id;
712
+ }
713
+ }
714
+ },
715
+ load: {
716
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
717
+ handler(id) {
718
+ if (id.startsWith(PREFIX$2)) return readFile(id.slice(18), { encoding: "utf8" });
719
+ }
720
+ },
721
+ transform: {
722
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$2)}`) },
723
+ async handler(code, id) {
724
+ let meta = null;
725
+ try {
726
+ const jsCode = transformSync(id, code).code;
727
+ const ast = this.parse(jsCode);
728
+ 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) {
729
+ meta = astToObject(node.expression.arguments[0]);
730
+ break;
731
+ }
732
+ } catch (error) {
733
+ nitro.logger.warn(`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`);
734
+ }
735
+ return {
736
+ code: `export default ${JSON.stringify(meta)};`,
737
+ map: null
738
+ };
739
+ }
740
+ }
741
+ };
742
+ }
743
+ function astToObject(node) {
744
+ switch (node.type) {
745
+ case "ObjectExpression": {
746
+ const obj = {};
747
+ for (const prop of node.properties) if (prop.type === "Property") {
748
+ const key = prop.key.name ?? prop.key.value;
749
+ obj[key] = astToObject(prop.value);
750
+ }
751
+ return obj;
752
+ }
753
+ case "ArrayExpression": return node.elements.map((el) => astToObject(el)).filter(Boolean);
754
+ case "Literal": return node.value;
755
+ }
756
+ }
757
+
758
+ //#endregion
759
+ //#region src/build/plugins/server-main.ts
760
+ function serverMain(nitro) {
761
+ return {
762
+ name: "nitro:server-main",
763
+ renderChunk(code, chunk) {
764
+ if (chunk.isEntry) return {
765
+ code: `globalThis.__nitro_main__ = import.meta.url; ${code}`,
766
+ map: null
767
+ };
768
+ }
769
+ };
770
+ }
771
+
772
+ //#endregion
773
+ //#region src/build/plugins/virtual.ts
774
+ const PREFIX$1 = "\0nitro:virtual:";
775
+ function virtual(input) {
776
+ const modules = /* @__PURE__ */ new Map();
777
+ for (const mod of input) {
778
+ const render = () => typeof mod.template === "function" ? mod.template() : mod.template;
779
+ modules.set(mod.id, {
780
+ module: mod,
781
+ render
782
+ });
783
+ }
784
+ return {
785
+ name: "nitro:virtual",
786
+ api: { modules },
787
+ resolveId: {
788
+ order: "pre",
789
+ filter: { id: /* @__PURE__ */ new RegExp(`^(${[...modules.keys()].map((id) => pathRegExp(id)).join("|")})$`) },
790
+ handler: (id) => {
791
+ const mod = modules.get(id);
792
+ if (!mod) return null;
793
+ return {
794
+ id: PREFIX$1 + id,
795
+ moduleSideEffects: mod.module.moduleSideEffects ?? false
796
+ };
797
+ }
798
+ },
799
+ load: {
800
+ order: "pre",
801
+ filter: { id: /* @__PURE__ */ new RegExp(`^${escapeRegExp(PREFIX$1)}`) },
802
+ handler: async (id) => {
803
+ const idNoPrefix = id.slice(15);
804
+ const mod = modules.get(idNoPrefix);
805
+ if (!mod) throw new Error(`Virtual module ${idNoPrefix} not found.`);
806
+ return {
807
+ code: await mod.render(),
808
+ map: null
809
+ };
810
+ }
811
+ }
812
+ };
813
+ }
814
+
815
+ //#endregion
816
+ //#region src/build/plugins/resolve.ts
817
+ const subpathMap = {
818
+ "nitro/h3": "h3",
819
+ "nitro/deps/h3": "h3",
820
+ "nitro/deps/ofetch": "ofetch"
821
+ };
822
+ function nitroResolveIds() {
823
+ return {
824
+ name: "nitro:resolve-ids",
825
+ resolveId: {
826
+ order: "pre",
827
+ handler(id, importer, rOpts) {
828
+ if (importer && importer.startsWith("\0nitro:virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
829
+ const mappedId = subpathMap[id];
830
+ if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
831
+ }
832
+ }
833
+ };
834
+ }
835
+
836
+ //#endregion
837
+ //#region src/build/plugins/sourcemap-min.ts
838
+ function sourcemapMinify() {
839
+ return {
840
+ name: "nitro:sourcemap-minify",
841
+ generateBundle(_options, bundle) {
842
+ for (const [key, asset] of Object.entries(bundle)) {
843
+ if (!key.endsWith(".map") || !("source" in asset) || typeof asset.source !== "string") continue;
844
+ const sourcemap = JSON.parse(asset.source);
845
+ delete sourcemap.sourcesContent;
846
+ delete sourcemap.x_google_ignoreList;
847
+ if ((sourcemap.sources || []).some((s) => s.includes("node_modules"))) sourcemap.mappings = "";
848
+ asset.source = JSON.stringify(sourcemap);
849
+ }
850
+ }
851
+ };
852
+ }
853
+
854
+ //#endregion
855
+ //#region src/build/plugins/raw.ts
856
+ const HELPER_ID = "\0nitro-raw-helpers";
857
+ const RESOLVED_PREFIX = "\0nitro:raw:";
858
+ const PREFIX = "raw:";
859
+ function raw() {
860
+ return {
861
+ name: "nitro:raw",
862
+ resolveId: {
863
+ order: "pre",
864
+ filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${PREFIX}`)] },
865
+ async handler(id, importer, resolveOpts) {
866
+ if (id === HELPER_ID) return id;
867
+ if (id.startsWith(PREFIX)) {
868
+ const resolvedId = (await this.resolve(id.slice(4), importer, resolveOpts))?.id;
869
+ if (!resolvedId) return null;
870
+ return { id: RESOLVED_PREFIX + resolvedId };
871
+ }
872
+ }
873
+ },
874
+ load: {
875
+ order: "pre",
876
+ filter: { id: [/* @__PURE__ */ new RegExp(`^${HELPER_ID}$`), /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`)] },
877
+ handler(id) {
878
+ if (id === HELPER_ID) return getHelpers();
879
+ if (id.startsWith(RESOLVED_PREFIX)) return promises.readFile(id.slice(11), isBinary(id) ? "binary" : "utf8");
880
+ }
881
+ },
882
+ transform: {
883
+ order: "pre",
884
+ filter: { id: /* @__PURE__ */ new RegExp(`^${RESOLVED_PREFIX}`) },
885
+ handler(code, id) {
886
+ const path = id.slice(11);
887
+ if (isBinary(id)) return {
888
+ code: `import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
889
+ map: rawAssetMap(path)
890
+ };
891
+ return {
892
+ code: `export default ${JSON.stringify(code)}`,
893
+ map: rawAssetMap(path),
894
+ moduleType: "js"
895
+ };
896
+ }
897
+ }
898
+ };
899
+ }
900
+ function isBinary(id) {
901
+ const idMime = src_default.getType(id) || "";
902
+ if (idMime.startsWith("text/")) return false;
903
+ if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
904
+ return true;
905
+ }
906
+ function getHelpers() {
907
+ return `
908
+ export function base64ToUint8Array(str) {
909
+ const data = atob(str);
910
+ const size = data.length;
911
+ const bytes = new Uint8Array(size);
912
+ for (let i = 0; i < size; i++) {
913
+ bytes[i] = data.charCodeAt(i);
914
+ }
915
+ return bytes;
916
+ }
917
+ `;
918
+ }
919
+ function rawAssetMap(id) {
920
+ return {
921
+ version: 3,
922
+ file: id,
923
+ sources: [id],
924
+ sourcesContent: [],
925
+ names: [],
926
+ mappings: ""
927
+ };
928
+ }
929
+
930
+ //#endregion
931
+ //#region src/utils/dep.ts
932
+ async function importDep(opts, _retry) {
933
+ const resolved = resolveModulePath(opts.id, {
934
+ from: [opts.dir, import.meta.url],
935
+ cache: _retry ? false : true,
936
+ try: true
937
+ });
938
+ if (resolved) return await import(resolved);
939
+ let shouldInstall;
940
+ if (_retry || a) shouldInstall = false;
941
+ else if (T) {
942
+ consola.info(`\`${opts.id}\` is required for ${opts.reason}. Installing automatically in CI environment...`);
943
+ shouldInstall = true;
944
+ } else shouldInstall = await consola.prompt(`\`${opts.id}\` is required for ${opts.reason}, but it is not installed. Would you like to install it?`, {
945
+ type: "confirm",
946
+ default: true,
947
+ cancel: "undefined"
948
+ });
949
+ if (!shouldInstall) throw new Error(`\`${opts.id}\` is not installed. Please add it to your dependencies for ${opts.reason}.`);
950
+ const start = Date.now();
951
+ consola.start(`Installing \`${opts.id}\` in \`${opts.dir}\`...`);
952
+ const { addDevDependency } = await import("../cli/_chunks/dist4.mjs");
953
+ await addDevDependency(opts.id, { cwd: opts.dir });
954
+ consola.success(`Installed \`${opts.id}\` in ${opts.dir} (${Date.now() - start}ms).`);
955
+ return importDep(opts, true);
956
+ }
957
+
958
+ //#endregion
959
+ //#region src/build/plugins/externals.ts
960
+ const PLUGIN_NAME = "nitro:externals";
961
+ function externals(opts) {
962
+ const include = opts?.include ? opts.include.map((p) => toPathRegExp(p)) : void 0;
963
+ const exclude = [/^(?:[\0#~.]|[a-z0-9]{2,}:)|\?/, ...(opts?.exclude || []).map((p) => toPathRegExp(p))];
964
+ const filter = (id) => {
965
+ if (include && !include.some((r) => r.test(id))) return false;
966
+ if (exclude.some((r) => r.test(id))) return false;
967
+ return true;
968
+ };
969
+ const tryResolve = (id, from) => resolveModulePath(id, {
970
+ try: true,
971
+ from: from && isAbsolute(from) ? from : opts.rootDir,
972
+ conditions: opts.conditions
973
+ });
974
+ const tracedPaths = /* @__PURE__ */ new Set();
975
+ return {
976
+ name: PLUGIN_NAME,
977
+ resolveId: {
978
+ order: "pre",
979
+ filter: { id: {
980
+ exclude,
981
+ include
982
+ } },
983
+ async handler(id, importer, rOpts) {
984
+ if (builtinModules.includes(id)) return {
985
+ resolvedBy: PLUGIN_NAME,
986
+ external: true,
987
+ id: id.includes(":") ? id : `node:${id}`
988
+ };
989
+ if (rOpts.custom?.["node-resolve"]) return null;
990
+ let resolved = await this.resolve(id, importer, rOpts);
991
+ const cjsResolved = resolved?.meta?.commonjs?.resolved;
992
+ if (cjsResolved) {
993
+ if (!filter(cjsResolved.id)) return resolved;
994
+ resolved = cjsResolved;
995
+ }
996
+ if (!resolved?.id || !filter(resolved.id)) return resolved;
997
+ let resolvedPath = resolved.id;
998
+ if (!isAbsolute(resolvedPath)) resolvedPath = tryResolve(resolvedPath, importer) || resolvedPath;
999
+ if (opts.trace) {
1000
+ let importId = toImport(id) || toImport(resolvedPath);
1001
+ if (!importId) return resolved;
1002
+ if (!tryResolve(importId, importer)) {
1003
+ const guessed = await guessSubpath(resolvedPath, opts.conditions);
1004
+ if (!guessed) return resolved;
1005
+ importId = guessed;
1006
+ }
1007
+ tracedPaths.add(resolvedPath);
1008
+ return {
1009
+ ...resolved,
1010
+ resolvedBy: PLUGIN_NAME,
1011
+ external: true,
1012
+ id: importId
1013
+ };
1014
+ }
1015
+ return {
1016
+ ...resolved,
1017
+ resolvedBy: PLUGIN_NAME,
1018
+ external: true,
1019
+ id: isAbsolute(resolvedPath) ? pathToFileURL(resolvedPath).href : resolvedPath
1020
+ };
1021
+ }
1022
+ },
1023
+ buildEnd: {
1024
+ order: "post",
1025
+ async handler() {
1026
+ if (!opts.trace || tracedPaths.size === 0) return;
1027
+ const { traceNodeModules } = await importDep({
1028
+ id: "nf3",
1029
+ dir: opts.rootDir,
1030
+ reason: "tracing external dependencies"
1031
+ });
1032
+ await traceNodeModules([...tracedPaths], {
1033
+ ...opts.trace,
1034
+ exportConditions: opts.conditions,
1035
+ rootDir: opts.rootDir,
1036
+ writePackageJson: true,
1037
+ traceOptions: {
1038
+ base: "/",
1039
+ exportsOnly: true,
1040
+ processCwd: opts.rootDir
1041
+ }
1042
+ });
1043
+ }
1044
+ }
1045
+ };
1046
+ }
1047
+ const NODE_MODULES_RE = /^(?<dir>.+\/node_modules\/)(?<name>[^/@]+|@[^/]+\/[^/]+)(?:\/(?<subpath>.+))?$/;
1048
+ const IMPORT_RE = /^(?!\.)(?<name>[^/@]+|@[^/]+\/[^/]+)(?:\/(?<subpath>.+))?$/;
1049
+ function toImport(id) {
1050
+ if (isAbsolute(id)) {
1051
+ const { name, subpath } = NODE_MODULES_RE.exec(id)?.groups || {};
1052
+ if (name && subpath) return join(name, subpath);
1053
+ } else if (IMPORT_RE.test(id)) return id;
1054
+ }
1055
+ function guessSubpath(path, conditions) {
1056
+ const { dir, name, subpath } = NODE_MODULES_RE.exec(path)?.groups || {};
1057
+ if (!dir || !name || !subpath) return;
1058
+ const exports = getPkgJSON(join(dir, name) + "/")?.exports;
1059
+ if (!exports || typeof exports !== "object") return;
1060
+ for (const e of flattenExports(exports)) {
1061
+ if (!conditions.includes(e.condition || "default")) continue;
1062
+ if (e.fsPath === subpath) return join(name, e.subpath);
1063
+ if (e.fsPath.includes("*")) {
1064
+ const fsPathRe = /* @__PURE__ */ new RegExp("^" + escapeRegExp(e.fsPath).replace(String.raw`\*`, "(.+?)") + "$");
1065
+ if (fsPathRe.test(subpath)) {
1066
+ const matched = fsPathRe.exec(subpath)?.[1];
1067
+ if (matched) return join(name, e.subpath.replace("*", matched));
1068
+ }
1069
+ }
1070
+ }
1071
+ }
1072
+ function getPkgJSON(dir) {
1073
+ const cache = getPkgJSON._cache ||= /* @__PURE__ */ new Map();
1074
+ if (cache.has(dir)) return cache.get(dir);
1075
+ try {
1076
+ const pkg = createRequire(dir)("./package.json");
1077
+ cache.set(dir, pkg);
1078
+ return pkg;
1079
+ } catch {}
1080
+ }
1081
+ function flattenExports(exports = {}, parentSubpath = "./") {
1082
+ return Object.entries(exports).flatMap(([key, value]) => {
1083
+ const [subpath, condition] = key.startsWith(".") ? [key.slice(1)] : [void 0, key];
1084
+ const _subPath = join(parentSubpath, subpath || "");
1085
+ if (typeof value === "string") return [{
1086
+ subpath: _subPath,
1087
+ fsPath: value.replace(/^\.\//, ""),
1088
+ condition
1089
+ }];
1090
+ return typeof value === "object" ? flattenExports(value, _subPath) : [];
1091
+ });
1092
+ }
1093
+
1094
+ //#endregion
1095
+ //#region src/build/plugins.ts
1096
+ function baseBuildPlugins(nitro, base) {
927
1097
  const plugins$1 = [];
928
1098
  if (nitro.options.imports) plugins$1.push(unplugin.rollup(nitro.options.imports));
929
1099
  if (nitro.options.wasm !== false) plugins$1.push(unwasm(nitro.options.wasm || {}));
@@ -938,23 +1108,16 @@ function baseBuildPlugins(nitro, base) {
938
1108
  preventAssignment: true,
939
1109
  values: base.replacements
940
1110
  }));
941
- if (!nitro.options.noExternals) plugins$1.push(rollupNodeFileTrace(defu(nitro.options.externals, {
942
- outDir: nitro.options.output.serverDir,
943
- moduleDirectories: nitro.options.nodeModulesDirs,
944
- external: nitro.options.nodeModulesDirs,
945
- inline: [...base.noExternal],
946
- traceOptions: {
947
- base: "/",
948
- processCwd: nitro.options.rootDir,
949
- exportsOnly: true
950
- },
951
- traceAlias: {
952
- "h3-nightly": "h3",
953
- ...nitro.options.externals?.traceAlias
954
- },
955
- exportConditions: nitro.options.exportConditions,
956
- writePackageJson: true
957
- })));
1111
+ if (nitro.options.node && nitro.options.noExternals !== true) {
1112
+ const isDevOrPrerender = nitro.options.dev || nitro.options.preset === "nitro-prerender";
1113
+ plugins$1.push(externals({
1114
+ rootDir: nitro.options.rootDir,
1115
+ conditions: nitro.options.exportConditions || ["default"],
1116
+ exclude: [...base.noExternal],
1117
+ include: isDevOrPrerender ? void 0 : nitro.options.traceDeps,
1118
+ trace: isDevOrPrerender ? false : { outDir: nitro.options.output.serverDir }
1119
+ }));
1120
+ }
958
1121
  if (nitro.options.sourcemap && !nitro.options.dev && nitro.options.experimental.sourcemapMinify !== false) plugins$1.push(sourcemapMinify());
959
1122
  return plugins$1;
960
1123
  }
@@ -3,11 +3,11 @@ import { a as createUnimport } from "../_libs/unimport.mjs";
3
3
  import { t as glob } from "../_libs/tinyglobby.mjs";
4
4
  import { n as resolveCompatibilityDates, r as resolveCompatibilityDatesFromEnv } from "../_libs/compatx.mjs";
5
5
  import { t as klona } from "../_libs/klona.mjs";
6
- import { i as d, r as a } from "../_libs/std-env.mjs";
6
+ import { a as d, i as a } from "../_libs/std-env.mjs";
7
7
  import { t as escapeStringRegexp } from "../_libs/escape-string-regexp.mjs";
8
8
  import { n as parse, t as TSConfckCache } from "../_libs/tsconfck.mjs";
9
9
  import { i as writeFile$1, n as prettyPath, r as resolveNitroPath, t as isDirectory } from "./DJvLZH4H.mjs";
10
- import { i as scanHandlers, r as scanAndSyncOptions, t as runParallel } from "./XHOrB-Xs.mjs";
10
+ import { i as scanHandlers, r as scanAndSyncOptions, t as runParallel } from "./Ddt06bL8.mjs";
11
11
  import { a as findRoute, i as findAllRoutes, n as addRoute, r as createRouter, t as compileRouterToString } from "../_libs/rou3.mjs";
12
12
  import { t as src_default } from "../_libs/mime.mjs";
13
13
  import { n as z, t as P } from "../_libs/ultrahtml.mjs";
@@ -57,6 +57,7 @@ const NitroDefaults = {
57
57
  virtual: {},
58
58
  compressPublicAssets: false,
59
59
  ignore: [],
60
+ wasm: {},
60
61
  dev: false,
61
62
  devServer: { watch: [] },
62
63
  watchOptions: { ignoreInitial: true },
@@ -87,6 +88,7 @@ const NitroDefaults = {
87
88
  replace: {},
88
89
  node: true,
89
90
  sourcemap: false,
91
+ traceDeps: [],
90
92
  typescript: {
91
93
  strict: true,
92
94
  generateRuntimeConfigTypes: false,
@@ -1,7 +1,7 @@
1
1
  import { O as relative, k as resolve, x as dirname } from "../_libs/c12.mjs";
2
2
  import { t as glob } from "../_libs/tinyglobby.mjs";
3
- import { r as a } from "../_libs/std-env.mjs";
4
- import { t as runParallel } from "./XHOrB-Xs.mjs";
3
+ import { i as a } from "../_libs/std-env.mjs";
4
+ import { t as runParallel } from "./Ddt06bL8.mjs";
5
5
  import { t as gzipSize } from "../_libs/gzip-size.mjs";
6
6
  import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
7
7
  import { promises } from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { C as isAbsolute, O as relative, h as resolveModulePath, k as resolve, w as join, x as dirname } from "../_libs/c12.mjs";
2
- import { c as parseNodeModulePath, s as lookupNodeModuleSubpath } from "../_libs/local-pkg.mjs";
2
+ import { o as lookupNodeModuleSubpath, s as parseNodeModulePath } from "../_libs/local-pkg.mjs";
3
3
  import { o as toExports } from "../_libs/unimport.mjs";
4
4
  import { t as glob } from "../_libs/tinyglobby.mjs";
5
5
  import { i as writeFile, r as resolveNitroPath, t as isDirectory } from "./DJvLZH4H.mjs";
package/dist/_dev.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { S as extname$1, k as resolve$1, o as debounce, w as join$1 } from "./_libs/c12.mjs";
2
- import { n as T, r as a } from "./_libs/std-env.mjs";
2
+ import { i as a, r as T } from "./_libs/std-env.mjs";
3
3
  import { t as src_default } from "./_libs/mime.mjs";
4
4
  import { r as writeDevBuildInfo } from "./_build/common.mjs";
5
5
  import { n as createProxyServer } from "./_libs/httpxy.mjs";
@@ -1683,4 +1683,4 @@ const isPackageListed = quansync(function* (name, cwd$1) {
1683
1683
  const isPackageListedSync = isPackageListed.sync;
1684
1684
 
1685
1685
  //#endregion
1686
- export { findStaticImports as a, parseNodeModulePath as c, resolveModuleExportNames as d, sanitizeFilePath as f, findExports as i, parseStaticImport as l, detectSyntax as n, findTypeExports as o, fileURLToPath$1 as r, lookupNodeModuleSubpath as s, resolveModule as t, resolve$1 as u };
1686
+ export { findTypeExports as a, parseStaticImport as c, sanitizeFilePath as d, findStaticImports as i, resolve$1 as l, detectSyntax as n, lookupNodeModuleSubpath as o, findExports as r, parseNodeModulePath as s, resolveModule as t, resolveModuleExportNames as u };
@@ -155,4 +155,4 @@ function G() {
155
155
  const P = G(), K = P?.name || "";
156
156
 
157
157
  //#endregion
158
- export { p as a, d as i, T as n, a as r, K as t };
158
+ export { d as a, a as i, K as n, p as o, T as r, A as t };
@@ -2,7 +2,7 @@ import { i as __toESM, n as __require, t as __commonJSMin } from "../_chunks/QkU
2
2
  import { C as isAbsolute$1, D as parse$2, O as relative$1, T as normalize$2, b as basename$1, f as readPackageJSON, k as resolve$1, m as resolvePackageJSON, w as join$1, x as dirname$1 } from "./c12.mjs";
3
3
  import { t as MagicString } from "./magic-string.mjs";
4
4
  import { n as parse, t as Parser } from "./acorn.mjs";
5
- import { a as findStaticImports, d as resolveModuleExportNames, i as findExports, l as parseStaticImport, n as detectSyntax, o as findTypeExports, t as resolveModule, u as resolve$2 } from "./local-pkg.mjs";
5
+ import { a as findTypeExports, c as parseStaticImport, i as findStaticImports, l as resolve$2, n as detectSyntax, r as findExports, t as resolveModule, u as resolveModuleExportNames } from "./local-pkg.mjs";
6
6
  import { t as stripLiteral } from "./strip-literal.mjs";
7
7
  import { t as require_picomatch } from "./picomatch.mjs";
8
8
  import { t as glob } from "./tinyglobby.mjs";
@@ -2,9 +2,10 @@ import { b as basename, h as resolveModulePath } from "./c12.mjs";
2
2
  import { t as MagicString } from "./magic-string.mjs";
3
3
  import { a as genString, i as genSafeVariableName, n as genObjectFromRaw, t as genImport } from "./knitwork.mjs";
4
4
  import { existsSync, promises } from "node:fs";
5
+ import { fileURLToPath } from "node:url";
5
6
  import { createHash } from "node:crypto";
6
7
 
7
- //#region node_modules/.pnpm/unwasm@0.5.1/node_modules/unwasm/dist/plugin/index.mjs
8
+ //#region node_modules/.pnpm/unwasm@0.5.2/node_modules/unwasm/dist/plugin/index.mjs
8
9
  var __create = Object.create;
9
10
  var __defProp = Object.defineProperty;
10
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5779,11 +5780,20 @@ function unwasm(opts) {
5779
5780
  external: true
5780
5781
  };
5781
5782
  if (WASM_ID_RE.test(id)) {
5782
- const r = await this.resolve(id, importer, { skipSelf: true });
5783
- if (r?.id && r.id !== id) return {
5784
- id: r.id.startsWith("file://") ? r.id.slice(7) : r.id,
5783
+ const resolved = await this.resolve(id, importer);
5784
+ if (!resolved?.id) return resolved;
5785
+ let resolvedId = resolved?.id;
5786
+ if (resolvedId && resolvedId.startsWith("file://")) resolvedId = fileURLToPath(resolvedId);
5787
+ return {
5788
+ ...resolved,
5789
+ id: resolvedId,
5785
5790
  external: false,
5786
- moduleSideEffects: false
5791
+ moduleSideEffects: false,
5792
+ resolvedBy: "unwasm",
5793
+ meta: {
5794
+ ...resolved.meta,
5795
+ unwasm: { resolved }
5796
+ }
5787
5797
  };
5788
5798
  }
5789
5799
  }
package/dist/_presets.mjs CHANGED
@@ -1,12 +1,10 @@
1
1
  import "./_chunks/QkUO_zA6.mjs";
2
2
  import { O as relative$1, _ as h, c as findNearestFile, d as readGitConfig, f as readPackageJSON, h as resolveModulePath, k as resolve$1, s as findFile, w as join$1, x as dirname$1 } from "./_libs/c12.mjs";
3
- import "./_libs/acorn.mjs";
4
3
  import { n as gr, t as Q } from "./_libs/confbox.mjs";
5
- import { r as fileURLToPath } from "./_libs/local-pkg.mjs";
6
4
  import "./_libs/fdir.mjs";
7
5
  import { t as glob } from "./_libs/tinyglobby.mjs";
8
6
  import { r as resolveCompatibilityDatesFromEnv, t as formatCompatibilityDate } from "./_libs/compatx.mjs";
9
- import { a as p, r as a, t as K } from "./_libs/std-env.mjs";
7
+ import { i as a, n as K, o as p } from "./_libs/std-env.mjs";
10
8
  import { i as writeFile$2 } from "./_chunks/DJvLZH4H.mjs";
11
9
  import { builtinModules } from "node:module";
12
10
  import consola$1 from "consola";
@@ -635,8 +633,6 @@ async function cloudflareDevModule(nitro) {
635
633
  persistDir,
636
634
  environment: config.environment
637
635
  };
638
- nitro.options.externals.inline = nitro.options.externals.inline || [];
639
- nitro.options.externals.inline.push(fileURLToPath(new URL("runtime/", import.meta.url)));
640
636
  nitro.options.plugins = nitro.options.plugins || [];
641
637
  nitro.options.plugins.unshift(resolveModulePath("./cloudflare/runtime/plugin.dev", {
642
638
  from: presetsDir,
@@ -862,7 +858,6 @@ const denoDeploy = defineNitroPreset({
862
858
  manifest: { deploymentId: process.env.DENO_DEPLOYMENT_ID },
863
859
  exportConditions: ["deno"],
864
860
  node: false,
865
- noExternals: true,
866
861
  serveStatic: "deno",
867
862
  commands: {
868
863
  preview: "",
package/dist/builder.mjs CHANGED
@@ -5,10 +5,10 @@ import "./_libs/acorn.mjs";
5
5
  import "./_libs/js-tokens.mjs";
6
6
  import "./_libs/unimport.mjs";
7
7
  import "./_libs/fdir.mjs";
8
- import { a as copyPublicAssets, c as loadOptions, i as prepare, n as runTask, o as build, r as prerender, s as createNitro, t as listTasks } from "./_chunks/_yl3G_3Y.mjs";
8
+ import { a as copyPublicAssets, c as loadOptions, i as prepare, n as runTask, o as build, r as prerender, s as createNitro, t as listTasks } from "./_chunks/CvxEFBdh.mjs";
9
9
  import "./_libs/tsconfck.mjs";
10
10
  import "./_chunks/DJvLZH4H.mjs";
11
- import { n as writeTypes } from "./_chunks/XHOrB-Xs.mjs";
11
+ import { n as writeTypes } from "./_chunks/Ddt06bL8.mjs";
12
12
  import "./_libs/mime.mjs";
13
13
  import { t as getBuildInfo } from "./_build/common.mjs";
14
14
  import { n as createDevServer } from "./_dev.mjs";
@@ -38,7 +38,7 @@ class EnvRunner {
38
38
  },
39
39
  },
40
40
  new ESModulesEvaluator(),
41
- process.env.DEBUG ? console.debug : undefined
41
+ process.env.NITRO_DEBUG ? console.debug : undefined
42
42
  );
43
43
 
44
44
  this.reload();
@@ -1,5 +1,5 @@
1
1
  export declare const version: string;
2
- export declare const pkgDir: string;
3
2
  export declare const runtimeDir: string;
4
3
  export declare const presetsDir: string;
4
+ export declare const pkgDir: string;
5
5
  export declare const runtimeDependencies: string[];
@@ -2,9 +2,9 @@ import { fileURLToPath } from "node:url";
2
2
  import packageJson from "../../package.json" with { type: "json" };
3
3
  export const version = packageJson.version;
4
4
  const resolve = (path) => fileURLToPath(new URL(path, import.meta.url));
5
- export const pkgDir = /* @__PURE__ */ resolve("../../");
6
5
  export const runtimeDir = /* @__PURE__ */ resolve("./");
7
6
  export const presetsDir = /* @__PURE__ */ resolve("../presets/");
7
+ export const pkgDir = /* @__PURE__ */ resolve("../../");
8
8
  export const runtimeDependencies = [
9
9
  "crossws",
10
10
  "croner",
@@ -7,10 +7,9 @@ import { Duplex } from "node:stream";
7
7
  import { ServerRequest, ServerRequest as ServerRequest$1 } from "srvx";
8
8
  import { FetchOptions, FetchRequest, FetchResponse } from "ofetch";
9
9
  import { Preset } from "unenv";
10
- import { JsxOptions, TransformOptions } from "oxc-transform";
11
- import { ExternalsPluginOptions as NodeExternalsOptions } from "nf3";
12
10
  import { ConnectorName } from "db0";
13
11
  import { BuiltinDriverName } from "unstorage";
12
+ import { JsxOptions, TransformOptions } from "oxc-transform";
14
13
  import { MinifyOptions } from "oxc-minify";
15
14
  import { InputOptions, OutputOptions } from "rollup";
16
15
  import { DevMessageListener as DevMessageListener$1, Nitro as Nitro$1 } from "nitro/types";
@@ -27,6 +26,7 @@ import { UnwasmPluginOptions } from "unwasm/plugin";
27
26
  import { Unimport } from "unimport";
28
27
  import { RouterContext } from "rou3";
29
28
  import { RouterCompilerOptions } from "rou3/compiler";
29
+ import { ExternalsPluginOptions as NodeExternalsOptions } from "nf3";
30
30
  import { ProviderName } from "std-env";
31
31
 
32
32
  //#region src/types/fetch/fetch.d.ts
@@ -3040,11 +3040,11 @@ interface NitroOptions extends PresetOptions {
3040
3040
  node: boolean;
3041
3041
  moduleSideEffects: string[];
3042
3042
  oxc?: OXCOptions;
3043
- noExternals: boolean;
3044
- externals: NodeExternalsOptions;
3045
3043
  replace: Record<string, string | ((id: string) => string)>;
3046
3044
  commonJS?: RollupCommonJSOptions;
3047
3045
  exportConditions?: string[];
3046
+ noExternals?: boolean | (string | RegExp)[];
3047
+ traceDeps?: (string | RegExp)[];
3048
3048
  typescript: {
3049
3049
  strict?: boolean;
3050
3050
  generateRuntimeConfigTypes?: boolean;
package/dist/vite.mjs CHANGED
@@ -5,20 +5,20 @@ import "./_libs/acorn.mjs";
5
5
  import "./_libs/js-tokens.mjs";
6
6
  import "./_libs/unimport.mjs";
7
7
  import "./_libs/fdir.mjs";
8
- import "./_chunks/_yl3G_3Y.mjs";
8
+ import "./_chunks/CvxEFBdh.mjs";
9
9
  import "./_libs/tsconfck.mjs";
10
10
  import "./_chunks/DJvLZH4H.mjs";
11
- import "./_chunks/XHOrB-Xs.mjs";
11
+ import "./_chunks/Ddt06bL8.mjs";
12
12
  import "./_libs/mime.mjs";
13
13
  import "./_build/common.mjs";
14
14
  import "./_dev.mjs";
15
15
  import "./_libs/plugin-alias.mjs";
16
16
  import "./_libs/plugin-commonjs.mjs";
17
17
  import "./_libs/plugin-inject.mjs";
18
- import "./_chunks/rU_kdJ2P.mjs";
18
+ import "./_chunks/BY3yPF44.mjs";
19
+ import "./_libs/etag.mjs";
19
20
  import "./_libs/remapping.mjs";
20
21
  import "./_libs/plugin-replace.mjs";
21
- import "./_libs/etag.mjs";
22
22
  import { t as nitro } from "./_build/vite.plugin.mjs";
23
23
  import "./_libs/vite-plugin-fullstack.mjs";
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251203-124621-d38ffe1f",
3
+ "version": "3.0.1-20251203-231615-3a2d2662",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -49,8 +49,8 @@
49
49
  "release": "pnpm test && pnpm build && changelogen --release --prerelease --push",
50
50
  "stub": "obuild --stub",
51
51
  "test": "pnpm lint && pnpm test:types && pnpm test:rollup && pnpm test:rolldown",
52
- "test:rollup": "NITRO_BUILDER=rollup pnpm vitest",
53
52
  "test:rolldown": "NITRO_BUILDER=rolldown pnpm vitest",
53
+ "test:rollup": "NITRO_BUILDER=rollup pnpm vitest",
54
54
  "test:types": "tsc --noEmit"
55
55
  },
56
56
  "resolutions": {
@@ -63,7 +63,6 @@
63
63
  "db0": "^0.3.4",
64
64
  "h3": "2.0.1-rc.5",
65
65
  "jiti": "^2.6.1",
66
- "nf3": "^0.1.12",
67
66
  "ofetch": "^2.0.0-alpha.3",
68
67
  "ohash": "^2.0.11",
69
68
  "oxc-minify": "^0.101.0",
@@ -129,6 +128,7 @@
129
128
  "mime": "^4.1.0",
130
129
  "miniflare": "^4.20251128.0",
131
130
  "mlly": "^1.8.0",
131
+ "nf3": "^0.1.12",
132
132
  "nypm": "^0.6.2",
133
133
  "obuild": "^0.4.4",
134
134
  "pathe": "^2.0.3",
@@ -156,7 +156,7 @@
156
156
  "unctx": "^2.4.1",
157
157
  "unimport": "^5.5.0",
158
158
  "untyped": "^2.0.0",
159
- "unwasm": "^0.5.1",
159
+ "unwasm": "^0.5.2",
160
160
  "vitest": "^4.0.15",
161
161
  "wrangler": "^4.51.0",
162
162
  "xml2js": "^0.6.2",
@@ -164,12 +164,16 @@
164
164
  "youch-core": "^0.3.3"
165
165
  },
166
166
  "peerDependencies": {
167
+ "nf3": ">=0.2",
167
168
  "rolldown": "*",
168
169
  "rollup": "^4",
169
170
  "vite": "^7",
170
171
  "xml2js": "^0.6.2"
171
172
  },
172
173
  "peerDependenciesMeta": {
174
+ "nf3": {
175
+ "optional": true
176
+ },
173
177
  "rolldown": {
174
178
  "optional": true
175
179
  },