nitro-nightly 3.0.1-20251116-171456-64898bbc → 3.0.1-20251116-223140-b9920d49

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.
@@ -13,7 +13,7 @@ import "../_libs/tinyglobby.mjs";
13
13
  import "../_libs/compatx.mjs";
14
14
  import "../_libs/klona.mjs";
15
15
  import { r as a } from "../_libs/std-env.mjs";
16
- import "../_chunks/Clc3YR4F.mjs";
16
+ import "../_chunks/QnObqKaP.mjs";
17
17
  import "../_libs/escape-string-regexp.mjs";
18
18
  import "../_libs/tsconfck.mjs";
19
19
  import "../_libs/dot-prop.mjs";
@@ -2,7 +2,7 @@ import { C as isAbsolute$1, O as relative$1, b as basename$1, h as resolveModule
2
2
  import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
3
3
  import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
4
4
  import { n as T, r as a } from "../_libs/std-env.mjs";
5
- import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/Clc3YR4F.mjs";
5
+ import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/QnObqKaP.mjs";
6
6
  import { n as prettyPath } from "../_chunks/DJvLZH4H.mjs";
7
7
  import { i as scanHandlers } from "../_chunks/XHOrB-Xs.mjs";
8
8
  import { n as writeBuildInfo, t as getBuildInfo } from "./common.mjs";
@@ -329,18 +329,25 @@ async function resolvePathOptions(options) {
329
329
  h.handler = resolveNitroPath(h.handler, options);
330
330
  return [route, h];
331
331
  }));
