wrangler 2.2.0 → 2.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -114,6 +114,7 @@
114
114
  "xxhash-wasm": "^1.0.1"
115
115
  },
116
116
  "devDependencies": {
117
+ "@cloudflare/types": "^6.18.4",
117
118
  "@databases/split-sql-query": "^1.0.3",
118
119
  "@databases/sql": "^3.2.0",
119
120
  "@iarna/toml": "^3.0.0",
@@ -401,6 +401,17 @@ describe("pages", () => {
401
401
  }
402
402
  );
403
403
 
404
+ setMockResponse(
405
+ "/accounts/:accountId/pages/projects/foo",
406
+ "GET",
407
+ async ([_url, accountId]) => {
408
+ assertLater(() => {
409
+ expect(accountId).toEqual("some-account-id");
410
+ });
411
+ return { deployment_configs: { production: {}, preview: {} } };
412
+ }
413
+ );
414
+
404
415
  await runWrangler("pages publish . --project-name=foo");
405
416
 
406
417
  expect(std.out).toMatchInlineSnapshot(`
@@ -470,6 +481,17 @@ describe("pages", () => {
470
481
  }
471
482
  );
472
483
 
484
+ setMockResponse(
485
+ "/accounts/:accountId/pages/projects/foo",
486
+ "GET",
487
+ async ([_url, accountId]) => {
488
+ assertLater(() => {
489
+ expect(accountId).toEqual("some-account-id");
490
+ });
491
+ return { deployment_configs: { production: {}, preview: {} } };
492
+ }
493
+ );
494
+
473
495
  await runWrangler("pages publish . --project-name=foo");
474
496
 
475
497
  // Assert two identical requests
@@ -564,6 +586,17 @@ describe("pages", () => {
564
586
  }
565
587
  );
566
588
 
589
+ setMockResponse(
590
+ "/accounts/:accountId/pages/projects/foo",
591
+ "GET",
592
+ async ([_url, accountId]) => {
593
+ assertLater(() => {
594
+ expect(accountId).toEqual("some-account-id");
595
+ });
596
+ return { deployment_configs: { production: {}, preview: {} } };
597
+ }
598
+ );
599
+
567
600
  await runWrangler("pages publish . --project-name=foo");
568
601
 
569
602
  // Assert two requests
@@ -658,6 +691,17 @@ describe("pages", () => {
658
691
  }
659
692
  );
660
693
 
694
+ setMockResponse(
695
+ "/accounts/:accountId/pages/projects/foo",
696
+ "GET",
697
+ async ([_url, accountId]) => {
698
+ assertLater(() => {
699
+ expect(accountId).toEqual("some-account-id");
700
+ });
701
+ return { deployment_configs: { production: {}, preview: {} } };
702
+ }
703
+ );
704
+
661
705
  await runWrangler("pages publish . --project-name=foo");
662
706
 
663
707
  // We have 3 buckets, so expect 3 uploads
@@ -772,6 +816,17 @@ describe("pages", () => {
772
816
  }
773
817
  );
774
818
 
819
+ setMockResponse(
820
+ "/accounts/:accountId/pages/projects/foo",
821
+ "GET",
822
+ async ([_url, accountId]) => {
823
+ assertLater(() => {
824
+ expect(accountId).toEqual("some-account-id");
825
+ });
826
+ return { deployment_configs: { production: {}, preview: {} } };
827
+ }
828
+ );
829
+
775
830
  await runWrangler(`pages publish public --project-name=foo`);
776
831
 
777
832
  // We have 3 buckets, so expect 3 uploads
@@ -886,6 +941,17 @@ describe("pages", () => {
886
941
  }
887
942
  );
888
943
 
944
+ setMockResponse(
945
+ "/accounts/:accountId/pages/projects/foo",
946
+ "GET",
947
+ async ([_url, accountId]) => {
948
+ assertLater(() => {
949
+ expect(accountId).toEqual("some-account-id");
950
+ });
951
+ return { deployment_configs: { production: {}, preview: {} } };
952
+ }
953
+ );
954
+
889
955
  chdir("public");
890
956
  await runWrangler(`pages publish . --project-name=foo`);
891
957
 
@@ -988,6 +1054,17 @@ describe("pages", () => {
988
1054
  })
989
1055
  );
990
1056
 
1057
+ setMockResponse(
1058
+ "/accounts/:accountId/pages/projects/foo",
1059
+ "GET",
1060
+ async ([_url, accountId]) => {
1061
+ assertLater(() => {
1062
+ expect(accountId).toEqual("some-account-id");
1063
+ });
1064
+ return { deployment_configs: { production: {}, preview: {} } };
1065
+ }
1066
+ );
1067
+
991
1068
  await runWrangler("pages publish . --project-name=foo");
992
1069
 
993
1070
  expect(std.err).toMatchInlineSnapshot(`""`);
@@ -1132,6 +1209,17 @@ describe("pages", () => {
1132
1209
  }
1133
1210
  );
1134
1211
 
1212
+ setMockResponse(
1213
+ "/accounts/:accountId/pages/projects/foo",
1214
+ "GET",
1215
+ async ([_url, accountId]) => {
1216
+ assertLater(() => {
1217
+ expect(accountId).toEqual("some-account-id");
1218
+ });
1219
+ return { deployment_configs: { production: {}, preview: {} } };
1220
+ }
1221
+ );
1222
+
1135
1223
  await runWrangler("pages publish public --project-name=foo");
1136
1224
 
1137
1225
  expect(std.out).toMatchInlineSnapshot(`
@@ -1238,6 +1326,17 @@ describe("pages", () => {
1238
1326
  }
1239
1327
  );
1240
1328
 
1329
+ setMockResponse(
1330
+ "/accounts/:accountId/pages/projects/foo",
1331
+ "GET",
1332
+ async ([_url, accountId]) => {
1333
+ assertLater(() => {
1334
+ expect(accountId).toEqual("some-account-id");
1335
+ });
1336
+ return { deployment_configs: { production: {}, preview: {} } };
1337
+ }
1338
+ );
1339
+
1241
1340
  await runWrangler("pages publish public --project-name=foo");
1242
1341
 
1243
1342
  expect(std.out).toMatchInlineSnapshot(`
@@ -1389,6 +1488,17 @@ describe("pages", () => {
1389
1488
  }
1390
1489
  );
1391
1490
 
1491
+ setMockResponse(
1492
+ "/accounts/:accountId/pages/projects/foo",
1493
+ "GET",
1494
+ async ([_url, accountId]) => {
1495
+ assertLater(() => {
1496
+ expect(accountId).toEqual("some-account-id");
1497
+ });
1498
+ return { deployment_configs: { production: {}, preview: {} } };
1499
+ }
1500
+ );
1501
+
1392
1502
  await runWrangler("pages publish public --project-name=foo");
1393
1503
 
1394
1504
  expect(std.out).toMatchInlineSnapshot(`
@@ -1475,6 +1585,17 @@ describe("pages", () => {
1475
1585
  });
1476
1586
  });
1477
1587
 
1588
+ setMockResponse(
1589
+ "/accounts/:accountId/pages/projects/foo",
1590
+ "GET",
1591
+ async ([_url, accountId]) => {
1592
+ assertLater(() => {
1593
+ expect(accountId).toEqual("some-account-id");
1594
+ });
1595
+ return { deployment_configs: { production: {}, preview: {} } };
1596
+ }
1597
+ );
1598
+
1478
1599
  await expect(runWrangler("pages publish public --project-name=foo"))
1479
1600
  .rejects
1480
1601
  .toThrow(`Invalid _routes.json file found at: public/_routes.json
@@ -1627,6 +1748,17 @@ and that at least one include rule is provided.
1627
1748
  }
1628
1749
  );
1629
1750
 
1751
+ setMockResponse(
1752
+ "/accounts/:accountId/pages/projects/foo",
1753
+ "GET",
1754
+ async ([_url, accountId]) => {
1755
+ assertLater(() => {
1756
+ expect(accountId).toEqual("some-account-id");
1757
+ });
1758
+ return { deployment_configs: { production: {}, preview: {} } };
1759
+ }
1760
+ );
1761
+
1630
1762
  await runWrangler("pages publish public --project-name=foo");
1631
1763
 
1632
1764
  expect(std.out).toMatchInlineSnapshot(`
@@ -1712,6 +1844,17 @@ and that at least one include rule is provided.
1712
1844
  });
