nitro-nightly 3.0.1-20251212-103723-5f37156f → 3.0.1-20251212-124050-0939a38d

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.
@@ -53,11 +53,10 @@ const getRolldownConfig = (nitro) => {
53
53
  }
54
54
  },
55
55
  onwarn(warning, warn) {
56
- if (![
57
- "CIRCULAR_DEPENDENCY",
58
- "EVAL",
59
- "EMPTY_CHUNK"
60
- ].includes(warning.code || "") && !warning.message.includes("Unsupported source map comment")) warn(warning);
56
+ if (!base.ignoreWarningCodes.has(warning.code || "")) {
57
+ console.log(warning.code);
58
+ warn(warning);
59
+ }
61
60
  },
62
61
  treeshake: { moduleSideEffects(id) {
63
62
  return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
@@ -91,12 +91,7 @@ const getRollupConfig = (nitro) => {
91
91
  inject(base.env.inject)
92
92
  ],
93
93
  onwarn(warning, rollupWarn) {
94
- if (![
95
- "EVAL",
96
- "CIRCULAR_DEPENDENCY",
97
- "THIS_IS_UNDEFINED",
98
- "EMPTY_CHUNK"
99
- ].includes(warning.code || "") && !warning.message.includes("Unsupported source map comment")) rollupWarn(warning);
94
+ if (!base.ignoreWarningCodes.has(warning.code || "")) rollupWarn(warning);
100
95
  },
101
96
  treeshake: { moduleSideEffects(id) {
102
97
  return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
@@ -79,7 +79,13 @@ function baseBuildConfig(nitro) {
79
79
  replacements,
80
80
  env,
81
81
  aliases: resolveAliases({ ...env.alias }),
82
- noExternal: getNoExternals(nitro)
82
+ noExternal: getNoExternals(nitro),
83
+ ignoreWarningCodes: new Set([
84
+ "EVAL",
85
+ "CIRCULAR_DEPENDENCY",
86
+ "THIS_IS_UNDEFINED",
87
+ "EMPTY_BUNDLE"
88
+ ])
83
89
  };
84
90
  }
85
91
  function getNoExternals(nitro) {
@@ -39,6 +39,9 @@ const getViteRollupConfig = (ctx) => {
39
39
  treeshake: { moduleSideEffects(id) {
40
40
  return nitro$1.options.moduleSideEffects.some((p) => id.startsWith(p));
41
41
  } },
42
+ onwarn(warning, warn) {
43
+ if (!base.ignoreWarningCodes.has(warning.code || "")) warn(warning);
44
+ },
42
45
  output: {
43
46
  format: "esm",
44
47
  entryFileNames: "index.mjs",
@@ -3,10 +3,10 @@ import type { ServerRequest, ServerRequestContext } from "srvx";
3
3
  import type { H3EventContext, Middleware, WebSocketHooks } from "h3";
4
4
  import { HookableCore } from "hookable";
5
5
  declare global {
6
- var __nitro__: NitroApp | undefined;
6
+ var __nitro__: Partial<Record<"default" | "prerender" | (string & {}), NitroApp | undefined>> | undefined;
7
7
  }
8
- export declare function useNitroApp(): NitroApp;
9
- export declare function useNitroHooks(): HookableCore<NitroRuntimeHooks>;
8
+ export declare function useNitroApp(_id?): NitroApp;
9
+ export declare function useNitroHooks(_id?): HookableCore<NitroRuntimeHooks>;
10
10
  export declare function serverFetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
11
11
  export declare function resolveWebsocketHooks(req: ServerRequest): Promise<Partial<WebSocketHooks>>;
12
12
  export declare function fetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
@@ -6,11 +6,21 @@ import errorHandler from "#nitro/virtual/error-handler";
6
6
  import { plugins } from "#nitro/virtual/plugins";
7
7
  import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro/virtual/routing";
8
8
  import { hasRouteRules, hasRoutedMiddleware, hasGlobalMiddleware, hasRoutes, hasHooks, hasPlugins } from "#nitro/virtual/feature-flags";
9
- export function useNitroApp() {
10
- return useNitroApp.__instance__ ??= initNitroApp();
9
+ const APP_ID = import.meta.prerender ? "prerender" : "default";
10
+ export function useNitroApp(_id = APP_ID) {
11
+ let instance = globalThis.__nitro__?.[_id];
12
+ if (instance) {
13
+ return instance;
14
+ }
15
+ globalThis.__nitro__ ??= {};
16
+ instance = globalThis.__nitro__[_id] = createNitroApp();
17
+ if (hasPlugins) {
18
+ initNitroPlugins(instance);
19
+ }
20
+ return instance;
11
21
  }
12
- export function useNitroHooks() {
13
- const nitroApp = useNitroApp();
22
+ export function useNitroHooks(_id = APP_ID) {
23
+ const nitroApp = useNitroApp(_id);
14
24
  const hooks = nitroApp.hooks;
15
25
  if (hooks) {
16
26
  return hooks;
@@ -42,21 +52,6 @@ export function fetch(resource, init, context) {
42
52
  resource = resource._request || resource;
43
53
  return fetch(resource, init);
44
54
  }
45
- function initNitroApp() {
46
- const nitroApp = createNitroApp();
47
- if (hasPlugins) {
48
- for (const plugin of plugins) {
49
- try {
50
- plugin(nitroApp);
51
- } catch (error) {
52
- nitroApp.captureError?.(error, { tags: ["plugin"] });
53
- throw error;
54
- }
55
- }
56
- }
57
- globalThis.__nitro__ = nitroApp;
58
- return nitroApp;
59
- }
60
55
  function createNitroApp() {
61
56
  const hooks = hasHooks ? new HookableCore() : undefined;
62
57
  const captureError = (error, errorCtx) => {
@@ -119,6 +114,17 @@ function createNitroApp() {
119
114
  };
120
115
  return app;
121
116
  }
117
+ function initNitroPlugins(app) {
118
+ for (const plugin of plugins) {
119
+ try {
120
+ plugin(app);
121
+ } catch (error) {
122
+ app.captureError?.(error, { tags: ["plugin"] });
123
+ throw error;
124
+ }
125
+ }
126
+ return app;
127
+ }
122
128
  function createH3App(config) {
123
129
  // Create H3 app
124
130
  const h3App = new H3Core(config);
@@ -8,7 +8,7 @@ export { defineRouteMeta } from "./internal/meta.mjs";
8
8
  export { defineNitroErrorHandler as defineErrorHandler } from "./internal/error/utils.mjs";
9
9
  // Runtime
10
10
  export function serverFetch(resource, init, context) {
11
- const nitro = globalThis.__nitro__ || globalThis.__nitro_builder__;
11
+ const nitro = globalThis.__nitro__?.default || globalThis.__nitro__?.prerender || globalThis.__nitro_builder__;
12
12
  if (!nitro) {
13
13
  return Promise.reject(new Error("Nitro instance is not available."));
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251212-103723-5f37156f",
3
+ "version": "3.0.1-20251212-124050-0939a38d",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "resolutions": {
60
60
  "nitro": "link:.",
61
- "undici": "^7.11.0"
61
+ "undici": "^7.16.0"
62
62
  },
63
63
  "dependencies": {
64
64
  "consola": "^3.4.2",
@@ -78,7 +78,7 @@
78
78
  "devDependencies": {
79
79
  "@azure/functions": "^3.5.1",
80
80
  "@azure/static-web-apps-cli": "^2.0.7",
81
- "@cloudflare/workers-types": "^4.20251210.0",
81
+ "@cloudflare/workers-types": "^4.20251212.0",
82
82
  "@deno/types": "^0.0.1",
83
83
  "@hiogawa/vite-plugin-fullstack": "npm:@pi0/vite-plugin-fullstack@0.0.5-pr-1297",
84
84
  "@netlify/edge-functions": "^3.0.3",
@@ -89,7 +89,7 @@
89
89
  "@rollup/plugin-json": "^6.1.0",
90
90
  "@rollup/plugin-node-resolve": "^16.0.3",
91
91
  "@rollup/plugin-replace": "^6.0.3",
92
- "@scalar/api-reference": "^1.40.3",
92
+ "@scalar/api-reference": "^1.40.5",
93
93
  "@types/aws-lambda": "^8.10.159",
94
94
  "@types/estree": "^1.0.8",
95
95
  "@types/etag": "^1.8.4",
@@ -129,7 +129,7 @@
129
129
  "knitwork": "^1.3.0",
130
130
  "magic-string": "^0.30.21",
131
131
  "mime": "^4.1.0",
132
- "miniflare": "^4.20251202.1",
132
+ "miniflare": "^4.20251210.0",
133
133
  "mlly": "^1.8.0",
134
134
  "nf3": "^0.3.1",
135
135
  "nypm": "^0.6.2",
@@ -139,10 +139,10 @@
139
139
  "pkg-types": "^2.3.0",
140
140
  "prettier": "^3.7.4",
141
141
  "pretty-bytes": "^7.1.0",
142
- "react": "^19.2.0",
142
+ "react": "^19.2.3",
143
143
  "rendu": "^0.0.7",
144
144
  "rolldown": "1.0.0-beta.54",
145
- "rolldown-vite": "^7.2.10",
145
+ "rolldown-vite": "^7.2.11",
146
146
  "rollup": "^4.53.3",
147
147
  "rou3": "^0.7.11",
148
148
  "scule": "^1.3.0",
@@ -161,16 +161,16 @@
161
161
  "untyped": "^2.0.0",
162
162
  "unwasm": "^0.5.2",
163
163
  "vitest": "^4.0.15",
164
- "wrangler": "^4.53.0",
164
+ "wrangler": "^4.54.0",
165
165
  "xml2js": "^0.6.2",
166
166
  "youch": "4.1.0-beta.13",
167
167
  "youch-core": "^0.3.3"
168
168
  },
169
169
  "peerDependencies": {
170
- "nf3": ">=0.2",
170
+ "nf3": ">=0.3.1",
171
171
  "rolldown": "*",
172
- "rollup": "^4",
173
- "vite": "^7",
172
+ "rollup": "^4.53.3",
173
+ "vite": "^7.2.7",
174
174
  "xml2js": "^0.6.2"
175
175
  },
176
176
  "peerDependenciesMeta": {
@@ -190,7 +190,7 @@
190
190
  "optional": true
191
191
  }
192
192
  },
193
- "packageManager": "pnpm@10.22.0",
193
+ "packageManager": "pnpm@10.25.0",
194
194
  "engines": {
195
195
  "node": "^20.19.0 || >=22.12.0"
196
196
  }