wrangler 2.8.0 → 2.8.1

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.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/d1/d1.test.ts +12 -8
  3. package/src/__tests__/deployments.test.ts +4 -4
  4. package/src/__tests__/helpers/msw/handlers/deployments.ts +10 -18
  5. package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
  6. package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
  7. package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
  8. package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
  9. package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
  10. package/src/__tests__/pages.test.ts +34 -37
  11. package/src/__tests__/publish.test.ts +126 -0
  12. package/src/__tests__/r2.test.ts +11 -35
  13. package/src/__tests__/tail.test.ts +6 -18
  14. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  15. package/src/__tests__/user.test.ts +0 -1
  16. package/src/__tests__/whoami.test.tsx +6 -17
  17. package/src/__tests__/worker-namespace.test.ts +56 -48
  18. package/src/api/index.ts +1 -0
  19. package/src/api/pages/index.ts +5 -0
  20. package/src/api/pages/publish.tsx +321 -0
  21. package/src/bundle.ts +62 -10
  22. package/src/cli.ts +2 -2
  23. package/src/config/environment.ts +12 -10
  24. package/src/d1/utils.ts +1 -1
  25. package/src/deployments.ts +16 -6
  26. package/src/dev/local.tsx +1 -10
  27. package/src/dev/start-server.ts +5 -10
  28. package/src/dev/use-esbuild.ts +1 -0
  29. package/src/entry.ts +1 -2
  30. package/src/index.ts +1 -1
  31. package/src/metrics/send-event.ts +2 -1
  32. package/src/pages/build.ts +4 -124
  33. package/src/pages/buildFunctions.ts +129 -0
  34. package/src/pages/dev.ts +12 -2
  35. package/src/pages/functions/buildPlugin.ts +1 -0
  36. package/src/pages/functions/buildWorker.ts +8 -2
  37. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  38. package/src/pages/publish.tsx +9 -235
  39. package/src/publish/publish.ts +1 -0
  40. package/templates/d1-beta-facade.js +1 -1
  41. package/templates/middleware/loader-modules.ts +2 -0
  42. package/templates/tsconfig.tsbuildinfo +1 -1
  43. package/wrangler-dist/cli.d.ts +132 -10
  44. package/wrangler-dist/cli.js +486 -388
@@ -261,6 +261,17 @@ interface EnvironmentInheritable {
261
261
  logpush: boolean | undefined;
262
262
  }
263
263
 
264
+ export type DurableObjectBindings = {
265
+ /** The name of the binding used to refer to the Durable Object */
266
+ name: string;
267
+ /** The exported class name of the Durable Object */
268
+ class_name: string;
269
+ /** The script where the Durable Object is defined (if it's external to this worker) */
270
+ script_name?: string;
271
+ /** The service environment of the script_name to bind to */
272
+ environment?: string;
273
+ }[];
274
+
264
275
  /**
265
276
  * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
266
277
  * that cannot be inherited from the top-level environment, and must be defined specifically.
@@ -303,16 +314,7 @@ interface EnvironmentNonInheritable {
303
314
  * @nonInheritable
304
315
  */
305
316
  durable_objects: {
306
- bindings: {
307
- /** The name of the binding used to refer to the Durable Object */
308
- name: string;
309
- /** The exported class name of the Durable Object */
310
- class_name: string;
311
- /** The script where the Durable Object is defined (if it's external to this worker) */
312
- script_name?: string;
313
- /** The service environment of the script_name to bind to */
314
- environment?: string;
315
- }[];
317
+ bindings: DurableObjectBindings;
316
318
  };
317
319
 
