nitro-nightly 3.0.1-20251110-110934-89e686f1 → 3.0.1-20251110-120029-c61042ad

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.
@@ -682,6 +682,55 @@ function sourcemapMinify() {
682
682
  };
683
683
  }
684
684
 
685
+ //#endregion
686
+ //#region src/build/plugins/raw.ts
687
+ const HELPER_ID = "\0raw-helpers";
688
+ function raw() {
689
+ return {
690
+ name: "raw",
691
+ async resolveId(id, importer, resolveOpts) {
692
+ if (id === HELPER_ID) return id;
693
+ if (!id.startsWith("raw:")) return;
694
+ return { id: "\0raw:" + (await this.resolve(id.slice(4), importer, resolveOpts))?.id };
695
+ },
696
+ load(id) {
697
+ if (id === HELPER_ID) return getHelpers();
698
+ if (id.startsWith("\0raw:")) return promises.readFile(id.slice(5), isBinary(id) ? "binary" : "utf8");
699
+ },
700
+ transform(code, id) {
701
+ if (!id.startsWith("\0raw:")) return;
702
+ if (isBinary(id)) return {
703
+ code: `// ROLLUP_NO_REPLACE \n import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
704
+ map: null
705
+ };
706
+ return {
707
+ code: `// ROLLUP_NO_REPLACE \n export default ${JSON.stringify(code)}`,
708
+ map: null,
709
+ moduleType: "js"
710
+ };
711
+ }
712
+ };
713
+ }
714
+ function isBinary(id) {
715
+ const idMime = src_default.getType(id) || "";
716
+ if (idMime.startsWith("text/")) return false;
717
+ if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
718
+ return true;
719
+ }
720
+ function getHelpers() {
721
+ return String.raw`
722
+ export function base64ToUint8Array(str) {
723
+ const data = atob(str);
724
+ const size = data.length;
725
+ const bytes = new Uint8Array(size);
726
+ for (let i = 0; i < size; i++) {
727
+ bytes[i] = data.charCodeAt(i);
728
+ }
729
+ return bytes;
730
+ }
731
+ `;
732
+ }
733
+
685
734
  //#endregion
686
735
  //#region src/build/plugins.ts