332
- if (!options.routes["/**"] && !options.handlers.some((h) => h.route === "/**")) {
333
- const serverEntry = resolveModulePath("./server", {
334
- from: [options.rootDir, ...options.scanDirs],
335
- extensions: RESOLVE_EXTENSIONS,
336
- try: true
337
- });
338
- if (serverEntry) {
339
- if (!(options.handlers.some((h) => h.handler === serverEntry) || Object.values(options.routes).some((r) => r.handler === serverEntry))) {
340
- options.routes["/**"] = { handler: serverEntry };
341
- consola$1.info(`Using \`${prettyPath(serverEntry)}\` as default route handler.`);
332
+ if (options.serverEntry !== false) {
333
+ if (typeof options?.serverEntry === "string") options.serverEntry = { handler: options.serverEntry };
334
+ if (options.serverEntry?.handler) options.serverEntry.handler = resolveNitroPath(options.serverEntry.handler, options);
335
+ else {
336
+ const detected = resolveModulePath("./server", {
337
+ try: true,
338
+ from: options.rootDir,
339
+ extensions: RESOLVE_EXTENSIONS.flatMap((ext) => [ext, `.node${ext}`])
340
+ });
341
+ if (detected) {
342
+ options.serverEntry ??= { handler: "" };
343
+ options.serverEntry.handler = detected;
344
+ consola$1.info(`Detected \`${prettyPath(detected)}\` as server entry.`);
342
345
  }
343
346
  }
347
+ if (options.serverEntry?.handler && !options.serverEntry?.format) {
348
+ const isNode = /\.(node)\.\w+$/.test(options.serverEntry.handler);
349
+ options.serverEntry.format = isNode ? "node" : "web";
350
+ }
344
351
  }
345
352
  if (options.renderer?.handler) options.renderer.handler = resolveModulePath(resolveNitroPath(options.renderer?.handler, options), {
346
353
  from: [options.rootDir, ...options.scanDirs],
@@ -804,6 +811,12 @@ function initNitroRouting(nitro) {
804
811
  ...nitro.options.handlers,
805
812
  ...nitro.scannedHandlers
806
813
  ].filter((h) => h && !h.middleware && matchesEnv(h));
814
+ if (nitro.options.serverEntry && nitro.options.serverEntry.handler) _routes.push({
815
+ route: "/**",
816
+ lazy: false,
817
+ format: nitro.options.serverEntry.format,
818
+ handler: nitro.options.serverEntry.handler
819
+ });
807
820
  if (nitro.options.renderer?.handler) _routes.push({
808
821
  route: "/**",
809
822
  lazy: true,
package/dist/builder.mjs CHANGED
@@ -13,7 +13,7 @@ import "./_libs/tinyglobby.mjs";
13
13
  import "./_libs/compatx.mjs";
14
14
  import "./_libs/klona.mjs";
15
15
  import "./_libs/std-env.mjs";
16
- import { a as createNitro, c as loadOptions, i as build, n as prepare, o as listTasks, r as copyPublicAssets, s as runTask, t as prerender } from "./_chunks/Clc3YR4F.mjs";
16
+ import { a as createNitro, c as loadOptions, i as build, n as prepare, o as listTasks, r as copyPublicAssets, s as runTask, t as prerender } from "./_chunks/QnObqKaP.mjs";
17
17
  import "./_libs/escape-string-regexp.mjs";
18
18
  import "./_libs/tsconfck.mjs";
19
19
  import "./_libs/dot-prop.mjs";
@@ -2992,12 +2992,16 @@ interface NitroOptions extends PresetOptions {
2992
2992
  };
2993
2993
  baseURL: string;
2994
2994
  apiBaseURL: string;
2995
- routes: Record<string, string | Omit<NitroEventHandler, "route" | "middleware">>;
2995
+ serverEntry: false | {
2996
+ handler: string;
2997
+ format?: EventHandlerFormat;
2998
+ };
2996
2999
  handlers: NitroEventHandler[];
2997
3000
  devHandlers: NitroDevEventHandler[];
2998
3001
  routeRules: {
2999
3002
  [path: string]: NitroRouteRules;
3000
3003
  };
3004
+ routes: Record<string, string | Omit<NitroEventHandler, "route" | "middleware">>;
3001
3005
  errorHandler: string | string[];
3002
3006
  devErrorHandler: NitroErrorHandler;
3003
3007
  prerender: {
@@ -3072,7 +3076,7 @@ interface NitroOptions extends PresetOptions {
3072
3076
  /**
3073
3077
  * Nitro input config (nitro.config)
3074
3078
  */
3075
- interface NitroConfig extends DeepPartial<Omit<NitroOptions, "routeRules" | "rollupConfig" | "preset" | "compatibilityDate" | "unenv" | "serverDir" | "_config" | "_c12">>, C12InputConfig<NitroConfig> {
3079
+ interface NitroConfig extends DeepPartial<Omit<NitroOptions, "routeRules" | "rollupConfig" | "preset" | "compatibilityDate" | "unenv" | "serverDir" | "_config" | "_c12" | "serverEntry">>, C12InputConfig<NitroConfig> {
3076
3080
  preset?: PresetNameInput;
3077
3081
  extends?: string | string[] | NitroPreset;
3078
3082
  routeRules?: {
@@ -3082,6 +3086,7 @@ interface NitroConfig extends DeepPartial<Omit<NitroOptions, "routeRules" | "rol
3082
3086
  compatibilityDate?: CompatibilityDateSpec;
3083
3087
  unenv?: Preset | Preset[];
3084
3088
  serverDir?: boolean | "./" | "./server" | (string & {});
3089
+ serverEntry?: string | NitroOptions["serverEntry"];
3085
3090
  }
3086
3091
  interface LoadConfigOptions {
3087
3092
  watch?: boolean;
package/dist/vite.mjs CHANGED
@@ -13,7 +13,7 @@ import "./_libs/tinyglobby.mjs";
13
13
  import "./_libs/compatx.mjs";
14
14
  import "./_libs/klona.mjs";
15
15
  import "./_libs/std-env.mjs";
16
- import "./_chunks/Clc3YR4F.mjs";
16
+ import "./_chunks/QnObqKaP.mjs";
17
17
  import "./_libs/escape-string-regexp.mjs";
18
18
  import "./_libs/tsconfck.mjs";
19
19
  import "./_libs/dot-prop.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251116-171456-64898bbc",
3
+ "version": "3.0.1-20251116-223140-b9920d49",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",