nitro-nightly 3.0.1-20251106-140827-5d57690c → 3.0.1-20251106-143644-01cf2a01

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.
@@ -52,7 +52,7 @@ const getViteRollupConfig = (ctx) => {
52
52
  input: nitro$1.options.entry,
53
53
  external: [...base.env.external],
54
54
  plugins: [
55
- ctx.pluginConfig.experimental?.virtualBundle && virtualBundlePlugin(ctx._serviceBundles),
55
+ ctx.pluginConfig.experimental?.vite?.virtualBundle && virtualBundlePlugin(ctx._serviceBundles),
56
56
  ...baseBuildPlugins(nitro$1, base),
57
57
  alias({ entries: base.aliases }),
58
58
  replace({
@@ -193,7 +193,6 @@ async function buildEnvironments(ctx, builder) {
193
193
  if (nitro$1.options.commands.deploy) nitro$1.logger.success(`You can deploy this build using \`${rewriteRelativePaths(nitro$1.options.commands.deploy)}\``);
194
194
  }
195
195
  function prodSetup(ctx) {
196
- const services = ctx.pluginConfig.services || {};
197
196
  return `
198
197
  function lazyService(loader) {
199
198
  let promise, mod
@@ -209,9 +208,9 @@ function lazyService(loader) {
209
208
  }
210
209
 
211
210
  const services = {
212
- ${Object.keys(services).map((name) => {
211
+ ${Object.keys(ctx.services).map((name) => {
213
212
  let entry;
214
- if (ctx.pluginConfig.experimental?.virtualBundle) entry = ctx._entryPoints[name];
213
+ if (ctx.pluginConfig.experimental?.vite?.virtualBundle) entry = ctx._entryPoints[name];
215
214
  else entry = resolve$1(ctx.nitro.options.buildDir, "vite/services", name, ctx._entryPoints[name]);
216
215
  return [name, entry];
217
216
  }).map(([name, entry]) => `[${JSON.stringify(name)}]: lazyService(() => import(${JSON.stringify(entry)}))`).join(",\n")}
@@ -407,7 +406,7 @@ function createServiceEnvironment(ctx, name, serviceConfig) {
407
406
  };
408
407
  }
409
408
  function createServiceEnvironments(ctx) {
410
- return Object.fromEntries(Object.entries(ctx.pluginConfig.services || {}).map(([name, config]) => [name, createServiceEnvironment(ctx, name, config)]));
409
+ return Object.fromEntries(Object.entries(ctx.services).map(([name, config]) => [name, createServiceEnvironment(ctx, name, config)]));
411
410
  }
412
411
  function tryResolve(id) {
413
412
  if (/^[~#/\0]/.test(id) || isAbsolute$1(id)) return id;
@@ -529,7 +528,7 @@ function nitro(pluginConfig = {}) {
529
528
  nitroPrepare(ctx),
530
529
  nitroService(ctx),
531
530
  nitroPreviewPlugin(ctx),
532
- pluginConfig.experimental?.assetsImport !== false && assetsPlugin({ experimental: { clientBuildFallback: false } })
531
+ pluginConfig.experimental?.vite?.assetsImport !== false && assetsPlugin({ experimental: { clientBuildFallback: false } })
533
532
  ].filter(Boolean);
534
533
  }
535
534
  function nitroInit(ctx) {
@@ -576,7 +575,7 @@ function nitroEnv(ctx) {
576
575
  debug("[env] Configuring client environment", name === "client" ? "" : ` (${name})`);
577
576
  config.build.emptyOutDir = false;
578
577
  config.build.outDir = useNitro(ctx).options.output.publicDir;
579
- } else if (ctx.pluginConfig.experimental?.virtualBundle && name in (ctx.pluginConfig.services || {})) {
578
+ } else if (ctx.pluginConfig.experimental?.vite?.virtualBundle && name in (ctx.services || {})) {
580
579
  debug("[env] Configuring service environment for virtual:", name);
581
580
  config.build ??= {};
582
581
  config.build.write = config.build.write ?? false;
@@ -627,8 +626,7 @@ function nitroMain(ctx) {
627
626
  generateBundle: { handler(_options, bundle) {
628
627
  const environment = this.environment;
629
628
  debug("[main] Generating manifest and entry points for environment:", environment.name);
630
- const services = ctx.pluginConfig.services || {};
631
- const isRegisteredService = Object.keys(services).includes(environment.name);
629
+ const isRegisteredService = Object.keys(ctx.services).includes(environment.name);
632
630
  let entryFile;
633
631
  for (const [_name, file] of Object.entries(bundle)) if (file.type === "chunk" && isRegisteredService && file.isEntry) if (entryFile === void 0) entryFile = file.fileName;
634
632
  else this.warn(`Multiple entry points found for service "${environment.name}"`);
@@ -644,7 +642,7 @@ function nitroMain(ctx) {
644
642
  },
645
643
  async hotUpdate({ server, modules, timestamp }) {
646
644
  const env = this.environment;
647
- if (ctx.pluginConfig.experimental?.serverReload === false || env.config.consumer === "client") return;
645
+ if (ctx.pluginConfig.experimental?.vite.serverReload === false || env.config.consumer === "client") return;
648
646
  const clientEnvs = Object.values(server.environments).filter((env$1) => env$1.config.consumer === "client");
649
647
  let hasServerOnlyModule = false;
650
648
  const invalidated = /* @__PURE__ */ new Set();
@@ -695,6 +693,7 @@ function nitroService(ctx) {
695
693
  function createContext(pluginConfig) {
696
694
  return {
697
695
  pluginConfig,
696
+ services: {},
698
697
  _entryPoints: {},
699
698
  _serviceBundles: {}
700
699
  };
@@ -707,7 +706,7 @@ async function setupNitroContext(ctx, configEnv, userConfig) {
707
706
  const nitroConfig = {
708
707
  dev: configEnv.command === "serve",
709
708
  rootDir: userConfig.root,
710
- ...defu(ctx.pluginConfig.config, userConfig.nitro)
709
+ ...defu(ctx.pluginConfig, ctx.pluginConfig.config, userConfig.nitro)
711
710
  };
712
711
  nitroConfig.modules ??= [];
713
712
  for (const plugin of flattenPlugins(userConfig.plugins || [])) if (plugin.nitro) nitroConfig.modules.push(plugin.nitro);
@@ -715,36 +714,33 @@ async function setupNitroContext(ctx, configEnv, userConfig) {
715
714
  debug("[init] Using builder:", nitroConfig.builder);
716
715
  ctx.nitro = ctx.pluginConfig._nitro || await createNitro(nitroConfig);
717
716
  ctx.nitro.options.builder = ctx._isRolldown ? "rolldown-vite" : "vite";
718
- if (!ctx.pluginConfig.services?.ssr) {
719
- ctx.pluginConfig.services ??= {};
720
- if (userConfig.environments?.ssr === void 0) {
721
- const ssrEntry = resolveModulePath("./entry-server", {
722
- from: [
723
- "app",
724
- "src",
725
- ""
726
- ].flatMap((d) => [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs].map((s) => join$1(s, d) + "/")),
717
+ if (!ctx.services?.ssr) if (userConfig.environments?.ssr === void 0) {
718
+ const ssrEntry = resolveModulePath("./entry-server", {
719
+ from: [
720
+ "app",
721
+ "src",
722
+ ""
723
+ ].flatMap((d) => [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs].map((s) => join$1(s, d) + "/")),
724
+ extensions: DEFAULT_EXTENSIONS,
725
+ try: true
726
+ });
727
+ if (ssrEntry) {
728
+ ctx.services.ssr = { entry: ssrEntry };
729
+ ctx.nitro.logger.info(`Using \`${prettyPath(ssrEntry)}\` as vite ssr entry.`);
730
+ }
731
+ } else {
732
+ let ssrEntry = getEntry(userConfig.environments.ssr.build?.rollupOptions?.input);
733
+ if (typeof ssrEntry === "string") {
734
+ ssrEntry = resolveModulePath(ssrEntry, {
735
+ from: [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs],
727
736
  extensions: DEFAULT_EXTENSIONS,
737
+ suffixes: ["", "/index"],
728
738
  try: true
729
- });
730
- if (ssrEntry) {
731
- ctx.pluginConfig.services.ssr = { entry: ssrEntry };
732
- ctx.nitro.logger.info(`Using \`${prettyPath(ssrEntry)}\` as vite ssr entry.`);
733
- }
734
- } else {
735
- let ssrEntry = getEntry(userConfig.environments.ssr.build?.rollupOptions?.input);
736
- if (typeof ssrEntry === "string") {
737
- ssrEntry = resolveModulePath(ssrEntry, {
738
- from: [ctx.nitro.options.rootDir, ...ctx.nitro.options.scanDirs],
739
- extensions: DEFAULT_EXTENSIONS,
740
- suffixes: ["", "/index"],
741
- try: true
742
- }) || ssrEntry;
743
- ctx.pluginConfig.services.ssr = { entry: ssrEntry };
744
- }
739
+ }) || ssrEntry;
740
+ ctx.services.ssr = { entry: ssrEntry };
745
741
  }
746
742
  }