687
736
  function baseBuildPlugins(nitro, base) {
@@ -704,6 +753,7 @@ function baseBuildPlugins(nitro, base) {
704
753
  plugins.push(storage(nitro));
705
754
  plugins.push(database(nitro));
706
755
  plugins.push(routing(nitro));
756
+ plugins.push(raw());
707
757
  if (nitro.options.experimental.openAPI) plugins.push(routeMeta(nitro));
708
758
  plugins.push(errorHandler(nitro));
709
759
  plugins.push(virtual({ "#nitro-internal-pollyfills": base.env.polyfill.map((p) => `import '${p}';`).join("\n") || `/* No polyfills */` }, nitro.vfs, { moduleSideEffects: true }));
@@ -28,10 +28,10 @@ import { n as baseBuildConfig, r as replace, t as baseBuildPlugins } from "./com
28
28
  import "../_libs/remapping.mjs";
29
29
  import "../_libs/unwasm.mjs";
30
30
  import "../_libs/etag.mjs";
31
- import { n as raw, t as generateFSTree } from "../_chunks/DnxxnLj6.mjs";
32
31
  import "../_libs/duplexer.mjs";
33
32
  import "../_libs/gzip-size.mjs";
34
33
  import "../_libs/pretty-bytes.mjs";
34
+ import { t as generateFSTree } from "../_chunks/BX9-zVkM.mjs";
35
35
  import { builtinModules } from "node:module";
36
36
  import { watch } from "node:fs";
37
37
  import { defu } from "defu";
@@ -56,14 +56,10 @@ const getRolldownConfig = (nitro) => {
56
56
  ...builtinModules,
57
57
  ...builtinModules.map((m) => `node:${m}`)
58
58
  ],
59
- plugins: [
60
- ...baseBuildPlugins(nitro, base),
61
- replace({
62
- preventAssignment: true,
63
- values: base.replacements
64
- }),
65
- raw()
66
- ],
59
+ plugins: [...baseBuildPlugins(nitro, base), replace({
60
+ preventAssignment: true,
61
+ values: base.replacements
62
+ })],
67
63
  resolve: {
68
64
  alias: base.aliases,
69
65
  extensions: base.extensions,
@@ -30,10 +30,10 @@ import { n as baseBuildConfig, r as replace, t as baseBuildPlugins } from "./com
30
30
  import "../_libs/remapping.mjs";
31
31
  import "../_libs/unwasm.mjs";
32
32
  import "../_libs/etag.mjs";
33
- import { n as raw, t as generateFSTree } from "../_chunks/DnxxnLj6.mjs";
34
33
  import "../_libs/duplexer.mjs";
35
34
  import "../_libs/gzip-size.mjs";
36
35
  import "../_libs/pretty-bytes.mjs";
36
+ import { t as generateFSTree } from "../_chunks/BX9-zVkM.mjs";
37
37
  import "../_libs/commondir.mjs";
38
38
  import "../_libs/is-reference.mjs";
39
39
  import { t as json } from "../_libs/plugin-json.mjs";
@@ -124,8 +124,7 @@ const getRollupConfig = (nitro) => {
124
124
  }),
125
125
  commonjs({ ...nitro.options.commonJS }),
126
126
  json(),
127
- inject(base.env.inject),
128
- raw()
127
+ inject(base.env.inject)
129
128
  ],
130
129
  onwarn(warning, rollupWarn) {
131
130
  if (![
@@ -0,0 +1,59 @@
1
+ import { O as relative, k as resolve, x as dirname } from "../_libs/c12.mjs";
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 "./ANM1K1bE.mjs";
5
+ import { t as gzipSize } from "../_libs/gzip-size.mjs";
6
+ import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
7
+ import { promises } from "node:fs";
8
+ import { colors } from "consola/utils";
9
+
10
+ //#region src/utils/fs-tree.ts
11
+ async function generateFSTree(dir, options = {}) {
12
+ if (a) return;
13
+ const files = await glob("**/*.*", {
14
+ cwd: dir,
15
+ ignore: ["*.map"]
16
+ });
17
+ const items = [];
18
+ await runParallel(new Set(files), async (file) => {
19
+ const path = resolve(dir, file);
20
+ const src = await promises.readFile(path);
21
+ const size = src.byteLength;
22
+ const gzip = options.compressedSizes ? await gzipSize(src) : 0;
23
+ items.push({
24
+ file,
25
+ path,
26
+ size,
27
+ gzip
28
+ });
29
+ }, { concurrency: 10 });
30
+ items.sort((a$1, b) => a$1.path.localeCompare(b.path));
31
+ let totalSize = 0;
32
+ let totalGzip = 0;
33
+ let totalNodeModulesSize = 0;
34
+ let totalNodeModulesGzip = 0;
35
+ let treeText = "";
36
+ for (const [index, item] of items.entries()) {
37
+ let dir$1 = dirname(item.file);
38
+ if (dir$1 === ".") dir$1 = "";
39
+ const rpath = relative(process.cwd(), item.path);
40
+ const treeChar = index === items.length - 1 ? "└─" : "├─";
41
+ if (item.file.includes("node_modules")) {
42
+ totalNodeModulesSize += item.size;
43
+ totalNodeModulesGzip += item.gzip;
44
+ continue;
45
+ }
46
+ treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
47
+ if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
48
+ treeText += "\n";
49
+ totalSize += item.size;
50
+ totalGzip += item.gzip;
51
+ }
52
+ treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
53
+ if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
54
+ treeText += "\n";
55
+ return treeText;
56
+ }
57
+
58
+ //#endregion
59
+ export { generateFSTree as t };
package/dist/_presets.mjs CHANGED
@@ -576,19 +576,14 @@ async function writeWranglerConfig(nitro, cfTarget) {
576
576
  wranglerConfig.name = await generateWorkerName(nitro);
577
577
  nitro.logger.info(`Using auto generated worker name: \`${wranglerConfig.name}\``);
578
578
  }
579
- const compatFlags = new Set(wranglerConfig.compatibility_flags || []);
580
- if (nitro.options.cloudflare?.nodeCompat) {
581
- if (compatFlags.has("nodejs_compat_v2") && compatFlags.has("no_nodejs_compat_v2")) {
582
- nitro.logger.warn("[cloudflare] Wrangler config `compatibility_flags` contains both `nodejs_compat_v2` and `no_nodejs_compat_v2`. Ignoring `nodejs_compat_v2`.");
583
- compatFlags.delete("nodejs_compat_v2");
584
- }
585
- if (compatFlags.has("nodejs_compat_v2")) nitro.logger.warn("[cloudflare] Please consider replacing `nodejs_compat_v2` with `nodejs_compat` in your `compatibility_flags` or USE IT AT YOUR OWN RISK as it can cause issues with nitro.");
586
- else {
587
- compatFlags.add("nodejs_compat");
588
- compatFlags.add("no_nodejs_compat_v2");
589
- }
590
- }
591
- wranglerConfig.compatibility_flags = [...compatFlags];
579
+ wranglerConfig.compatibility_flags ??= [];
580
+ if (nitro.options.cloudflare?.nodeCompat && !wranglerConfig.compatibility_flags.includes("nodejs_compat")) wranglerConfig.compatibility_flags.push("nodejs_compat");
581
+ if (wranglerConfig.no_bundle === void 0) wranglerConfig.no_bundle = true;
582
+ wranglerConfig.rules ??= [];
583
+ if (!wranglerConfig.rules.some((rule) => rule.type === "ESModule")) wranglerConfig.rules.push({
584
+ type: "ESModule",
585
+ globs: ["**/*.mjs", "**/*.js"]
586
+ });
592
587
  await writeFile$1(wranglerConfigPath, JSON.stringify(wranglerConfig, null, 2), true);
593
588
  const configPath = join$1(nitro.options.rootDir, ".wrangler/deploy/config.json");
594
589
  await writeFile$1(configPath, JSON.stringify({ configPath: relative(dirname(configPath), wranglerConfigPath) }), true);
@@ -1,9 +1,10 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import packageJson from "../../package.json" with { type: "json" };
3
3
  export const version = packageJson.version;
4
- export const pkgDir = fileURLToPath(new URL("../../", import.meta.url));
5
- export const runtimeDir = fileURLToPath(new URL("./", import.meta.url));
6
- export const presetsDir = fileURLToPath(new URL("../presets/", import.meta.url));
4
+ const resolve = (path) => fileURLToPath(new URL(path, import.meta.url));
5
+ export const pkgDir = /* @__PURE__ */ resolve("../../");
6
+ export const runtimeDir = /* @__PURE__ */ resolve("./");
7
+ export const presetsDir = /* @__PURE__ */ resolve("../presets/");
7
8
  export const runtimeDependencies = [
8
9
  "crossws",
9
10
  "croner",
@@ -2709,9 +2709,6 @@ interface ServerAssetOptions {
2709
2709
  };
2710
2710
  };
2711
2711
  }
2712
- interface RawOptions {
2713
- extensions?: string[];
2714
- }
2715
2712
  //#endregion
2716
2713
  //#region src/types/hooks.d.ts
2717
2714
  type HookResult = void | Promise<void>;
@@ -3143,4 +3140,4 @@ declare module "srvx" {
3143
3140
  }
3144
3141
  }
3145
3142
  //#endregion
3146
- export { $Fetch, AssetMeta, AvailableRouterMethod, Base$Fetch, CacheEntry, CacheOptions, CachedEventHandlerOptions, CaptureError, CapturedErrorContext, CompressOptions, DatabaseConnectionConfig, DatabaseConnectionConfigs, DatabaseConnectionName, DevMessageListener, DevRPCHooks, DevWorker, EventHandlerFormat, ExtractedRouteMethod, FetchHandler, H3Event$Fetch, H3EventFetch, HTTPstatus, InternalApi, LoadConfigOptions, MatchedRouteRule, MatchedRouteRules, MatchedRoutes, MiddlewareOf, Nitro, NitroApp, NitroAppPlugin, NitroAsyncContext, NitroBuildInfo, NitroConfig, NitroDevEventHandler, NitroDevServerOptions, NitroDynamicConfig, NitroErrorHandler, NitroEventHandler, NitroFetchOptions, NitroFetchRequest, NitroFrameworkInfo, NitroHooks, NitroModule, NitroModuleInput, type NitroOpenAPIConfig, NitroOptions, NitroPreset, NitroPresetMeta, NitroRouteConfig, NitroRouteMeta, NitroRouteRules, NitroRuntimeConfig, NitroRuntimeConfigApp, NitroRuntimeHooks, NitroStaticBuildFlags, NitroTypes, type NodeExternalsOptions, OXCOptions, PrerenderGenerateRoute, PrerenderRoute, PublicAsset, PublicAssetDir, RawOptions, RenderContext, RenderHandler, RenderResponse, ResponseCacheEntry, RollupConfig, RollupVirtualOptions, Serialize, SerializeObject, SerializeTuple, ServerAssetDir, ServerAssetOptions, Simplify, StorageMounts, Task, TaskContext, TaskEvent, TaskMeta, TaskPayload, TaskResult, TaskRunnerOptions, TypedInternalResponse, UpgradeHandler, VirtualModule, WorkerAddress, WorkerHooks };
3143
+ export { $Fetch, AssetMeta, AvailableRouterMethod, Base$Fetch, CacheEntry, CacheOptions, CachedEventHandlerOptions, CaptureError, CapturedErrorContext, CompressOptions, DatabaseConnectionConfig, DatabaseConnectionConfigs, DatabaseConnectionName, DevMessageListener, DevRPCHooks, DevWorker, EventHandlerFormat, ExtractedRouteMethod, FetchHandler, H3Event$Fetch, H3EventFetch, HTTPstatus, InternalApi, LoadConfigOptions, MatchedRouteRule, MatchedRouteRules, MatchedRoutes, MiddlewareOf, Nitro, NitroApp, NitroAppPlugin, NitroAsyncContext, NitroBuildInfo, NitroConfig, NitroDevEventHandler, NitroDevServerOptions, NitroDynamicConfig, NitroErrorHandler, NitroEventHandler, NitroFetchOptions, NitroFetchRequest, NitroFrameworkInfo, NitroHooks, NitroModule, NitroModuleInput, type NitroOpenAPIConfig, NitroOptions, NitroPreset, NitroPresetMeta, NitroRouteConfig, NitroRouteMeta, NitroRouteRules, NitroRuntimeConfig, NitroRuntimeConfigApp, NitroRuntimeHooks, NitroStaticBuildFlags, NitroTypes, type NodeExternalsOptions, OXCOptions, PrerenderGenerateRoute, PrerenderRoute, PublicAsset, PublicAssetDir, RenderContext, RenderHandler, RenderResponse, ResponseCacheEntry, RollupConfig, RollupVirtualOptions, Serialize, SerializeObject, SerializeTuple, ServerAssetDir, ServerAssetOptions, Simplify, StorageMounts, Task, TaskContext, TaskEvent, TaskMeta, TaskPayload, TaskResult, TaskRunnerOptions, TypedInternalResponse, UpgradeHandler, VirtualModule, WorkerAddress, WorkerHooks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20251110-110934-89e686f1",
3
+ "version": "3.0.1-20251110-120029-c61042ad",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -1,125 +0,0 @@
1
- import { O as relative, S as extname, k as resolve, x as dirname } from "../_libs/c12.mjs";
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 "./ANM1K1bE.mjs";
5
- import { t as src_default } from "../_libs/mime.mjs";
6
- import { t as gzipSize } from "../_libs/gzip-size.mjs";
7
- import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
8
- import { promises } from "node:fs";
9
- import { colors } from "consola/utils";
10
-
11
- //#region src/build/plugins/raw.ts
12
- const HELPER_ID = "\0raw-helpers";
13
- function raw(opts = {}) {
14
- const extensions = new Set([
15
- ".md",
16
- ".mdx",
17
- ".txt",
18
- ".css",
19
- ".htm",
20
- ".html",
21
- ".sql",
22
- ...opts.extensions || []
23
- ]);
24
- return {
25
- name: "raw",
26
- async resolveId(id, importer, resolveOpts) {
27
- if (id === HELPER_ID) return id;
28
- if (id[0] === "\0") return;
29
- const withRawSpecifier = id.startsWith("raw:");
30
- if (withRawSpecifier) id = id.slice(4);
31
- if (!withRawSpecifier && !extensions.has(extname(id))) return;
32
- const resolvedId = (await this.resolve(id, importer, resolveOpts))?.id;
33
- if (!resolvedId || resolvedId.startsWith("\0")) return resolvedId;
34
- if (!withRawSpecifier && !extensions.has(extname(resolvedId))) return;
35
- return { id: "\0raw:" + resolvedId };
36
- },
37
- load(id) {
38
- if (id === HELPER_ID) return getHelpers();
39
- if (id.startsWith("\0raw:")) return promises.readFile(id.slice(5), isBinary(id) ? "binary" : "utf8");
40
- },
41
- transform(code, id) {
42
- if (!id.startsWith("\0raw:")) return;
43
- if (isBinary(id)) return {
44
- code: `// ROLLUP_NO_REPLACE \n import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
45
- map: null
46
- };
47
- return {
48
- code: `// ROLLUP_NO_REPLACE \n export default ${JSON.stringify(code)}`,
49
- map: null,
50
- moduleType: "js"
51
- };
52
- }
53
- };
54
- }
55
- function isBinary(id) {
56
- const idMime = src_default.getType(id) || "";
57
- if (idMime.startsWith("text/")) return false;
58
- if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
59
- return true;
60
- }
61
- function getHelpers() {
62
- return String.raw`
63
- export function base64ToUint8Array(str) {
64
- const data = atob(str);
65
- const size = data.length;
66
- const bytes = new Uint8Array(size);
67
- for (let i = 0; i < size; i++) {
68
- bytes[i] = data.charCodeAt(i);
69
- }
70
- return bytes;
71
- }
72
- `;
73
- }
74
-
75
- //#endregion
76
- //#region src/utils/fs-tree.ts
77
- async function generateFSTree(dir, options = {}) {
78
- if (a) return;
79
- const files = await glob("**/*.*", {
80
- cwd: dir,
81
- ignore: ["*.map"]
82
- });
83
- const items = [];
84
- await runParallel(new Set(files), async (file) => {
85
- const path = resolve(dir, file);
86
- const src = await promises.readFile(path);
87
- const size = src.byteLength;
88
- const gzip = options.compressedSizes ? await gzipSize(src) : 0;
89
- items.push({
90
- file,
91
- path,
92
- size,
93
- gzip
94
- });
95
- }, { concurrency: 10 });
96
- items.sort((a$1, b) => a$1.path.localeCompare(b.path));
97
- let totalSize = 0;
98
- let totalGzip = 0;
99
- let totalNodeModulesSize = 0;
100
- let totalNodeModulesGzip = 0;
101
- let treeText = "";
102
- for (const [index, item] of items.entries()) {
103
- let dir$1 = dirname(item.file);
104
- if (dir$1 === ".") dir$1 = "";
105
- const rpath = relative(process.cwd(), item.path);
106
- const treeChar = index === items.length - 1 ? "└─" : "├─";
107
- if (item.file.includes("node_modules")) {
108
- totalNodeModulesSize += item.size;
109
- totalNodeModulesGzip += item.gzip;
110
- continue;
111
- }
112
- treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
113
- if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
114
- treeText += "\n";
115
- totalSize += item.size;
116
- totalGzip += item.gzip;
117
- }
118
- treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
119
- if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
120
- treeText += "\n";
121
- return treeText;
122
- }
123
-
124
- //#endregion
125
- export { raw as n, generateFSTree as t };