wrangler 2.0.5 → 2.0.8

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 (46) hide show
  1. package/README.md +1 -1
  2. package/bin/wrangler.js +16 -4
  3. package/package.json +6 -4
  4. package/pages/functions/buildPlugin.ts +13 -0
  5. package/pages/functions/buildWorker.ts +13 -0
  6. package/src/__tests__/configuration.test.ts +335 -86
  7. package/src/__tests__/dev.test.tsx +166 -15
  8. package/src/__tests__/helpers/mock-dialogs.ts +41 -1
  9. package/src/__tests__/index.test.ts +30 -16
  10. package/src/__tests__/init.test.ts +249 -131
  11. package/src/__tests__/kv.test.ts +101 -101
  12. package/src/__tests__/package-manager.test.ts +154 -7
  13. package/src/__tests__/pages.test.ts +369 -39
  14. package/src/__tests__/parse.test.ts +5 -1
  15. package/src/__tests__/publish.test.ts +556 -84
  16. package/src/__tests__/r2.test.ts +47 -24
  17. package/src/__tests__/secret.test.ts +39 -4
  18. package/src/abort.d.ts +3 -0
  19. package/src/bundle.ts +32 -1
  20. package/src/cfetch/index.ts +21 -4
  21. package/src/cfetch/internal.ts +14 -9
  22. package/src/config/environment.ts +40 -14
  23. package/src/config/index.ts +162 -0
  24. package/src/config/validation.ts +179 -64
  25. package/src/create-worker-preview.ts +17 -7
  26. package/src/create-worker-upload-form.ts +22 -8
  27. package/src/dev/dev.tsx +2 -4
  28. package/src/dev/local.tsx +6 -0
  29. package/src/dev/remote.tsx +15 -1
  30. package/src/dialogs.tsx +48 -0
  31. package/src/durable.ts +102 -0
  32. package/src/index.tsx +314 -144
  33. package/src/inspect.ts +39 -0
  34. package/src/kv.ts +77 -13
  35. package/src/open-in-browser.ts +5 -12
  36. package/src/package-manager.ts +50 -3
  37. package/src/pages.tsx +210 -65
  38. package/src/parse.ts +21 -4
  39. package/src/proxy.ts +38 -22
  40. package/src/publish.ts +227 -113
  41. package/src/sites.tsx +11 -9
  42. package/src/worker.ts +8 -0
  43. package/templates/new-worker-scheduled.js +17 -0
  44. package/templates/new-worker-scheduled.ts +32 -0
  45. package/templates/new-worker.ts +16 -1
  46. package/wrangler-dist/cli.js +35466 -22362
