nitropack-nightly 2.11.0-20250204-104845.ccf57266 → 2.11.0-20250205-112249.ccfda71c

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.
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250204-104845.ccf57266";
1
+ const version = "2.11.0-20250205-112249.ccfda71c";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250204-104845.ccf57266";
1
+ const version = "2.11.0-20250205-112249.ccfda71c";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250204-104845.ccf57266";
1
+ const version = "2.11.0-20250205-112249.ccfda71c";
2
2
 
3
3
  export { version };
@@ -0,0 +1,3 @@
1
+ export type { CloudflareOptions as PresetOptions } from "./types";
2
+ declare const _default: any[];
3
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import { defineNitroPreset } from "nitropack/kit";
2
+ import { writeFile } from "nitropack/kit";
3
+ import { resolve } from "pathe";
4
+ const cloudflare = defineNitroPreset(
5
+ {
6
+ extends: "base-worker",
7
+ entry: "./runtime/cloudflare-worker",
8
+ exportConditions: ["workerd"],
9
+ commands: {
10
+ preview: "npx wrangler dev ./server/index.mjs --site ./public",
11
+ deploy: "npx wrangler deploy"
12
+ },
13
+ wasm: {
14
+ lazy: true
15
+ },
16
+ hooks: {
17
+ async compiled(nitro) {
18
+ await writeFile(
19
+ resolve(nitro.options.output.dir, "package.json"),
20
+ JSON.stringify({ private: true, main: "./server/index.mjs" }, null, 2)
21
+ );
22
+ await writeFile(
23
+ resolve(nitro.options.output.dir, "package-lock.json"),
24
+ JSON.stringify({ lockfileVersion: 1 }, null, 2)
25
+ );
26
+ }
27
+ }
28
+ },
29
+ {
30
+ name: "cloudflare-worker",
31
+ aliases: ["cloudflare"],
32
+ url: import.meta.url
33
+ }
34
+ );
35
+ const cloudflareModuleLegacy = defineNitroPreset(
36
+ {
37
+ extends: "base-worker",
38
+ entry: "./runtime/cloudflare-module-legacy",
39
+ exportConditions: ["workerd"],
40
+ commands: {
41
+ preview: "npx wrangler dev ./server/index.mjs --site ./public",
42
+ deploy: "npx wrangler deploy"
43
+ },
44
+ rollupConfig: {
45
+ external: "__STATIC_CONTENT_MANIFEST",
46
+ output: {
47
+ format: "esm",
48
+ exports: "named",
49
+ inlineDynamicImports: false
50
+ }
51
+ },
52
+ wasm: {
53
+ lazy: false,
54
+ esmImport: true
55
+ },
56
+ hooks: {
57
+ async compiled(nitro) {
58
+ await writeFile(
59
+ resolve(nitro.options.output.dir, "package.json"),
60
+ JSON.stringify({ private: true, main: "./server/index.mjs" }, null, 2)
61
+ );
62
+ await writeFile(
63
+ resolve(nitro.options.output.dir, "package-lock.json"),
64
+ JSON.stringify({ lockfileVersion: 1 }, null, 2)
65
+ );
66
+ }
67
+ }
68
+ },
69
+ {
70
+ name: "cloudflare-module-legacy",
71
+ aliases: ["cloudflare-module"],
72
+ url: import.meta.url
73
+ }
74
+ );
75
+ export default [cloudflare, cloudflareModuleLegacy];
@@ -8,6 +8,7 @@ import {
8
8
  writeCFPagesRedirects
9
9
  } from "./utils.mjs";
10
10
  import { hybridNodePlugin, unenvCfPreset } from "./unenv/preset.mjs";
11
+ import cfLegacyPresets from "./preset-legacy.mjs";
11
12
  const isWindows = process.platform === "win32";
12
13
  const commandWithDir = (command) => isWindows ? `cmd /c "cd ./ && ${command}"` : `(cd ./ && ${command})`;
13
14
  const cloudflarePages = defineNitroPreset(
@@ -91,77 +92,6 @@ const cloudflarePagesStatic = defineNitroPreset(
91
92
  static: true
92
93
  }
93
94
  );