747
- if (!ctx.nitro.options.renderer?.entry && !ctx.nitro.options.renderer?.template && ctx.pluginConfig.services.ssr?.entry) {
743
+ if (!ctx.nitro.options.renderer?.entry && !ctx.nitro.options.renderer?.template && ctx.services.ssr?.entry) {
748
744
  ctx.nitro.options.renderer ??= {};
749
745
  ctx.nitro.options.renderer.entry = resolve$1(runtimeDir, "internal/vite/ssr-renderer");
750
746
  }
package/dist/_presets.mjs CHANGED
@@ -678,6 +678,7 @@ const cloudflarePages = defineNitroPreset({
678
678
  hooks: {
679
679
  "build:before": async (nitro) => {
680
680
  await enableNodeCompat(nitro);
681
+ if (nitro.options.builder?.includes("rolldown")) nitro.options.minify = false;
681
682
  },
682
683
  async compiled(nitro) {
683
684
  await writeWranglerConfig(nitro, "pages");
@@ -748,6 +749,7 @@ const cloudflareModule = defineNitroPreset({
748
749
  hooks: {
749
750
  "build:before": async (nitro) => {
750
751
  await enableNodeCompat(nitro);
752
+ if (nitro.options.builder?.includes("rolldown")) nitro.options.minify = false;
751
753
  },
752
754
  async compiled(nitro) {
753
755
  await writeWranglerConfig(nitro, "module");
package/dist/vite.d.mts CHANGED
@@ -21,59 +21,34 @@ declare module "rollup" {
21
21
  nitro?: NitroModule;
22
22
  }
23
23
  }
24
- interface NitroPluginConfig {
25
- /** Custom Nitro config */
26
- config?: NitroConfig;
24
+ interface NitroPluginConfig extends NitroConfig {
27
25
  /**
28
- * Fetchable service environments automatically created by the plugin.
29
- *
30
- * **Note:** You can use top level `environments` with same keys to extend environment configurations.
31
- */
32
- services?: Record<string, ServiceConfig>;
33
- /**
34
- * @internal Pre-initialized Nitro instance.
26
+ * @internal Use preinitialized Nitro instance for the plugin.
35
27
  */
36
28
  _nitro?: Nitro;
37
- experimental?: {
38
- /**
39
- * @experimental Use the virtual filesystem for intermediate environment build output files.
40
- * @note This is unsafe if plugins rely on temporary files on the filesystem.
41
- */
42
- virtualBundle?: boolean;
43
- /**
44
- * @experimental Enable `?assets` import proposed by https://github.com/vitejs/vite/discussions/20913
45
- * @default true
46
- */
47
- assetsImport?: boolean;
48
- /**
49
- * Reload the page when a server module is updated.
50
- *
51
- * @default true
52
- */
53
- serverReload: boolean;
29
+ experimental?: NitroConfig["experimental"] & {
30
+ vite: {
31
+ /**
32
+ * @experimental Use the virtual filesystem for intermediate environment build output files.
33
+ * @note This is unsafe if plugins rely on temporary files on the filesystem.
34
+ */
35
+ virtualBundle?: boolean;
36
+ /**
37
+ * @experimental Enable `?assets` import proposed by https://github.com/vitejs/vite/discussions/20913
38
+ * @default true
39
+ */
40
+ assetsImport?: boolean;
41
+ /**
42
+ * Reload the page when a server module is updated.
43
+ *
44
+ * @default true
45
+ */
46
+ serverReload: boolean;
47
+ };
54
48
  };
55
49
  }
56
50
  interface ServiceConfig {
57
- /**
58
- * Path to the service entrypoint file.
59
- *
60
- * Services should export a web standard fetch handler function.
61
- *
62
- * Example:
63
- * ```ts
64
- * export default async (req: Request) => {
65
- * return Response.json({ message: "Hello from service!" });
66
- * };
67
- * ```
68
- */
69
51
  entry: string;
70
- /**
71
- * Service route.
72
- *
73
- * - If `route` is not set, services are only accessible via `fetch("<url>", { viteEnv: "<name>" })`.
74
- * - `ssr` service is special and defaults to `"/**"` route, meaning it will handle all requests.
75
- */
76
- route?: string;
77
52
  }
78
53
  //#endregion
79
54
  //#region src/build/vite/plugin.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251106-140827-5d57690c",
3
+ "version": "3.0.1-20251106-143644-01cf2a01",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",