1713
1845
  });
1714
1846
 
1847
+ setMockResponse(
1848
+ "/accounts/:accountId/pages/projects/foo",
1849
+ "GET",
1850
+ async ([_url, accountId]) => {
1851
+ assertLater(() => {
1852
+ expect(accountId).toEqual("some-account-id");
1853
+ });
1854
+ return { deployment_configs: { production: {}, preview: {} } };
1855
+ }
1856
+ );
1857
+
1715
1858
  await expect(runWrangler("pages publish public --project-name=foo"))
1716
1859
  .rejects
1717
1860
  .toThrow(`Invalid _routes.json file found at: public/_routes.json
@@ -1829,6 +1972,17 @@ and that at least one include rule is provided.
1829
1972
  }
1830
1973
  );
1831
1974
 
1975
+ setMockResponse(
1976
+ "/accounts/:accountId/pages/projects/foo",
1977
+ "GET",
1978
+ async ([_url, accountId]) => {
1979
+ assertLater(() => {
1980
+ expect(accountId).toEqual("some-account-id");
1981
+ });
1982
+ return { deployment_configs: { production: {}, preview: {} } };
1983
+ }
1984
+ );
1985
+
1832
1986
  await runWrangler("pages publish public --project-name=foo");
1833
1987
 
1834
1988
  expect(std.out).toMatchInlineSnapshot(`
@@ -1957,29 +2111,37 @@ and that at least one include rule is provided.
1957
2111
  assertLater(() => {
1958
2112
  expect(requests.length).toBe(3);
1959
2113
 
1960
- expect(requests[0].headers).toMatchObject({
2114
+ const sortedRequests = requests.sort((a, b) => {
2115
+ return (JSON.parse(a.body as string)[0].key as string).localeCompare(
2116
+ JSON.parse(b.body as string)[0].key as string
2117
+ );
2118
+ });
2119
+
2120
+ expect(sortedRequests[0].headers).toMatchObject({
1961
2121
  Authorization: "Bearer <<funfetti-auth-jwt>>",
1962
2122
  });
1963
2123
 
1964
2124
  let body = JSON.parse(
1965
- requests[0].body as string
2125
+ sortedRequests[0].body as string
1966
2126
  ) as UploadPayloadFile[];
1967
2127
  expect(body).toMatchObject([
1968
2128
  {
1969
- key: "95dedb64e6d4940fc2e0f11f711cc2f4",
1970
- value: Buffer.from("headersfile").toString("base64"),
2129
+ key: "09a79777abda8ccc8bdd51dd3ff8e9e9",
2130
+ value: Buffer.from("func").toString("base64"),
1971
2131
  metadata: {
1972
- contentType: "application/octet-stream",
2132
+ contentType: "application/javascript",
1973
2133
  },
1974
2134
  base64: true,
1975
2135
  },
1976
2136
  ]);
1977
2137
 
1978
- expect(requests[1].headers).toMatchObject({
2138
+ expect(sortedRequests[1].headers).toMatchObject({
1979
2139
  Authorization: "Bearer <<funfetti-auth-jwt>>",
1980
2140
  });
1981
2141
 
1982
- body = JSON.parse(requests[1].body as string) as UploadPayloadFile[];
2142
+ body = JSON.parse(
2143
+ sortedRequests[1].body as string
2144
+ ) as UploadPayloadFile[];
1983
2145
  expect(body).toMatchObject([
1984
2146
  {
1985
2147
  key: "2082190357cfd3617ccfe04f340c6247",
@@ -1991,17 +2153,19 @@ and that at least one include rule is provided.
1991
2153
  },
1992
2154
  ]);
1993
2155
 
1994
- expect(requests[2].headers).toMatchObject({
2156
+ expect(sortedRequests[2].headers).toMatchObject({
1995
2157
  Authorization: "Bearer <<funfetti-auth-jwt>>",
1996
2158
  });
1997
2159
 
1998
- body = JSON.parse(requests[2].body as string) as UploadPayloadFile[];
2160
+ body = JSON.parse(
2161
+ sortedRequests[2].body as string
2162
+ ) as UploadPayloadFile[];
1999
2163
  expect(body).toMatchObject([
2000
2164
  {
2001
- key: "09a79777abda8ccc8bdd51dd3ff8e9e9",
2002
- value: Buffer.from("func").toString("base64"),
2165
+ key: "95dedb64e6d4940fc2e0f11f711cc2f4",
2166
+ value: Buffer.from("headersfile").toString("base64"),
2003
2167
  metadata: {
2004
- contentType: "application/javascript",
2168
+ contentType: "application/octet-stream",
2005
2169
  },
2006
2170
  base64: true,
2007
2171
  },
package/src/bundle.ts CHANGED
@@ -13,7 +13,7 @@ import type { WorkerRegistry } from "./dev-registry";
13
13
  import type { Entry } from "./entry";
14
14
  import type { CfModule } from "./worker";
15
15
 
16
- type BundleResult = {
16
+ export type BundleResult = {
17
17
  modules: CfModule[];
18
18
  dependencies: esbuild.Metafile["outputs"][string]["inputs"];
19
19
  resolvedEntryPointPath: string;
@@ -80,24 +80,31 @@ export async function bundleWorker(
80
80
  destination: string,
81
81
  options: {
82
82
  serveAssetsFromWorker: boolean;
83
- assets: StaticAssetsConfig;
83
+ assets?: StaticAssetsConfig;
84
84
  betaD1Shims?: string[];
85
- jsxFactory: string | undefined;
86
- jsxFragment: string | undefined;
85
+ jsxFactory?: string;
86
+ jsxFragment?: string;
87
87
  rules: Config["rules"];
88
- watch?: esbuild.WatchMode;
89
- tsconfig: string | undefined;
90
- minify: boolean | undefined;
91
- nodeCompat: boolean | undefined;
88
+ watch?: esbuild.WatchMode | boolean;
89
+ tsconfig?: string;
90
+ minify?: boolean;
91
+ nodeCompat?: boolean;
92
92
  define: Config["define"];
93
93
  checkFetch: boolean;
94
- services: Config["services"] | undefined;
95
- workerDefinitions: WorkerRegistry | undefined;
96
- firstPartyWorkerDevFacade: boolean | undefined;
94
+ services?: Config["services"];
95
+ workerDefinitions?: WorkerRegistry;
96
+ firstPartyWorkerDevFacade?: boolean;
97
97
  targetConsumer: "dev" | "publish";
98
98
  local: boolean;
99
- testScheduled?: boolean | undefined;
100
- experimentalLocalStubCache: boolean | undefined;
99
+ testScheduled?: boolean;
100
+ experimentalLocalStubCache?: boolean;
101
+ inject?: string[];
102
+ loader?: Record<string, string>;
103
+ sourcemap?: esbuild.CommonOptions["sourcemap"];
104
+ plugins?: esbuild.Plugin[];
105
+ // TODO: Rip these out https://github.com/cloudflare/wrangler2/issues/2153
106
+ disableModuleCollection?: boolean;
107
+ isOutfile?: boolean;
101
108
  }
102
109
  ): Promise<BundleResult> {
103
110
  const {
@@ -119,6 +126,12 @@ export async function bundleWorker(
119
126
  targetConsumer,
120
127
  testScheduled,
121
128
  experimentalLocalStubCache,
129
+ inject: injectOption,
130
+ loader,
131
+ sourcemap,
132
+ plugins,
133
+ disableModuleCollection,
134
+ isOutfile,
122
135
  } = options;
123
136
 
124
137
  // We create a temporary directory for any oneoff files we
@@ -127,7 +140,7 @@ export async function bundleWorker(
127
140
  const tmpDir = await tmp.dir({ unsafeCleanup: true });
128
141
 
129
142
  const entryDirectory = path.dirname(entry.file);
130
- const moduleCollector = createModuleCollector({
143
+ let moduleCollector = createModuleCollector({
131
144
  wrangler1xlegacyModuleReferences: {
132
145
  rootDirectory: entryDirectory,
133
146
  fileNames: new Set(
@@ -143,6 +156,15 @@ export async function bundleWorker(
143
156
  format: entry.format,
144
157
  rules,
145
158
  });
159
+ if (disableModuleCollection) {
160
+ moduleCollector = {
161
+ modules: [],
162
+ plugin: {
163
+ name: moduleCollector.plugin.name,
164
+ setup: () => {},
165
+ },
166
+ };
167
+ }
146
168
 
147
169
  // In dev, we want to patch `fetch()` with a special version that looks
148
170
  // for bad usages and can warn the user about them; so we inject
@@ -253,7 +275,7 @@ export async function bundleWorker(
253
275
 
254
276
  // At this point, inputEntry points to the entry point we want to build.
255
277
 
256
- const inject: string[] = [];
278
+ const inject: string[] = injectOption ?? [];
257
279
  if (checkFetch) inject.push(checkedFetchFileToInject);
258
280
  if (experimentalLocalStubCache) {
259
281
  inject.push(
@@ -266,11 +288,17 @@ export async function bundleWorker(
266
288
  bundle: true,
267
289
  absWorkingDir: entry.directory,
268
290
  outdir: destination,
291
+ ...(isOutfile
292
+ ? {
293
+ outdir: undefined,
294
+ outfile: destination,
295
+ }
296
+ : {}),
269
297
  inject,
270
298
  external: ["__STATIC_CONTENT_MANIFEST"],
271
299
  format: entry.format === "modules" ? "esm" : "iife",
272
300
  target: "es2020",
273
- sourcemap: true,
301
+ sourcemap: sourcemap ?? true, // this needs to use ?? to accept false
274
302
  // Include a reference to the output folder in the sourcemap.
275
303
  // This is omitted by default, but we need it to properly resolve source paths in error output.
276
304
  sourceRoot: destination,
@@ -291,6 +319,7 @@ export async function bundleWorker(
291
319
  ".js": "jsx",
292
320
  ".mjs": "jsx",
293
321
  ".cjs": "jsx",
322
+ ...(loader || {}),
294
323
  },
295
324
  plugins: [
296
325
  // We run the moduleCollector plugin for service workers as part of the middleware loader
@@ -301,6 +330,7 @@ export async function bundleWorker(
301
330
  ...(nodeCompat
302
331
  ? [NodeGlobalsPolyfills({ buffer: true }), NodeModulesPolyfills()]
303
332
  : []),
333
+ ...(plugins || []),
304
334
  ],
305
335
  ...(jsxFactory && { jsxFactory }),
306
336
  ...(jsxFragment && { jsxFragment }),
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
- import { dirname, join } from "node:path";
3
+ import { dirname, join, resolve } from "node:path";
4
4
  import { FatalError } from "../errors";
5
5
  import { logger } from "../logger";
6
6
  import * as metrics from "../metrics";
@@ -81,6 +81,13 @@ export function Options(yargs: Argv) {
81
81
  type: "boolean",
82
82
  hidden: true,
83
83
  },
84
+ bindings: {
85
+ type: "string",
86
+ describe:
87
+ "Bindings used in Functions (used to register beta product shims)",
88
+ deprecated: true,
89
+ hidden: true,
90
+ },
84
91
  })
85
92
  .epilogue(pagesBetaWarning);
86
93
  }
@@ -97,6 +104,7 @@ export const Handler = async ({
97
104
  plugin,
98
105
  buildOutputDirectory,
99
106
  nodeCompat,
107
+ bindings,
100
108
  }: PagesBuildArgs) => {
101
109
  if (!isInPagesCI) {
102
110
  // Beta message for `wrangler pages <commands>` usage
@@ -109,6 +117,16 @@ export const Handler = async ({
109
117
  );
110
118
  }
111
119
 
120
+ let d1Databases: string[] | undefined = undefined;
121
+ if (bindings) {
122
+ try {
123
+ const decodedBindings = JSON.parse(bindings);
124
+ d1Databases = Object.keys(decodedBindings?.d1_databases || {});
125
+ } catch {
126
+ throw new FatalError("Could not parse a valid set of 'bindings'.", 1);
127
+ }
128
+ }
129
+
112
130
  buildOutputDirectory ??= dirname(outfile);
113
131
  try {
114
132
  await buildFunctions({
@@ -123,6 +141,8 @@ export const Handler = async ({
123
141
  buildOutputDirectory,
124
142
  nodeCompat,
125
143
  routesOutputPath,
144
+ local: false,
145
+ d1Databases,
126
146
  });
127
147
  } catch (e) {
128
148
  if (e instanceof FunctionsNoRoutesError) {
@@ -154,6 +174,8 @@ export async function buildFunctions({
154
174
  buildOutputDirectory,
155
175
  routesOutputPath,
156
176
  nodeCompat,
177
+ local,
178
+ d1Databases,
157
179
  }: Partial<
158
180
  Pick<
159
181
  PagesBuildArgs,
@@ -171,6 +193,8 @@ export async function buildFunctions({
171
193
  onEnd?: () => void;
172
194
  outfile: Required<PagesBuildArgs>["outfile"];
173
195
  routesOutputPath?: PagesBuildArgs["outputRoutesPath"];
196
+ local: boolean;
197
+ d1Databases?: string[];
174
198
  }) {
175
199
  RUNNING_BUILDERS.forEach(
176
200
  (runningBuilder) => runningBuilder.stop && runningBuilder.stop()
@@ -208,6 +232,8 @@ export async function buildFunctions({
208
232
  outfile: routesModule,
209
233
  });
210
234
 
235
+ const absoluteFunctionsDirectory = resolve(functionsDirectory);
236
+
211
237
  if (plugin) {
212
238
  RUNNING_BUILDERS.push(
213
239
  await buildPlugin({
@@ -217,6 +243,9 @@ export async function buildFunctions({
217
243
  sourcemap,
218
244
  watch,
219
245
  nodeCompat,
246
+ functionsDirectory: absoluteFunctionsDirectory,
247
+ local,
248
+ betaD1Shims: d1Databases,
220
249
  onEnd,
221
250
  })
222
251
  );
@@ -229,6 +258,9 @@ export async function buildFunctions({
229
258
  sourcemap,
230
259
  fallbackService,
231
260
  watch,
261
+ functionsDirectory: absoluteFunctionsDirectory,
262
+ local,
263
+ betaD1Shims: d1Databases,
232
264
  onEnd,
233
265
  buildOutputDirectory,
234
266
  nodeCompat,
package/src/pages/dev.tsx CHANGED
@@ -256,6 +256,8 @@ export const Handler = async ({
256
256
  await esbuild.build({
257
257
  entryPoints: [scriptPath],
258
258
  write: false,
259
+ // we need it to be bundled so that any imports that are used are affected by the blocker plugin
260
+ bundle: true,
259
261
  plugins: [blockWorkerJsImports],
260
262
  });
261
263
  } catch {}
@@ -270,7 +272,7 @@ export const Handler = async ({
270
272
  });
271
273
  } else if (usingFunctions) {
272
274
  // Try to use Functions
273
- const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.js`);
275
+ const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.mjs`);
274
276
  scriptPath = outfile;
275
277
 
276
278
  if (nodeCompat) {
@@ -290,6 +292,8 @@ export const Handler = async ({
290
292
  onEnd,
291
293
  buildOutputDirectory: directory,
292
294
  nodeCompat,
295
+ local: true,
296
+ d1Databases: d1s.map((binding) => binding.toString()),
293
297
  });
294
298
  await metrics.sendMetricsEvent("build pages functions");
295
299
 
@@ -307,6 +311,8 @@ export const Handler = async ({
307
311
  onEnd,
308
312
  buildOutputDirectory: directory,
309
313
  nodeCompat,
314
+ local: true,
315
+ d1Databases: d1s.map((binding) => binding.toString()),
310
316
  });
311
317
  await metrics.sendMetricsEvent("build pages functions");
312
318
  } catch (e) {
@@ -477,8 +483,8 @@ export const Handler = async ({
477
483
  .map((binding) => binding.toString().split("="))
478
484
  .map(([key, ...values]) => [key, values.join("=")])
479
485
  ),
480
- kv: kvs.map((val) => ({
481
- binding: val.toString(),
486
+ kv: kvs.map((binding) => ({
487
+ binding: binding.toString(),
482
488
  id: "",
483
489
  })),
484
490
  durableObjects: durableObjects
@@ -520,7 +526,7 @@ export const Handler = async ({
520
526
  persist,
521
527
  persistTo,
522
528
  showInteractiveDevSession: undefined,
523
- inspect: true,
529
+ inspect: undefined,
524
530
  logPrefix: "pages",
525
531
  logLevel: logLevel ?? "warn",
526
532
  },
@@ -680,14 +686,23 @@ async function spawnProxyProcess({
680
686
  return port;
681
687
  }
682
688
 
689
+ // TODO: Kill this once we have https://github.com/cloudflare/wrangler2/issues/2153
683
690
  const blockWorkerJsImports: esbuild.Plugin = {
684
691
  name: "block-worker-js-imports",
685
- setup(build: esbuild.PluginBuild) {
686
- build.onResolve({ filter: /.*/g }, (_args) => {
692
+ setup(build) {
693
+ build.onResolve({ filter: /.*/g }, (args) => {
694
+ // If it's the entrypoint, let it be as is
695
+ if (args.kind === "entry-point") {
696
+ return {
697
+ path: args.path,
698
+ };
699
+ }
700
+ // Otherwise, block any imports that the file is requesting
687
701
  logger.error(
688
702
  `_worker.js is importing from another file. This will throw an error if deployed.\nYou should bundle your Worker or remove the import if it is unused.`
689
703
  );
690
- return null;
704
+ // Miniflare will error with this briefly down the line -- there's no point in continuing.
705
+ process.exit(1);
691
706
  });
692
707
  },
693
708
  };