318
320
  /**
package/src/d1/utils.ts CHANGED
@@ -45,4 +45,4 @@ export const getDatabaseByNameOrBinding = async (
45
45
 
46
46
  export const d1BetaWarning = process.env.NO_D1_WARNING
47
47
  ? ""
48
- : "🚧 D1 is currently in open alpha and is not recommended for production data and traffic.\nPlease report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose.\nTo request features, visit https://community.cloudflare.com/c/developers/d1.\nTo give feedback, visit https://discord.gg/cloudflaredev";
48
+ : "--------------------\n🚧 D1 is currently in open alpha and is not recommended for production data and traffic\n🚧 Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose\n🚧 To request features, visit https://community.cloudflare.com/c/developers/d1\n🚧 To give feedback, visit https://discord.gg/cloudflaredev\n--------------------\n";
@@ -1,6 +1,8 @@
1
1
  import { URLSearchParams } from "url";
2
2
  import { fetchResult } from "./cfetch";
3
3
  import { logger } from "./logger";
4
+ import * as metrics from "./metrics";
5
+ import type { Config } from "./config";
4
6
  import type { ServiceMetadataRes } from "./init";
5
7
 
6
8
  export type DeploymentListRes = {
@@ -34,7 +36,8 @@ export type DeploymentListRes = {
34
36
 
35
37
  export async function deployments(
36
38
  accountId: string,
37
- scriptName: string | undefined
39
+ scriptName: string | undefined,
40
+ { send_metrics: sendMetrics }: { send_metrics?: Config["send_metrics"] } = {}
38
41
  ) {
39
42
  if (!scriptName) {
40
43
  throw new Error(
@@ -42,6 +45,14 @@ export async function deployments(
42
45
  );
43
46
  }
44
47
 
48
+ await metrics.sendMetricsEvent(
49
+ "view deployments",
50
+ { view: scriptName ? "single" : "all" },
51
+ {
52
+ sendMetrics,
53
+ }
54
+ );
55
+
45
56
  const scriptMetadata = await fetchResult<ServiceMetadataRes>(
46
57
  `/accounts/${accountId}/workers/services/${scriptName}`
47
58
  );
@@ -66,17 +77,16 @@ Source: ${sourceStr(versions.metadata.source)}\n`
66
77
  logger.log(...versionMessages);
67
78
  }
68
79
 
69
- // TODO Include emoji/icon for each source
70
80
  function sourceStr(source: string): string {
71
81
  switch (source) {
72
82
  case "api":
73
- return "API";
83
+ return "šŸ“” API";
74
84
  case "dash":
75
- return "Dashboard";
85
+ return "šŸ–„ļø Dashboard";
76
86
  case "wrangler":
77
- return "Wrangler";
87
+ return "🤠 Wrangler";
78
88
  case "terraform":
79
- return "Terraform";
89
+ return "šŸ—ļø Terraform";
80
90
  default:
81
91
  return "Other";
82
92
  }
package/src/dev/local.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import assert from "node:assert";
2
2
  import { fork } from "node:child_process";
3
3
  import { realpathSync } from "node:fs";
4
- import { readFile, writeFile } from "node:fs/promises";
4
+ import { readFile } from "node:fs/promises";
5
5
  import path from "node:path";
6
6
  import chalk from "chalk";
7
7
  import getPort from "get-port";
@@ -165,15 +165,6 @@ function useLocalWorker({
165
165
  async function startLocalWorker() {
166
166
  if (!bundle || !format) return;
167
167
 
168
- // In local mode, we want to copy all referenced modules into
169
- // the output bundle directory before starting up
170
- for (const module of bundle.modules) {
171
- await writeFile(
172
- path.join(path.dirname(bundle.path), module.name),
173
- module.content
174
- );
175
- }
176
-
177
168
  const scriptPath = realpathSync(bundle.path);
178
169
 
179
170
  const upstream =
@@ -1,6 +1,5 @@
1
1
  import { fork } from "node:child_process";
2
2
  import { realpathSync } from "node:fs";
3
- import { writeFile } from "node:fs/promises";
4
3
  import * as path from "node:path";
5
4
  import * as util from "node:util";
6
5
  import onExit from "signal-exit";
@@ -27,6 +26,7 @@ import { startRemoteServer } from "./remote";
27
26
  import { validateDevProps } from "./validate-dev-props";
28
27
 
29
28
  import type { Config } from "../config";
29
+ import type { DurableObjectBindings } from "../config/environment";
30
30
  import type { WorkerRegistry } from "../dev-registry";
31
31
  import type { Entry } from "../entry";
32
32
  import type { DevProps, DirectorySyncResult } from "./dev";
@@ -109,6 +109,7 @@ export async function startDevServer(
109
109
  testScheduled: props.testScheduled,
110
110
  local: props.local,
111
111
  experimentalLocal: props.experimentalLocal,
112
+ doBindings: props.bindings.durable_objects?.bindings ?? [],
112
113
  });
113
114
 
114
115
  if (props.local) {
@@ -218,6 +219,7 @@ async function runEsbuild({
218
219
  testScheduled,
219
220
  local,
220
221
  experimentalLocal,
222
+ doBindings,
221
223
  }: {
222
224
  entry: Entry;
223
225
  destination: string | undefined;
@@ -238,6 +240,7 @@ async function runEsbuild({
238
240
  testScheduled?: boolean;
239
241
  local: boolean;
240
242
  experimentalLocal: boolean | undefined;
243
+ doBindings: DurableObjectBindings;
241
244
  }): Promise<EsbuildBundle | undefined> {
242
245
  if (!destination) return;
243
246
 
@@ -279,6 +282,7 @@ async function runEsbuild({
279
282
  testScheduled,
280
283
  local,
281
284
  experimentalLocal,
285
+ doBindings,
282
286
  });
283
287
 
284
288
  return {
@@ -345,15 +349,6 @@ export async function startLocalServer({
345
349
  );
346
350
  }
347
351
 
348
- // In local mode, we want to copy all referenced modules into
349
- // the output bundle directory before starting up
350
- for (const module of bundle.modules) {
351
- await writeFile(
352
- path.join(path.dirname(bundle.path), module.name),
353
- module.content
354
- );
355
- }
356
-
357
352
  const scriptPath = realpathSync(bundle.path);
358
353
 
359
354
  const upstream =
@@ -123,6 +123,7 @@ export function useEsbuild({
123
123
  minify,
124
124
  nodeCompat,
125
125
  betaD1Shims,
126
+ doBindings: durableObjects.bindings,
126
127
  define,
127
128
  checkFetch: true,
128
129
  assets: assets && {
package/src/entry.ts CHANGED
@@ -6,6 +6,7 @@ import { execaCommand } from "execa";
6
6
  import { logger } from "./logger";
7
7
  import { getBasePath } from "./paths";
8
8
  import type { Config } from "./config";
9
+ import type { DurableObjectBindings } from "./config/environment";
9
10
  import type { CfScriptFormat } from "./worker";
10
11
  import type { Metafile } from "esbuild";
11
12
 
@@ -236,8 +237,6 @@ export function fileExists(filePath: string): boolean {
236
237
  return false;
237
238
  }
238
239
 
239
- type DurableObjectBindings = Config["durable_objects"]["bindings"];
240
-
241
240
  /**
242
241
  * Groups the durable object bindings into two lists:
243
242
  * those that are defined locally and those that refer to a durable object defined in another script.
package/src/index.ts CHANGED
@@ -588,7 +588,7 @@ export function createCLIParser(argv: string[]) {
588
588
  );
589
589
 
590
590
  logger.log(`${deploymentsWarning}\n`);
591
- await deployments(accountId, scriptName);
591
+ await deployments(accountId, scriptName, config);
592
592
  }
593
593
  );
594
594
 
@@ -56,7 +56,8 @@ export type EventNames =
56
56
  | "run dev"
57
57
  | "run dev (api)"
58
58
  | "run pages dev"
59
- | "view docs";
59
+ | "view docs"
60
+ | "view deployments";
60
61
 
61
62
  /**
62
63
  * Send a metrics event, with no extra properties, to Cloudflare, if usage tracking is enabled.
@@ -1,27 +1,19 @@
1
- import { writeFileSync } from "node:fs";
2
- import { tmpdir } from "node:os";
3
- import { dirname, join, resolve } from "node:path";
1
+ import { dirname } from "node:path";
4
2
  import { FatalError } from "../errors";
5
3
  import { logger } from "../logger";
6
4
  import * as metrics from "../metrics";
7
- import { toUrlPath } from "../paths";
5
+ import { buildFunctions } from "./buildFunctions";
8
6
  import { isInPagesCI } from "./constants";
9
7
  import {
10
8
  EXIT_CODE_FUNCTIONS_NO_ROUTES_ERROR,
11
9
  FunctionsNoRoutesError,
12
10
  getFunctionsNoRoutesWarning,
13
11
  } from "./errors";
14
- import { buildPlugin } from "./functions/buildPlugin";
15
- import { buildWorker } from "./functions/buildWorker";
16
- import { generateConfigFromFileTree } from "./functions/filepath-routing";
17
- import { writeRoutesModule } from "./functions/routes";
18
- import { convertRoutesToRoutesJSONSpec } from "./functions/routes-transformation";
19
- import { pagesBetaWarning, RUNNING_BUILDERS } from "./utils";
12
+ import { pagesBetaWarning } from "./utils";
20
13
  import type { YargsOptionsToInterface } from "../yargs-types";
21
- import type { Config } from "./functions/routes";
22
14
  import type { Argv } from "yargs";
23
15
 
24
- type PagesBuildArgs = YargsOptionsToInterface<typeof Options>;
16
+ export type PagesBuildArgs = YargsOptionsToInterface<typeof Options>;
25
17
 
26
18
  export function Options(yargs: Argv) {
27
19
  return yargs
@@ -156,115 +148,3 @@ export const Handler = async ({
156
148
  }
157
149
  await metrics.sendMetricsEvent("build pages functions");
158
150
  };
159
-
160
- /**
161
- * Builds a Functions worker based on the functions directory, with filepath and handler based routing.
162
- * @throws FunctionsNoRoutesError when there are no routes found in the functions directory
163
- */
164
- export async function buildFunctions({
165
- outfile,
166
- outputConfigPath,
167
- functionsDirectory,
168
- minify = false,
169
- sourcemap = false,
170
- fallbackService = "ASSETS",
171
- watch = false,
172
- onEnd,
173
- plugin = false,
174
- buildOutputDirectory,
175
- routesOutputPath,
176
- nodeCompat,
177
- local,
178
- d1Databases,
179
- }: Partial<
180
- Pick<
181
- PagesBuildArgs,
182
- | "outputConfigPath"
183
- | "minify"
184
- | "sourcemap"
185
- | "fallbackService"
186
- | "watch"
187
- | "plugin"
188
- | "buildOutputDirectory"
189
- | "nodeCompat"
190
- >
191
- > & {
192
- functionsDirectory: string;
193
- onEnd?: () => void;
194
- outfile: Required<PagesBuildArgs>["outfile"];
195
- routesOutputPath?: PagesBuildArgs["outputRoutesPath"];
196
- local: boolean;
197
- d1Databases?: string[];
198
- }) {
199
- RUNNING_BUILDERS.forEach(
200
- (runningBuilder) => runningBuilder.stop && runningBuilder.stop()
201
- );
202
-
203
- const routesModule = join(tmpdir(), `./functionsRoutes-${Math.random()}.mjs`);
204
- const baseURL = toUrlPath("/");
205
-
206
- const config: Config = await generateConfigFromFileTree({
207
- baseDir: functionsDirectory,
208
- baseURL,
209
- });
210
-
211
- if (!config.routes || config.routes.length === 0) {
212
- throw new FunctionsNoRoutesError(
213
- `Failed to find any routes while compiling Functions in: ${functionsDirectory}`
214
- );
215
- }
216
-
217
- if (routesOutputPath) {
218
- const routesJSON = convertRoutesToRoutesJSONSpec(config.routes);
219
- writeFileSync(routesOutputPath, JSON.stringify(routesJSON, null, 2));
220
- }
221
-
222
- if (outputConfigPath) {
223
- writeFileSync(
224
- outputConfigPath,
225
- JSON.stringify({ ...config, baseURL }, null, 2)
226
- );
227
- }
228
-
229
- await writeRoutesModule({
230
- config,
231
- srcDir: functionsDirectory,
232
- outfile: routesModule,
233
- });
234
-
235
- const absoluteFunctionsDirectory = resolve(functionsDirectory);
236
-
237
- if (plugin) {
238
- RUNNING_BUILDERS.push(
239
- await buildPlugin({
240
- routesModule,
241
- outfile,
242
- minify,
243
- sourcemap,
244
- watch,
245
- nodeCompat,
246
- functionsDirectory: absoluteFunctionsDirectory,
247
- local,
248
- betaD1Shims: d1Databases,
249
- onEnd,
250
- })
251
- );
252
- } else {
253
- RUNNING_BUILDERS.push(
254
- await buildWorker({
255
- routesModule,
256
- outfile,
257
- minify,
258
- sourcemap,
259
- fallbackService,
260
- watch,
261
- functionsDirectory: absoluteFunctionsDirectory,
262
- local,
263
- betaD1Shims: d1Databases,
264
- onEnd,
265
- buildOutputDirectory,
266
- nodeCompat,
267
- })
268
- );
269
- }
270
- }
@@ -0,0 +1,129 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join, resolve } from "node:path";
4
+ import { toUrlPath } from "../paths";
5
+ import { FunctionsNoRoutesError } from "./errors";
6
+ import { buildPlugin } from "./functions/buildPlugin";
7
+ import { buildWorker } from "./functions/buildWorker";
8
+ import { generateConfigFromFileTree } from "./functions/filepath-routing";
9
+ import { writeRoutesModule } from "./functions/routes";
10
+ import { convertRoutesToRoutesJSONSpec } from "./functions/routes-transformation";
11
+ import { RUNNING_BUILDERS } from "./utils";
12
+ import type { PagesBuildArgs } from "./build";
13
+ import type { Config } from "./functions/routes";
14
+
15
+ /**
16
+ * Builds a Functions worker based on the functions directory, with filepath and handler based routing.
17
+ * @throws FunctionsNoRoutesError when there are no routes found in the functions directory
18
+ */
19
+
20
+ export async function buildFunctions({
21
+ outfile,
22
+ outputConfigPath,
23
+ functionsDirectory,
24
+ minify = false,
25
+ sourcemap = false,
26
+ fallbackService = "ASSETS",
27
+ watch = false,
28
+ onEnd,
29
+ plugin = false,
30
+ buildOutputDirectory,
31
+ routesOutputPath,
32
+ nodeCompat,
33
+ local,
34
+ d1Databases,
35
+ experimentalWorkerBundle = false,
36
+ }: Partial<
37
+ Pick<
38
+ PagesBuildArgs,
39
+ | "outputConfigPath"
40
+ | "minify"
41
+ | "sourcemap"
42
+ | "fallbackService"
43
+ | "watch"
44
+ | "plugin"
45
+ | "buildOutputDirectory"
46
+ | "nodeCompat"
47
+ >
48
+ > & {
49
+ functionsDirectory: string;
50
+ onEnd?: () => void;
51
+ outfile: Required<PagesBuildArgs>["outfile"];
52
+ routesOutputPath?: PagesBuildArgs["outputRoutesPath"];
53
+ local: boolean;
54
+ d1Databases?: string[];
55
+ experimentalWorkerBundle?: boolean;
56
+ }) {
57
+ RUNNING_BUILDERS.forEach(
58
+ (runningBuilder) => runningBuilder.stop && runningBuilder.stop()
59
+ );
60
+
61
+ const routesModule = join(tmpdir(), `./functionsRoutes-${Math.random()}.mjs`);
62
+ const baseURL = toUrlPath("/");
63
+
64
+ const config: Config = await generateConfigFromFileTree({
65
+ baseDir: functionsDirectory,
66
+ baseURL,
67
+ });
68
+
69
+ if (!config.routes || config.routes.length === 0) {
70
+ throw new FunctionsNoRoutesError(
71
+ `Failed to find any routes while compiling Functions in: ${functionsDirectory}`
72
+ );
73
+ }
74
+
75
+ if (routesOutputPath) {
76
+ const routesJSON = convertRoutesToRoutesJSONSpec(config.routes);
77
+ writeFileSync(routesOutputPath, JSON.stringify(routesJSON, null, 2));
78
+ }
79
+
80
+ if (outputConfigPath) {
81
+ writeFileSync(
82
+ outputConfigPath,
83
+ JSON.stringify({ ...config, baseURL }, null, 2)
84
+ );
85
+ }
86
+
87
+ await writeRoutesModule({
88
+ config,
89
+ srcDir: functionsDirectory,
90
+ outfile: routesModule,
91
+ });
92
+
93
+ const absoluteFunctionsDirectory = resolve(functionsDirectory);
94
+
95
+ if (plugin) {
96
+ RUNNING_BUILDERS.push(
97
+ await buildPlugin({
98
+ routesModule,
99
+ outfile,
100
+ minify,
101
+ sourcemap,
102
+ watch,
103
+ nodeCompat,
104
+ functionsDirectory: absoluteFunctionsDirectory,
105
+ local,
106
+ betaD1Shims: d1Databases,
107
+ onEnd,
108
+ })
109
+ );
110
+ } else {
111
+ RUNNING_BUILDERS.push(
112
+ await buildWorker({
113
+ routesModule,
114
+ outfile,
115
+ minify,
116
+ sourcemap,
117
+ fallbackService,
118
+ watch,
119
+ functionsDirectory: absoluteFunctionsDirectory,
120
+ local,
121
+ betaD1Shims: d1Databases,
122
+ onEnd,
123
+ buildOutputDirectory,
124
+ nodeCompat,
125
+ experimentalWorkerBundle,
126
+ })
127
+ );
128
+ }
129
+ }
package/src/pages/dev.ts CHANGED
@@ -10,7 +10,7 @@ import { FatalError } from "../errors";
10
10
  import { logger } from "../logger";