@@ -43,6 +43,7 @@ describe("normalizeAndValidateConfig()", () => {
43
43
  migrations: [],
44
44
  name: undefined,
45
45
  r2_buckets: [],
46
+ services: [],
46
47
  route: undefined,
47
48
  routes: undefined,
48
49
  rules: [],
@@ -60,6 +61,8 @@ describe("normalizeAndValidateConfig()", () => {
60
61
  data_blobs: undefined,
61
62
  workers_dev: undefined,
62
63
  zone_id: undefined,
64
+ minify: undefined,
65
+ node_compat: undefined,
63
66
  });
64
67
  expect(diagnostics.hasErrors()).toBe(false);
65
68
  expect(diagnostics.hasWarnings()).toBe(false);
@@ -162,68 +165,110 @@ describe("normalizeAndValidateConfig()", () => {
162
165
  `);
163
166
  });
164
167
 
165
- it("should override `migrations` config defaults with provided values", () => {
166
- const expectedConfig: RawConfig = {
167
- migrations: [
168
- {
169
- tag: "TAG",
170
- new_classes: ["CLASS_1", "CLASS_2"],
171
- renamed_classes: [
172
- {
173
- from: "FROM_CLASS",
174
- to: "TO_CLASS",
175
- },
176
- ],
177
- deleted_classes: ["CLASS_3", "CLASS_4"],
178
- },
179
- ],
180
- };
168
+ describe("migrations", () => {
169
+ it("should override `migrations` config defaults with provided values", () => {
170
+ const expectedConfig: RawConfig = {
171
+ migrations: [
172
+ {
173
+ tag: "TAG",
174
+ new_classes: ["CLASS_1", "CLASS_2"],
175
+ renamed_classes: [
176
+ {
177
+ from: "FROM_CLASS",
178
+ to: "TO_CLASS",
179
+ },
180
+ ],
181
+ deleted_classes: ["CLASS_3", "CLASS_4"],
182
+ },
183
+ ],
184
+ };
181
185
 
182
- const { config, diagnostics } = normalizeAndValidateConfig(
183
- expectedConfig,
184
- undefined,
185
- { env: undefined }
186
- );
186
+ const { config, diagnostics } = normalizeAndValidateConfig(
187
+ expectedConfig,
188
+ undefined,
189
+ { env: undefined }
190
+ );
187
191
 
188
- expect(config).toEqual(expect.objectContaining(expectedConfig));
189
- expect(diagnostics.hasErrors()).toBe(false);
190
- expect(diagnostics.hasWarnings()).toBe(false);
191
- });
192
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
193
+ expect(diagnostics.hasErrors()).toBe(false);
194
+ expect(diagnostics.hasWarnings()).toBe(false);
195
+ });
192
196
 
193
- it("should error on invalid `migrations` values", () => {
194
- const expectedConfig = {
195
- migrations: [
196
- {
197
- tag: 111,
198
- new_classes: [222, 333],
199
- renamed_classes: [
200
- {
201
- from: 444,
202
- to: 555,
203
- },
204
- ],
205
- deleted_classes: [666, 777],
206
- },
207
- ],
208
- };
197
+ it("should error on invalid `migrations` values", () => {
198
+ const expectedConfig = {
199
+ migrations: [
200
+ {
201
+ tag: 111,
202
+ new_classes: [222, 333],
203
+ renamed_classes: [
204
+ {
205
+ from: 444,
206
+ to: 555,
207
+ },
208
+ ],
209
+ deleted_classes: [666, 777],
210
+ },
211
+ ],
212
+ };
209
213
 
210
- const { config, diagnostics } = normalizeAndValidateConfig(
211
- expectedConfig as unknown as RawConfig,
212
- undefined,
213
- { env: undefined }
214
- );
214
+ const { config, diagnostics } = normalizeAndValidateConfig(
215
+ expectedConfig as unknown as RawConfig,
216
+ undefined,
217
+ { env: undefined }
218
+ );
215
219
 
216
- expect(config).toEqual(expect.objectContaining(expectedConfig));
217
- expect(diagnostics.hasWarnings()).toBe(false);
218
- expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
219
- "Processing wrangler configuration:
220
- - Expected \\"migrations[0].tag\\" to be of type string but got 111.
221
- - Expected \\"migrations[0].new_classes.[0]\\" to be of type string but got 222.
222
- - Expected \\"migrations[0].new_classes.[1]\\" to be of type string but got 333.
223
- - Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":444,\\"to\\":555}].
224
- - Expected \\"migrations[0].deleted_classes.[0]\\" to be of type string but got 666.
225
- - Expected \\"migrations[0].deleted_classes.[1]\\" to be of type string but got 777."
226
- `);
220
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
221
+ expect(diagnostics.hasWarnings()).toBe(false);
222
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
223
+ "Processing wrangler configuration:
224
+ - Expected \\"migrations[0].tag\\" to be of type string but got 111.
225
+ - Expected \\"migrations[0].new_classes.[0]\\" to be of type string but got 222.
226
+ - Expected \\"migrations[0].new_classes.[1]\\" to be of type string but got 333.
227
+ - Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":444,\\"to\\":555}].
228
+ - Expected \\"migrations[0].deleted_classes.[0]\\" to be of type string but got 666.
229
+ - Expected \\"migrations[0].deleted_classes.[1]\\" to be of type string but got 777."
230
+ `);
231
+ });
232
+
233
+ it("should warn/error on unexpected fields on `migrations`", async () => {
234
+ const expectedConfig = {
235
+ migrations: [
236
+ {
237
+ tag: "TAG",
238
+ new_classes: ["CLASS_1", "CLASS_2"],
239
+ renamed_classes: [
240
+ {
241
+ from: "FROM_CLASS",
242
+ to: "TO_CLASS",
243
+ },
244
+ {
245
+ a: "something",
246
+ b: "someone",
247
+ },
248
+ ],
249
+ deleted_classes: ["CLASS_3", "CLASS_4"],
250
+ unrecognized_field: "FOO",
251
+ },
252
+ ],
253
+ };
254
+
255
+ const { config, diagnostics } = normalizeAndValidateConfig(
256
+ expectedConfig as unknown as RawConfig,
257
+ undefined,
258
+ { env: undefined }
259
+ );
260
+
261
+ expect(config).toEqual(expect.objectContaining(expectedConfig));
262
+ expect(diagnostics.hasErrors()).toBe(true);
263
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
264
+ "Processing wrangler configuration:
265
+ - Unexpected fields found in migrations field: \\"unrecognized_field\\""
266
+ `);
267
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
268
+ "Processing wrangler configuration:
269
+ - Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":\\"FROM_CLASS\\",\\"to\\":\\"TO_CLASS\\"},{\\"a\\":\\"something\\",\\"b\\":\\"someone\\"}]."
270
+ `);
271
+ });
227
272
  });
228
273
 
229
274
  describe("site", () => {
@@ -620,6 +665,12 @@ describe("normalizeAndValidateConfig()", () => {
620
665
  class_name: "CLASS2",
621
666
  script_name: "SCRIPT2",
622
667
  },
668
+ {
669
+ name: "DO_BINDING_3",
670
+ class_name: "CLASS3",
671
+ script_name: "SCRIPT3",
672
+ environment: "ENV3",
673
+ },
623
674
  ],
624
675
  },
625
676
  kv_namespaces: [
@@ -638,6 +689,13 @@ describe("normalizeAndValidateConfig()", () => {
638
689
  preview_bucket_name: "R2_PREVIEW_2",
639
690
  },
640
691
  ],
692
+ services: [
693
+ {
694
+ binding: "SERVICE_BINDING_1",
695
+ service: "SERVICE_TYPE_1",
696
+ environment: "SERVICE_BINDING_ENVIRONMENT_1",
697
+ },
698
+ ],
641
699
  unsafe: {
642
700
  bindings: [
643
701
  { name: "UNSAFE_BINDING_1", type: "UNSAFE_TYPE_1" },
@@ -648,6 +706,8 @@ describe("normalizeAndValidateConfig()", () => {
648
706
  },
649
707
  ],
650
708
  },
709
+ minify: true,
710
+ node_compat: true,
651
711
  };
652
712
 
653
713
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -661,9 +721,19 @@ describe("normalizeAndValidateConfig()", () => {
661
721
  );
662
722
  expect(diagnostics.hasErrors()).toBe(false);
663
723
  expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
664
- "Processing wrangler configuration:
665
- - \\"unsafe\\" fields are experimental and may change or break at any time."
666
- `);
724
+ "Processing wrangler configuration:
725
+ - \\"unsafe\\" fields are experimental and may change or break at any time.
726
+ - \\"services\\" fields are experimental and may change or break at any time.
727
+ - In wrangler.toml, you have configured [durable_objects] exported by this Worker (CLASS1), but no [migrations] for them. This may not work as expected until you add a [migrations] section to your wrangler.toml. Add this configuration to your wrangler.toml:
728
+
729
+ \`\`\`
730
+ [[migrations]]
731
+ tag = \\"v1\\" # Should be unique for each entry
732
+ new_classes = [\\"CLASS1\\"]
733
+ \`\`\`
734
+
735
+ Refer to https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml for more details."
736
+ `);
667
737
  });
