nitro-nightly 3.0.1-20251210-210244-79340a52 → 3.0.1-20251210-212547-0efa6415

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.
package/dist/_presets.mjs CHANGED
@@ -5,7 +5,7 @@ import "./_libs/@rollup/plugin-commonjs.mjs";
5
5
  import { t as glob } from "./_libs/tinyglobby.mjs";
6
6
  import { r as resolveCompatibilityDatesFromEnv, t as formatCompatibilityDate } from "./_libs/compatx.mjs";
7
7
  import { i as a, n as K, o as p } from "./_libs/std-env.mjs";
8
- import { i as writeFile$2 } from "./_build/shared.mjs";
8
+ import { i as writeFile$2, n as prettyPath } from "./_build/shared.mjs";
9
9
  import { builtinModules } from "node:module";
10
10
  import consola$1 from "consola";
11
11
  import { dirname, extname, relative, resolve } from "node:path";
@@ -227,14 +227,14 @@ var preset_default$4 = [awsLambda];
227
227
 
228
228
  //#endregion
229
229
  //#region src/presets/_utils/fs.ts
230
- function prettyPath(p$1, highlight = true) {
230
+ function prettyPath$1(p$1, highlight = true) {
231
231
  p$1 = relative$1(process.cwd(), p$1);
232
232
  return highlight ? colors.cyan(p$1) : p$1;
233
233
  }
234
234
  async function writeFile$1(file, contents, log = false) {
235
235
  await fsp.mkdir(dirname$1(file), { recursive: true });
236
236
  await fsp.writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
237
- if (log) consola$1.info("Generated", prettyPath(file));
237
+ if (log) consola$1.info("Generated", prettyPath$1(file));
238
238
  }
239
239
 
240
240
  //#endregion
@@ -426,7 +426,7 @@ const builtnNodeModules$1 = [
426
426
 
427
427
  //#endregion
428
428
  //#region src/presets/cloudflare/unenv/preset.ts
429
- const unencCfNodeCompat = {
429
+ const unenvCfNodeCompat = {
430
430
  meta: { name: "nitro:cloudflare-node-compat" },
431
431
  external: builtnNodeModules$1,
432
432
  alias: { ...Object.fromEntries(builtnNodeModules$1.flatMap((m) => [[m, m], [m.replace("node:", ""), m]])) },
@@ -530,7 +530,7 @@ async function enableNodeCompat(nitro) {
530
530
  nitro.options.cloudflare ??= {};
531
531
  nitro.options.cloudflare.deployConfig ??= true;
532
532
  nitro.options.cloudflare.nodeCompat ??= true;
533
- if (nitro.options.cloudflare.nodeCompat) nitro.options.unenv.push(unencCfNodeCompat);
533
+ if (nitro.options.cloudflare.nodeCompat) nitro.options.unenv.push(unenvCfNodeCompat);
534
534
  }
535
535
  const extensionParsers = {
536
536
  ".json": h,
@@ -640,6 +640,36 @@ async function cloudflareDevModule(nitro) {
640
640
  }));
641
641
  }
642
642
 
643
+ //#endregion
644
+ //#region src/presets/cloudflare/entry-exports.ts
645
+ const RESOLVE_EXTENSIONS = [
646
+ ".ts",
647
+ ".js",
648
+ ".mts",
649
+ ".mjs"
650
+ ];
651
+ async function setupEntryExports(nitro) {
652
+ const exportsEntry = resolveExportsEntry(nitro);
653
+ if (!exportsEntry) return;
654
+ const originalEntry = nitro.options.entry;
655
+ const virtualEntryId = nitro.options.entry = "#nitro-internal-virtual/cloudflare-server-entry";
656
+ nitro.options.virtual[virtualEntryId] = `
657
+ export * from "${exportsEntry}";
658
+ export * from "${originalEntry}";
659
+ export { default } from "${originalEntry}";
660
+ `;
661
+ }
662
+ function resolveExportsEntry(nitro) {
663
+ const entry = resolveModulePath(nitro.options.cloudflare?.exports || "./exports.cloudflare.ts", {
664
+ from: nitro.options.rootDir,
665
+ extensions: RESOLVE_EXTENSIONS,
666
+ try: true
667
+ });
668
+ if (!entry && nitro.options.cloudflare?.exports) nitro.logger.warn(`Your custom Cloudflare entrypoint \`${prettyPath(nitro.options.cloudflare.exports)}\` file does not exist.`);
669
+ else if (entry && !nitro.options.cloudflare?.exports) nitro.logger.info(`Detected \`${prettyPath(entry)}\` as Cloudflare entrypoint.`);
670
+ return entry;
671
+ }
672
+
643
673
  //#endregion
644
674
  //#region src/presets/cloudflare/preset.ts
645
675
  const cloudflarePages = defineNitroPreset({
@@ -670,6 +700,7 @@ const cloudflarePages = defineNitroPreset({
670
700
  "build:before": async (nitro) => {
671
701
  nitro.options.unenv.push(unenvCfExternals);
672
702
  await enableNodeCompat(nitro);
703
+ await setupEntryExports(nitro);
673
704
  },
674
705
  async compiled(nitro) {
675
706
  await writeWranglerConfig(nitro, "pages");
@@ -737,6 +768,7 @@ const cloudflareModule = defineNitroPreset({
737
768
  "build:before": async (nitro) => {
738
769
  nitro.options.unenv.push(unenvCfExternals);
739
770
  await enableNodeCompat(nitro);
771
+ await setupEntryExports(nitro);
740
772
  },
741
773
  async compiled(nitro) {
742
774
  await writeWranglerConfig(nitro, "module");
@@ -1585,6 +1585,10 @@ interface CloudflareOptions {
1585
1585
  */
1586
1586
  defaultRoutes?: boolean;
1587
1587
  };
1588
+ /**
1589
+ * Custom Cloudflare exports additional classes such as WorkflowEntrypoint.
1590
+ */
1591
+ exports?: string;
1588
1592
  }
1589
1593
  type DurableObjectState = ConstructorParameters<typeof DurableObject>[0];
1590
1594
  declare module "nitro/types" {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251210-210244-79340a52",
3
+ "version": "3.0.1-20251210-212547-0efa6415",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",