11
11
  import * as metrics from "../metrics";
12
12
  import { getBasePath } from "../paths";
13
- import { buildFunctions } from "./build";
13
+ import { buildFunctions } from "./buildFunctions";
14
14
  import { ROUTES_SPEC_VERSION, SECONDS_TO_WAIT_FOR_PROXY } from "./constants";
15
15
  import { FunctionsNoRoutesError, getFunctionsNoRoutesWarning } from "./errors";
16
16
  import { buildRawWorker, checkRawWorker } from "./functions/buildWorker";
@@ -89,6 +89,13 @@ export function Options(yargs: Argv) {
89
89
  default: true,
90
90
  description: "Whether to run bundling on `_worker.js`",
91
91
  },
92
+ "experimental-worker-bundle": {
93
+ type: "boolean",
94
+ default: false,
95
+ hidden: true,
96
+ description:
97
+ "Whether to process non-JS module imports or not, such as wasm/text/binary, when we run bundling on `functions` or `_worker.js`",
98
+ },
92
99
  binding: {
93
100
  type: "array",
94
101
  description: "Bind variable/secret (KEY=VALUE)",
@@ -175,6 +182,7 @@ export const Handler = async ({
175
182
  "script-path": singleWorkerScriptPath,
176
183
  bundle,
177
184
  noBundle,
185
+ experimentalWorkerBundle,
178
186
  binding: bindings = [],
179
187
  kv: kvs = [],
180
188
  do: durableObjects = [],
@@ -270,7 +278,7 @@ export const Handler = async ({
270
278
  await checkRawWorker(workerScriptPath, () => scriptReadyResolve());
271
279
  };
272
280
 
273
- const enableBundling = bundle || !noBundle;
281
+ const enableBundling = bundle || !noBundle || experimentalWorkerBundle;
274
282
  if (enableBundling) {
275
283
  // We want to actually run the `_worker.js` script through the bundler
276
284
  // So update the final path to the script that will be uploaded and
@@ -286,6 +294,7 @@ export const Handler = async ({
286
294
  sourcemap: true,
287
295
  watch: true,
288
296
  onEnd: () => scriptReadyResolve(),
297
+ experimentalWorkerBundle,
289
298
  });
290
299
  } catch (e: unknown) {
291
300
  logger.warn("Failed to bundle _worker.js.", e);
@@ -323,6 +332,7 @@ export const Handler = async ({
323
332
  buildOutputDirectory: directory,
324
333
  nodeCompat,
325
334
  local: true,
335
+ experimentalWorkerBundle,
326
336
  });
327
337
  await metrics.sendMetricsEvent("build pages functions");
328
338
  };
@@ -37,6 +37,7 @@ export function buildPlugin({
37
37
  betaD1Shims: (betaD1Shims || []).map(
38
38
  (binding) => `${D1_BETA_PREFIX}${binding}`
39
39
  ),
40
+ doBindings: [], // Pages functions don't support internal Durable Objects
40
41
  plugins: [
41
42
  buildNotifierPlugin(onEnd),
42
43
  {
@@ -21,6 +21,7 @@ export type Options = {
21
21
  functionsDirectory: string;
22
22
  local: boolean;
23
23
  betaD1Shims?: string[];
24
+ experimentalWorkerBundle?: boolean;
24
25
  };
25
26
 
26
27
  export function buildWorker({
@@ -36,6 +37,7 @@ export function buildWorker({
36
37
  functionsDirectory,
37
38
  local,
38
39
  betaD1Shims,
40
+ experimentalWorkerBundle = false,
39
41
  }: Options) {
40
42
  return bundleWorker(
41
43
  {
@@ -60,6 +62,7 @@ export function buildWorker({
60
62
  betaD1Shims: (betaD1Shims || []).map(
61
63
  (binding) => `${D1_BETA_PREFIX}${binding}`
62
64
  ),
65
+ doBindings: [], // Pages functions don't support internal Durable Objects
63
66
  plugins: [
64
67
  buildNotifierPlugin(onEnd),
65
68
  {
@@ -139,7 +142,7 @@ export function buildWorker({
139
142
  ],
140
143
  isOutfile: true,
141
144
  serveAssetsFromWorker: false,
142
- disableModuleCollection: true,
145
+ disableModuleCollection: experimentalWorkerBundle ? false : true,
143
146
  rules: [],
144
147
  checkFetch: local,
145
148
  targetConsumer: local ? "dev" : "publish",
@@ -162,6 +165,7 @@ export type RawOptions = {
162
165
  nodeCompat?: boolean;
163
166
  local: boolean;
164
167
  betaD1Shims?: string[];
168
+ experimentalWorkerBundle?: boolean;
165
169
  };
166
170
 
167
171
  /**
@@ -183,6 +187,7 @@ export function buildRawWorker({
183
187
  nodeCompat,
184
188
  local,
185
189
  betaD1Shims,
190
+ experimentalWorkerBundle = false,
186
191
  }: RawOptions) {
187
192
  return bundleWorker(
188
193
  {
@@ -204,10 +209,11 @@ export function buildRawWorker({
204
209
  betaD1Shims: (betaD1Shims || []).map(
205
210
  (binding) => `${D1_BETA_PREFIX}${binding}`
206
211
  ),
212
+ doBindings: [], // Pages functions don't support internal Durable Objects
207
213
  plugins: [...plugins, buildNotifierPlugin(onEnd)],
208
214
  isOutfile: true,
209
215
  serveAssetsFromWorker: false,
210
- disableModuleCollection: true,
216
+ disableModuleCollection: experimentalWorkerBundle ? false : true,
211
217
  rules: [],
212
218
  checkFetch: local,
213
219
  targetConsumer: local ? "dev" : "publish",