668
738
 
669
739
  it("should error on invalid environment values", () => {
@@ -705,6 +775,8 @@ describe("normalizeAndValidateConfig()", () => {
705
775
  cwd: 1555,
706
776
  watch_dir: 1666,
707
777
  },
778
+ minify: "INVALID",
779
+ node_compat: "INVALID",
708
780
  } as unknown as RawEnvironment;
709
781
 
710
782
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -717,8 +789,8 @@ describe("normalizeAndValidateConfig()", () => {
717
789
  expect(diagnostics.hasWarnings()).toBe(false);
718
790
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
719
791
  "Processing wrangler configuration:
720
- - Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
721
- - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
792
+ - Expected \\"route\\" to be either a string, or an object with shape { pattern, custom_domain, zone_id | zone_name }, but got 888.
793
+ - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, custom_domain, zone_id | zone_name }, but these weren't valid: [
722
794
  666,
723
795
  777,
724
796
  {
@@ -767,7 +839,9 @@ describe("normalizeAndValidateConfig()", () => {
767
839
  - Expected \\"tsconfig\\" to be of type string but got true.
768
840
  - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
769
841
  - Expected \\"main\\" to be of type string but got 1333.
770
- - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
842
+ - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
843
+ - Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
844
+ - Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
771
845
  `);
772
846
  });
773
847
 
@@ -1106,13 +1180,29 @@ describe("normalizeAndValidateConfig()", () => {
1106
1180
  durable_objects: {
1107
1181
  bindings: [
1108
1182
  {},
1109
- { name: "VALID" },
1183
+ { name: "MISSING_CLASS" },
1110
1184
  { name: 1555, class_name: 1666 },
1111
1185
  {
1112
1186
  name: 1777,
1113
1187
  class_name: 1888,
1114
1188
  script_name: 1999,
1115
1189
  },
1190
+ {
1191
+ name: "SOMENAME",
1192
+ class_name: "SomeClass",
1193
+ environment: "staging",
1194
+ },
1195
+ {
1196
+ name: 1778,
1197
+ class_name: 1889,
1198
+ script_name: 1992,
1199
+ environment: 2111,
1200
+ },
1201
+ {
1202
+ name: 1772,
1203
+ class_name: 1883,
1204
+ environment: 2112,
1205
+ },
1116
1206
  ],
1117
1207
  },
1118
1208
  } as unknown as RawConfig,
@@ -1126,6 +1216,8 @@ describe("normalizeAndValidateConfig()", () => {
1126
1216
  })
1127
1217
  );
1128
1218
  expect(diagnostics.hasWarnings()).toBe(false);
1219
+
1220
+ expect(diagnostics.hasErrors()).toBe(true);
1129
1221
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1130
1222
  "Processing wrangler configuration:
1131
1223
 
@@ -1133,7 +1225,7 @@ describe("normalizeAndValidateConfig()", () => {
1133
1225
  - binding should have a string \\"name\\" field.
1134
1226
  - binding should have a string \\"class_name\\" field.
1135
1227
 
1136
- - \\"durable_objects.bindings[1]\\": {\\"name\\":\\"VALID\\"}
1228
+ - \\"durable_objects.bindings[1]\\": {\\"name\\":\\"MISSING_CLASS\\"}
1137
1229
  - binding should have a string \\"class_name\\" field.
1138
1230
 
1139
1231
  - \\"durable_objects.bindings[2]\\": {\\"name\\":1555,\\"class_name\\":1666}
@@ -1143,7 +1235,22 @@ describe("normalizeAndValidateConfig()", () => {
1143
1235
  - \\"durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
1144
1236
  - binding should have a string \\"name\\" field.
1145
1237
  - binding should have a string \\"class_name\\" field.
1146
- - binding should, optionally, have a string \\"script_name\\" field."
1238
+ - the field \\"script_name\\", when present, should be a string.
1239
+
1240
+ - \\"durable_objects.bindings[4]\\": {\\"name\\":\\"SOMENAME\\",\\"class_name\\":\\"SomeClass\\",\\"environment\\":\\"staging\\"}
1241
+ - binding should have a \\"script_name\\" field if \\"environment\\" is present.
1242
+
1243
+ - \\"durable_objects.bindings[5]\\": {\\"name\\":1778,\\"class_name\\":1889,\\"script_name\\":1992,\\"environment\\":2111}
1244
+ - binding should have a string \\"name\\" field.
1245
+ - binding should have a string \\"class_name\\" field.
1246
+ - the field \\"script_name\\", when present, should be a string.
1247
+ - the field \\"environment\\", when present, should be a string.
1248
+
1249
+ - \\"durable_objects.bindings[6]\\": {\\"name\\":1772,\\"class_name\\":1883,\\"environment\\":2112}
1250
+ - binding should have a string \\"name\\" field.
1251
+ - binding should have a string \\"class_name\\" field.
1252
+ - the field \\"environment\\", when present, should be a string.
1253
+ - binding should have a \\"script_name\\" field if \\"environment\\" is present."
1147
1254
  `);
1148
1255
  });
1149
1256
  });
@@ -1358,6 +1465,151 @@ describe("normalizeAndValidateConfig()", () => {
1358
1465
  });
1359
1466
  });