94
- const cloudflare = defineNitroPreset(
95
- {
96
- extends: "base-worker",
97
- entry: "./runtime/cloudflare-worker",
98
- exportConditions: ["workerd"],
99
- commands: {
100
- preview: "npx wrangler dev ./server/index.mjs --site ./public",
101
- deploy: "npx wrangler deploy"
102
- },
103
- wasm: {
104
- lazy: true
105
- },
106
- hooks: {
107
- async compiled(nitro) {
108
- await writeFile(
109
- resolve(nitro.options.output.dir, "package.json"),
110
- JSON.stringify({ private: true, main: "./server/index.mjs" }, null, 2)
111
- );
112
- await writeFile(
113
- resolve(nitro.options.output.dir, "package-lock.json"),
114
- JSON.stringify({ lockfileVersion: 1 }, null, 2)
115
- );
116
- }
117
- }
118
- },
119
- {
120
- name: "cloudflare-worker",
121
- aliases: ["cloudflare"],
122
- url: import.meta.url
123
- }
124
- );
125
- const cloudflareModuleLegacy = defineNitroPreset(
126
- {
127
- extends: "base-worker",
128
- entry: "./runtime/cloudflare-module-legacy",
129
- exportConditions: ["workerd"],
130
- commands: {
131
- preview: "npx wrangler dev ./server/index.mjs --site ./public",
132
- deploy: "npx wrangler deploy"
133
- },
134
- rollupConfig: {
135
- external: "__STATIC_CONTENT_MANIFEST",
136
- output: {
137
- format: "esm",
138
- exports: "named",
139
- inlineDynamicImports: false
140
- }
141
- },
142
- wasm: {
143
- lazy: false,
144
- esmImport: true
145
- },
146
- hooks: {
147
- async compiled(nitro) {
148
- await writeFile(
149
- resolve(nitro.options.output.dir, "package.json"),
150
- JSON.stringify({ private: true, main: "./server/index.mjs" }, null, 2)
151
- );
152
- await writeFile(
153
- resolve(nitro.options.output.dir, "package-lock.json"),
154
- JSON.stringify({ lockfileVersion: 1 }, null, 2)
155
- );
156
- }
157
- }
158
- },
159
- {
160
- name: "cloudflare-module-legacy",
161
- aliases: ["cloudflare-module"],
162
- url: import.meta.url
163
- }
164
- );
165
95
  const cloudflareModule = defineNitroPreset(
166
96
  {
167
97
  extends: "base-worker",
@@ -220,10 +150,9 @@ const cloudflareDurable = defineNitroPreset(
220
150
  }
221
151
  );
222
152
  export default [
223
- cloudflare,
224
- cloudflareModuleLegacy,
225
- cloudflareModule,
226
- cloudflareDurable,
153
+ ...cfLegacyPresets,
227
154
  cloudflarePages,
228
- cloudflarePagesStatic
155
+ cloudflarePagesStatic,
156
+ cloudflareModule,
157
+ cloudflareDurable
229
158
  ];
@@ -137,32 +137,54 @@ export async function writeWranglerConfig(nitro, isPages) {
137
137
  const wranglerConfigDir = nitro.options.output.serverDir;
138
138
  const wranglerConfigPath = join(wranglerConfigDir, "wrangler.json");
139
139
  const defaults = {};
140
+ const overrides = {};
140
141
  defaults.compatibility_date = nitro.options.compatibilityDate.cloudflare || nitro.options.compatibilityDate.default;
141
- defaults.compatibility_flags = ["nodejs_compat", "no_nodejs_compat_v2"];
142
142
  if (isPages) {
143
- defaults.pages_build_output_dir = relative(
144
- dirname(wranglerConfigPath),
143
+ overrides.pages_build_output_dir = relative(
144
+ wranglerConfigDir,
145
145
  nitro.options.output.publicDir
146
146
  );
147
147
  } else {
148
- defaults.main = relative(
148
+ overrides.main = relative(
149
149
  wranglerConfigDir,
150
150
  join(nitro.options.output.serverDir, "index.mjs")
151
151
  );
152
- defaults.assets = {
152
+ overrides.assets = {
153
153
  binding: "ASSETS",
154
- directory: relative(
155
- dirname(wranglerConfigPath),
156
- nitro.options.output.publicDir
157
- )
154
+ directory: relative(wranglerConfigDir, nitro.options.output.publicDir)
158
155
  };
159
156
  }
160
157
  const userConfig = await resolveWranglerConfig(nitro.options.rootDir);
161
- const wranglerConfig = mergeWranglerConfigs(
158
+ const ctxConfig = nitro.options.cloudflare?.wrangler || {};
159
+ for (const key in overrides) {
160
+ if (key in userConfig || key in ctxConfig) {
161
+ nitro.logger.warn(
162
+ `[nitro] [cloudflare] Wrangler config \`${key}\`${key in ctxConfig ? "set by config or modules" : ""} is overridden and will be ignored.`
163
+ );
164
+ }
165
+ }
166
+ const wranglerConfig = defu(
167
+ overrides,
168
+ ctxConfig,
162
169
  userConfig,
163
- nitro.options.cloudflare?.wrangler,
164
170
  defaults
165
171
  );
172
+ const compatFlags = new Set(wranglerConfig.compatibility_flags || []);
173
+ if (compatFlags.has("nodejs_compat_v2") && compatFlags.has("no_nodejs_compat_v2")) {
174
+ nitro.logger.warn(
175
+ "[nitro] [cloudflare] Wrangler config `compatibility_flags` contains both `nodejs_compat_v2` and `no_nodejs_compat_v2`. Ignoring `nodejs_compat_v2`."
176
+ );
177
+ compatFlags.delete("nodejs_compat_v2");
178
+ }
179
+ if (compatFlags.has("nodejs_compat_v2")) {
180
+ nitro.logger.warn(
181
+ "[nitro] [cloudflare] Wrangler config `compatibility_flags` contains `nodejs_compat_v2`, which is currently incompatible with nitro, please remove it or USE AT YOUR OWN RISK!"
182
+ );
183
+ } else {
184
+ compatFlags.add("nodejs_compat");
185
+ compatFlags.add("no_nodejs_compat_v2");
186
+ }
187
+ wranglerConfig.compatibility_flags = [...compatFlags];
166
188
  await writeFile(
167
189
  wranglerConfigPath,
168
190
  JSON.stringify(wranglerConfig, null, 2),
@@ -199,14 +221,3 @@ async function resolveWranglerConfig(dir) {
199
221
  }
200
222
  return {};
201
223
  }
202
- function mergeWranglerConfigs(...configs) {
203
- const merged = defu({}, ...configs);
204
- if (merged.compatibility_flags) {
205
- let flags = [...new Set(merged.compatibility_flags || [])];
206
- if (flags.includes("no_nodejs_compat_v2")) {
207
- flags = flags.filter((flag) => flag !== "nodejs_compat_v2");
208
- }
209
- merged.compatibility_flags = flags;
210
- }
211
- return merged;
212
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.0-20250204-104845.ccf57266",
3
+ "version": "2.11.0-20250205-112249.ccfda71c",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",