1360
1467
 
1468
+ describe("services field", () => {
1469
+ it("should error if services is an object", () => {
1470
+ const { config, diagnostics } = normalizeAndValidateConfig(
1471
+ { services: {} } as unknown as RawConfig,
1472
+ undefined,
1473
+ { env: undefined }
1474
+ );
1475
+
1476
+ expect(config).toEqual(
1477
+ expect.not.objectContaining({ services: expect.anything })
1478
+ );
1479
+ expect(diagnostics.hasWarnings()).toBe(true);
1480
+ expect(diagnostics.hasErrors()).toBe(true);
1481
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1482
+ "Processing wrangler configuration:
1483
+ - \\"services\\" fields are experimental and may change or break at any time."
1484
+ `);
1485
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1486
+ "Processing wrangler configuration:
1487
+ - The field \\"services\\" should be an array but got {}."
1488
+ `);
1489
+ });
1490
+
1491
+ it("should error if services is a string", () => {
1492
+ const { config, diagnostics } = normalizeAndValidateConfig(
1493
+ { services: "BAD" } as unknown as RawConfig,
1494
+ undefined,
1495
+ { env: undefined }
1496
+ );
1497
+
1498
+ expect(config).toEqual(
1499
+ expect.not.objectContaining({ services: expect.anything })
1500
+ );
1501
+ expect(diagnostics.hasWarnings()).toBe(true);
1502
+ expect(diagnostics.hasErrors()).toBe(true);
1503
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1504
+ "Processing wrangler configuration:
1505
+ - \\"services\\" fields are experimental and may change or break at any time."
1506
+ `);
1507
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1508
+ "Processing wrangler configuration:
1509
+ - The field \\"services\\" should be an array but got \\"BAD\\"."
1510
+ `);
1511
+ });
1512
+
1513
+ it("should error if services is a number", () => {
1514
+ const { config, diagnostics } = normalizeAndValidateConfig(
1515
+ { services: 999 } as unknown as RawConfig,
1516
+ undefined,
1517
+ { env: undefined }
1518
+ );
1519
+
1520
+ expect(config).toEqual(
1521
+ expect.not.objectContaining({ services: expect.anything })
1522
+ );
1523
+ expect(diagnostics.hasWarnings()).toBe(true);
1524
+ expect(diagnostics.hasErrors()).toBe(true);
1525
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1526
+ "Processing wrangler configuration:
1527
+ - \\"services\\" fields are experimental and may change or break at any time."
1528
+ `);
1529
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1530
+ "Processing wrangler configuration:
1531
+ - The field \\"services\\" should be an array but got 999."
1532
+ `);
1533
+ });
1534
+
1535
+ it("should error if services is null", () => {
1536
+ const { config, diagnostics } = normalizeAndValidateConfig(
1537
+ { services: null } as unknown as RawConfig,
1538
+ undefined,
1539
+ { env: undefined }
1540
+ );
1541
+
1542
+ expect(config).toEqual(
1543
+ expect.not.objectContaining({ services: expect.anything })
1544
+ );
1545
+ expect(diagnostics.hasWarnings()).toBe(true);
1546
+ expect(diagnostics.hasErrors()).toBe(true);
1547
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1548
+ "Processing wrangler configuration:
1549
+ - \\"services\\" fields are experimental and may change or break at any time."
1550
+ `);
1551
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1552
+ "Processing wrangler configuration:
1553
+ - The field \\"services\\" should be an array but got null."
1554
+ `);
1555
+ });
1556
+
1557
+ it("should error if services bindings are not valid", () => {
1558
+ const { config, diagnostics } = normalizeAndValidateConfig(
1559
+ {
1560
+ services: [
1561
+ {},
1562
+ { binding: "SERVICE_BINDING_1" },
1563
+ { binding: 123, service: 456 },
1564
+ { binding: 123, service: 456, environment: 789 },
1565
+ { binding: "SERVICE_BINDING_1", service: 456, environment: 789 },
1566
+ {
1567
+ binding: 123,
1568
+ service: "SERVICE_BINDING_SERVICE_1",
1569
+ environment: 789,
1570
+ },
1571
+ {
1572
+ binding: 123,
1573
+ service: 456,
1574
+ environment: "SERVICE_BINDING_ENVIRONMENT_1",
1575
+ },
1576
+ ],
1577
+ } as unknown as RawConfig,
1578
+ undefined,
1579
+ { env: undefined }
1580
+ );
1581
+
1582
+ expect(config).toEqual(
1583
+ expect.not.objectContaining({
1584
+ services: { bindings: expect.anything },
1585
+ })
1586
+ );
1587
+ expect(diagnostics.hasWarnings()).toBe(true);
1588
+ expect(diagnostics.hasErrors()).toBe(true);
1589
+ expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
1590
+ "Processing wrangler configuration:
1591
+ - \\"services\\" fields are experimental and may change or break at any time."
1592
+ `);
1593
+ expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
1594
+ "Processing wrangler configuration:
1595
+ - \\"services[0]\\" bindings should have a string \\"binding\\" field but got {}.
1596
+ - \\"services[0]\\" bindings should have a string \\"service\\" field but got {}.
1597
+ - \\"services[1]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\"}.
1598
+ - \\"services[2]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456}.
1599
+ - \\"services[2]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456}.
1600
+ - \\"services[3]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
1601
+ - \\"services[3]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
1602
+ - \\"services[3]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":789}.
1603
+ - \\"services[4]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\",\\"service\\":456,\\"environment\\":789}.
1604
+ - \\"services[4]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":\\"SERVICE_BINDING_1\\",\\"service\\":456,\\"environment\\":789}.
1605
+ - \\"services[5]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":\\"SERVICE_BINDING_SERVICE_1\\",\\"environment\\":789}.
1606
+ - \\"services[5]\\" bindings should have a string \\"environment\\" field but got {\\"binding\\":123,\\"service\\":\\"SERVICE_BINDING_SERVICE_1\\",\\"environment\\":789}.
1607
+ - \\"services[6]\\" bindings should have a string \\"binding\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":\\"SERVICE_BINDING_ENVIRONMENT_1\\"}.
1608
+ - \\"services[6]\\" bindings should have a string \\"service\\" field but got {\\"binding\\":123,\\"service\\":456,\\"environment\\":\\"SERVICE_BINDING_ENVIRONMENT_1\\"}."
1609
+ `);
1610
+ });
1611
+ });
1612
+
1361
1613
  describe("unsafe field", () => {
1362
1614
  it("should error if unsafe is an array", () => {
1363
1615
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -1622,14 +1874,7 @@ describe("normalizeAndValidateConfig()", () => {
1622
1874
  - Deprecation: \\"zone_id\\":
1623
1875
  This is unnecessary since we can deduce this from routes directly.
1624
1876
  - Deprecation: \\"experimental_services\\":
1625
- The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
1626
- \`\`\`
1627
- [[unsafe.bindings]]
1628
- name = \\"mock-name\\"
1629
- type = \\"service\\"
1630
- service = \\"SERVICE\\"
1631
- environment = \\"ENV\\"
1632
- \`\`\`"
1877
+ The \\"experimental_services\\" field is no longer supported. Simply rename the [experimental_services] field to [services]."
1633
1878
  `);
1634
1879
  });
1635
1880
  });
@@ -1722,6 +1967,8 @@ describe("normalizeAndValidateConfig()", () => {
1722
1967
  cwd: "CWD",
1723
1968
  watch_dir: "WATCH_DIR",
1724
1969
  },
1970
+ minify: true,
1971
+ node_compat: true,
1725
1972
  };
1726
1973
 
1727
1974
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -1762,6 +2009,8 @@ describe("normalizeAndValidateConfig()", () => {
1762
2009
  cwd: "ENV_CWD",
1763
2010
  watch_dir: "ENV_WATCH_DIR",
1764
2011
  },
2012
+ minify: false,
2013
+ node_compat: false,
1765
2014
  };
1766
2015
  const rawConfig: RawConfig = {
1767
2016
  name: "mock-name",
@@ -1781,6 +2030,8 @@ describe("normalizeAndValidateConfig()", () => {
1781
2030
  cwd: "CWD",
1782
2031
  watch_dir: "WATCH_DIR",
1783
2032
  },
2033
+ minify: true,
2034
+ node_compat: true,
1784
2035
  env: {
1785
2036
  ENV1: rawEnv,
1786
2037
  },
@@ -2031,6 +2282,8 @@ describe("normalizeAndValidateConfig()", () => {
2031
2282
  cwd: 1555,
2032
2283
  watch_dir: 1666,
2033
2284
  },
2285
+ minify: "INVALID",
2286
+ node_compat: "INVALID",
2034
2287
  } as unknown as RawEnvironment;
2035
2288
 
2036
2289
  const { config, diagnostics } = normalizeAndValidateConfig(
@@ -2045,8 +2298,8 @@ describe("normalizeAndValidateConfig()", () => {
2045
2298
  "Processing wrangler configuration:
2046
2299
 
2047
2300
  - \\"env.ENV1\\" environment configuration
2048
- - Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
2049
- - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
2301
+ - Expected \\"route\\" to be either a string, or an object with shape { pattern, custom_domain, zone_id | zone_name }, but got 888.
2302
+ - Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, custom_domain, zone_id | zone_name }, but these weren't valid: [
2050
2303
  666,
2051
2304
  777
2052
2305
  ].
@@ -2063,7 +2316,9 @@ describe("normalizeAndValidateConfig()", () => {
2063
2316
  - Expected \\"tsconfig\\" to be of type string but got 123.
2064
2317
  - Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
2065
2318
  - Expected \\"main\\" to be of type string but got 1333.
2066
- - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
2319
+ - Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
2320
+ - Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
2321
+ - Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
2067
2322
  `);
2068
2323
  });
2069
2324
 
@@ -2285,6 +2540,7 @@ describe("normalizeAndValidateConfig()", () => {
2285
2540
  })
2286
2541
  );
2287
2542
  expect(diagnostics.hasWarnings()).toBe(false);
2543
+ expect(diagnostics.hasErrors()).toBe(true);
2288
2544
  expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
2289
2545
  "Processing wrangler configuration:
2290
2546
 
@@ -2304,7 +2560,7 @@ describe("normalizeAndValidateConfig()", () => {
2304
2560
  - \\"env.ENV1.durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
2305
2561
  - binding should have a string \\"name\\" field.
2306
2562
  - binding should have a string \\"class_name\\" field.
2307
- - binding should, optionally, have a string \\"script_name\\" field."
2563
+ - the field \\"script_name\\", when present, should be a string."
2308
2564
  `);
2309
2565
  });
2310
2566
  });
@@ -2869,14 +3125,7 @@ describe("normalizeAndValidateConfig()", () => {
2869
3125
  - Deprecation: \\"zone_id\\":
2870
3126
  This is unnecessary since we can deduce this from routes directly.
2871
3127
  - Deprecation: \\"experimental_services\\":
2872
- The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
2873
- \`\`\`
2874
- [[unsafe.bindings]]
2875
- name = \\"mock-name\\"
2876
- type = \\"service\\"
2877
- service = \\"SERVICE\\"
2878
- environment = \\"ENV\\"
2879
- \`\`\`"
3128
+ The \\"experimental_services\\" field is no longer supported. Simply rename the [experimental_services] field to [services]."
2880
3129
  `);
2881
3130
  });
2882
3131
  });