wrangler 2.12.0 → 2.12.2

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.
@@ -69,7 +69,7 @@ describe("deployment create", () => {
69
69
  --commit-message The commit message to attach to this deployment [string]
70
70
  --commit-dirty Whether or not the workspace should be considered dirty for this deployment [boolean]
71
71
  --skip-caching Skip asset caching which speeds up builds [boolean]
72
- --no-bundle Whether to run bundling on \`_worker.js\` before deploying [boolean] [default: true]
72
+ --no-bundle Whether to run bundling on \`_worker.js\` before deploying [boolean] [default: false]
73
73
 
74
74
  🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose"
75
75
  `);
@@ -1116,10 +1116,10 @@ describe("deployment create", () => {
1116
1116
  const body = await (req as RestRequestWithFormData).formData();
1117
1117
  const manifest = JSON.parse(body.get("manifest") as string);
1118
1118
 
1119
- // for Functions projects, we auto-generate a `_worker.js`,
1119
+ // for Functions projects, we auto-generate a `_worker.bundle`,
1120
1120
  // `functions-filepath-routing-config.json`, and `_routes.json`
1121
1121
  // file, based on the contents of `/functions`
1122
- const generatedWorkerJS = body.get("_worker.js") as string;
1122
+ const generatedWorkerBundle = body.get("_worker.bundle") as string;
1123
1123
  const generatedRoutesJSON = body.get("_routes.json") as string;
1124
1124
  const generatedFilepathRoutingConfig = body.get(
1125
1125
  "functions-filepath-routing-config.json"
@@ -1129,7 +1129,7 @@ describe("deployment create", () => {
1129
1129
  expect([...body.keys()]).toEqual([
1130
1130
  "manifest",
1131
1131
  "functions-filepath-routing-config.json",
1132
- "_worker.js",
1132
+ "_worker.bundle",
1133
1133
  "_routes.json",
1134
1134
  ]);
1135
1135
 
@@ -1139,14 +1139,14 @@ describe("deployment create", () => {
1139
1139
  }
1140
1140
  `);
1141
1141
 
1142
- // the contents of the generated `_worker.js` file is pretty massive, so I don't
1142
+ // the contents of the generated `_worker.bundle` file is pretty massive, so I don't
1143
1143
  // think snapshot testing makes much sense here. Plus, calling
1144
1144
  // `.toMatchInlineSnapshot()` without any arguments, in order to generate that
1145
1145
  // snapshot value, doesn't generate anything in this case (probably because the
1146
- // file contents is too big). So for now, let's test that _worker.js was indeed
1146
+ // file contents is too big). So for now, let's test that _worker.bundle was indeed
1147
1147
  // generated and that the file size is greater than zero
1148
- expect(generatedWorkerJS).not.toBeNull();
1149
- expect(generatedWorkerJS.length).toBeGreaterThan(0);
1148
+ expect(generatedWorkerBundle).not.toBeNull();
1149
+ expect(generatedWorkerBundle.length).toBeGreaterThan(0);
1150
1150
 
1151
1151
  const maybeRoutesJSONSpec = JSON.parse(generatedRoutesJSON);
1152
1152
  expect(isRoutesJSONSpec(maybeRoutesJSONSpec)).toBe(true);
@@ -1215,7 +1215,7 @@ describe("deployment create", () => {
1215
1215
  "✨ Compiled Worker successfully
1216
1216
  ✨ Success! Uploaded 1 files (TIMINGS)
1217
1217
 
1218
- ✨ Uploading Functions
1218
+ ✨ Uploading Functions bundle
1219
1219
  ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
1220
1220
  `);
1221
1221
 
@@ -1301,11 +1301,11 @@ describe("deployment create", () => {
1301
1301
  expect(req.params.accountId).toEqual("some-account-id");
1302
1302
  const body = await (req as RestRequestWithFormData).formData();
1303
1303
  const manifest = JSON.parse(body.get("manifest") as string);
1304
- const customWorkerJS = body.get("_worker.js");
1304
+ const workerBundle = body.get("_worker.bundle");
1305
1305
 
1306
1306
  // make sure this is all we uploaded
1307
1307
  expect([...body.keys()].sort()).toEqual(
1308
- ["manifest", "_worker.js"].sort()
1308
+ ["manifest", "_worker.bundle"].sort()
1309
1309
  );
1310
1310
 
1311
1311
  expect(manifest).toMatchInlineSnapshot(`
@@ -1314,8 +1314,8 @@ describe("deployment create", () => {
1314
1314
  }
1315
1315
  `);
1316
1316
 
1317
- expect(workerHasD1Shim(customWorkerJS as string)).toBeTruthy();
1318
- expect(customWorkerJS).toContain(
1317
+ expect(workerHasD1Shim(workerBundle as string)).toBeTruthy();
1318
+ expect(workerBundle).toContain(
1319
1319
  `console.log("SOMETHING FROM WITHIN THE WORKER");`
1320
1320
  );
1321
1321
 
@@ -1359,13 +1359,13 @@ describe("deployment create", () => {
1359
1359
  )
1360
1360
  );
1361
1361
 
1362
- await runWrangler("pages publish public --project-name=foo --bundle");
1362
+ await runWrangler("pages publish public --project-name=foo");
1363
1363
 
1364
1364
  expect(std.out).toMatchInlineSnapshot(`
1365
1365
  "✨ Success! Uploaded 1 files (TIMINGS)
1366
1366
 
1367
1367
  ✨ Compiled Worker successfully
1368
- ✨ Uploading _worker.js
1368
+ ✨ Uploading Worker bundle
1369
1369
  ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
1370
1370
  `);
1371
1371
 
@@ -1489,7 +1489,7 @@ describe("deployment create", () => {
1489
1489
  expect(req.params.accountId).toEqual("some-account-id");
1490
1490
  const body = await (req as RestRequestWithFormData).formData();
1491
1491
  const manifest = JSON.parse(body.get("manifest") as string);
1492
- const generatedWorkerJS = body.get("_worker.js") as string;
1492
+ const generatedWorkerBundle = body.get("_worker.bundle") as string;
1493
1493
  const customRoutesJSON = body.get("_routes.json") as string;
1494
1494
  const generatedFilepathRoutingConfig = body.get(
1495
1495
  "functions-filepath-routing-config.json"
@@ -1500,7 +1500,7 @@ describe("deployment create", () => {
1500
1500
  [
1501
1501
  "manifest",
1502
1502
  "functions-filepath-routing-config.json",
1503
- "_worker.js",
1503
+ "_worker.bundle",
1504
1504
  "_routes.json",
1505
1505
  ].sort()
1506
1506
  );
@@ -1511,9 +1511,9 @@ describe("deployment create", () => {
1511
1511
  }
1512
1512
  `);
1513
1513
 
1514
- // file content of generated `_worker.js` is too massive to snapshot test
1515
- expect(generatedWorkerJS).not.toBeNull();
1516
- expect(generatedWorkerJS.length).toBeGreaterThan(0);
1514
+ // file content of generated `_worker.bundle` is too massive to snapshot test
1515
+ expect(generatedWorkerBundle).not.toBeNull();
1516
+ expect(generatedWorkerBundle.length).toBeGreaterThan(0);
1517
1517
 
1518
1518
  const customRoutes = JSON.parse(customRoutesJSON);
1519
1519
  expect(customRoutes).toMatchObject({
@@ -1587,7 +1587,7 @@ describe("deployment create", () => {
1587
1587
  "✨ Compiled Worker successfully
1588
1588
  ✨ Success! Uploaded 1 files (TIMINGS)
1589
1589
 
1590
- ✨ Uploading Functions
1590
+ ✨ Uploading Functions bundle
1591
1591
  ✨ Uploading _routes.json
1592
1592
  ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
1593
1593
  `);
@@ -1821,13 +1821,13 @@ and that at least one include rule is provided.
1821
1821
  const body = await (req as RestRequestWithFormData).formData();
1822
1822
 
1823
1823
  const manifest = JSON.parse(body.get("manifest") as string);
1824
- const customWorkerJS = body.get("_worker.js") as string;
1824
+ const workerBundle = body.get("_worker.bundle") as string;
1825
1825
  const customRoutesJSON = body.get("_routes.json") as string;
1826
1826
 
1827
1827
  // make sure this is all we uploaded
1828
1828
  expect([...body.keys()]).toEqual([
1829
1829
  "manifest",
1830
- "_worker.js",
1830
+ "_worker.bundle",
1831
1831
  "_routes.json",
1832
1832
  ]);
1833
1833
  expect(req.params.accountId).toEqual("some-account-id");
@@ -1837,15 +1837,45 @@ and that at least one include rule is provided.
1837
1837
  }
1838
1838
  `);
1839
1839
 
1840
- expect(customWorkerJS).toMatchInlineSnapshot(`
1841
- "
1842
- export default {
1843
- async fetch(request, env) {
1844
- const url = new URL(request.url);
1845
- return url.pathname.startsWith('/api/') ? new Response('Ok') : env.ASSETS.fetch(request);
1846
- }
1847
- };
1848
- "
1840
+ // some fields in workerBundle, such as the undici form boundary
1841
+ // or the file hashes, are randomly generated. Let's replace these
1842
+ // dynamic values with static ones so we can properly test the
1843
+ // contents of `workerBundle`
1844
+ // see https://jestjs.io/docs/snapshot-testing#property-matchers
1845
+ let workerBundleWithConstantData = workerBundle.replace(
1846
+ /------formdata-undici-0.[0-9]*/g,
1847
+ "------formdata-undici-0.test"
1848
+ );
1849
+ workerBundleWithConstantData = workerBundleWithConstantData.replace(
1850
+ /bundledWorker-0.[0-9]*.mjs/g,
1851
+ "bundledWorker-0.test.mjs"
1852
+ );
1853
+
1854
+ // we care about a couple of things here, like the presence of `metadata`,
1855
+ // `bundledWorker`, the wasm import, etc., and since `workerBundle` is
1856
+ // small enough, let's go ahead and snapshot test the whole thing
1857
+ expect(workerBundleWithConstantData).toMatchInlineSnapshot(`
1858
+ "------formdata-undici-0.test
1859
+ Content-Disposition: form-data; name=\\"metadata\\"
1860
+
1861
+ {\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
1862
+ ------formdata-undici-0.test
1863
+ Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
1864
+ Content-Type: application/javascript+module
1865
+
1866
+ // _worker.js
1867
+ var worker_default = {
1868
+ async fetch(request, env) {
1869
+ const url = new URL(request.url);
1870
+ return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
1871
+ }
1872
+ };
1873
+ export {
1874
+ worker_default as default
1875
+ };
1876
+ //# sourceMappingURL=bundledWorker-0.test.mjs.map
1877
+
1878
+ ------formdata-undici-0.test--"
1849
1879
  `);
1850
1880
 
1851
1881
  expect(JSON.parse(customRoutesJSON)).toMatchObject({
@@ -1894,7 +1924,7 @@ and that at least one include rule is provided.
1894
1924
  "✨ Success! Uploaded 1 files (TIMINGS)
1895
1925
 
1896
1926
  ✨ Compiled Worker successfully
1897
- ✨ Uploading _worker.js
1927
+ ✨ Uploading Worker bundle
1898
1928
  ✨ Uploading _routes.json
1899
1929
  ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
1900
1930
  `);
@@ -2110,27 +2140,58 @@ and that at least one include rule is provided.
2110
2140
  async (req, res, ctx) => {
2111
2141
  const body = await (req as RestRequestWithFormData).formData();
2112
2142
  const manifest = JSON.parse(body.get("manifest") as string);
2113
- const customWorkerJS = body.get("_worker.js");
2143
+ const customWorkerBundle = body.get("_worker.bundle") as string;
2114
2144
 
2115
2145
  expect(req.params.accountId).toEqual("some-account-id");
2116
2146
  // make sure this is all we uploaded
2117
2147
  expect([...body.keys()].sort()).toEqual(
2118
- ["manifest", "_worker.js"].sort()
2148
+ ["manifest", "_worker.bundle"].sort()
2119
2149
  );
2120
2150
  expect(manifest).toMatchInlineSnapshot(`
2121
2151
  Object {
2122
2152
  "/README.md": "13a03eaf24ae98378acd36ea00f77f2f",
2123
2153
  }
2124
2154
  `);
2125
- expect(customWorkerJS).toMatchInlineSnapshot(`
2126
- "
2127
- export default {
2128
- async fetch(request, env) {
2129
- const url = new URL(request.url);
2130
- return url.pathname.startsWith('/api/') ? new Response('Ok') : env.ASSETS.fetch(request);
2131
- }
2132
- };
2133
- "
2155
+
2156
+ // some fields in workerBundle, such as the undici form boundary
2157
+ // or the file hashes, are randomly generated. Let's replace these
2158
+ // dynamic values with static ones so we can properly test the
2159
+ // contents of `workerBundle`
2160
+ // see https://jestjs.io/docs/snapshot-testing#property-matchers
2161
+ let workerBundleWithConstantData = customWorkerBundle.replace(
2162
+ /------formdata-undici-0.[0-9]*/g,
2163
+ "------formdata-undici-0.test"
2164
+ );
2165
+ workerBundleWithConstantData = workerBundleWithConstantData.replace(
2166
+ /bundledWorker-0.[0-9]*.mjs/g,
2167
+ "bundledWorker-0.test.mjs"
2168
+ );
2169
+
2170
+ // we care about a couple of things here, like the presence of `metadata`,
2171
+ // `bundledWorker`, the wasm import, etc., and since `workerBundle` is
2172
+ // small enough, let's go ahead and snapshot test the whole thing
2173
+ expect(workerBundleWithConstantData).toMatchInlineSnapshot(`
2174
+ "------formdata-undici-0.test
2175
+ Content-Disposition: form-data; name=\\"metadata\\"
2176
+
2177
+ {\\"main_module\\":\\"bundledWorker-0.test.mjs\\"}
2178
+ ------formdata-undici-0.test
2179
+ Content-Disposition: form-data; name=\\"bundledWorker-0.test.mjs\\"; filename=\\"bundledWorker-0.test.mjs\\"
2180
+ Content-Type: application/javascript+module
2181
+
2182
+ // _worker.js
2183
+ var worker_default = {
2184
+ async fetch(request, env) {
2185
+ const url = new URL(request.url);
2186
+ return url.pathname.startsWith(\\"/api/\\") ? new Response(\\"Ok\\") : env.ASSETS.fetch(request);
2187
+ }
2188
+ };
2189
+ export {
2190
+ worker_default as default
2191
+ };
2192
+ //# sourceMappingURL=bundledWorker-0.test.mjs.map
2193
+
2194
+ ------formdata-undici-0.test--"
2134
2195
  `);
2135
2196
 
2136
2197
  return res.once(
@@ -2172,14 +2233,14 @@ and that at least one include rule is provided.
2172
2233
  "✨ Success! Uploaded 1 files (TIMINGS)
2173
2234
 
2174
2235
  ✨ Compiled Worker successfully
2175
- ✨ Uploading _worker.js
2236
+ ✨ Uploading Worker bundle
2176
2237
  ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
2177
2238
  `);
2178
2239
 
2179
2240
  expect(std.err).toMatchInlineSnapshot('""');
2180
2241
  });
2181
2242
 
2182
- it("should bundle Functions and resolve its external module imports if the `--experimental-worker-bundle` flag is set", async () => {
2243
+ it("should bundle Functions and resolve its external module imports", async () => {
2183
2244
  // set up the directory of static files to upload.
2184
2245
  mkdirSync("public");
2185
2246
  writeFileSync("public/README.md", "This is a readme");
@@ -2364,9 +2425,7 @@ async function onRequest() {
2364
2425
  )
2365
2426
  );
2366
2427
 
2367
- await runWrangler(
2368
- "pages publish public --project-name=foo --experimental-worker-bundle=true"
2369
- );
2428
+ await runWrangler("pages publish public --project-name=foo");
2370
2429
 
2371
2430
  expect(std.out).toMatchInlineSnapshot(`
2372
2431
  "✨ Compiled Worker successfully
@@ -2380,7 +2439,7 @@ async function onRequest() {
2380
2439
  expect(std.err).toMatchInlineSnapshot('""');
2381
2440
  });
2382
2441
 
2383
- it("should bundle _worker.js and resolve its external module imports if the `--experimental-worker-bundle` flag is set", async () => {
2442
+ it("should bundle _worker.js and resolve its external module imports", async () => {
2384
2443
  // set up the directory of static files to upload
2385
2444
  mkdirSync("public");
2386
2445
  writeFileSync("public/README.md", "This is a readme");
@@ -2570,9 +2629,7 @@ async function onRequest() {
2570
2629
  )
2571
2630
  );
2572
2631
 
2573
- await runWrangler(
2574
- "pages publish public --project-name=foo --experimental-worker-bundle=true"
2575
- );
2632
+ await runWrangler("pages publish public --project-name=foo");
2576
2633
 
2577
2634
  expect(std.out).toMatchInlineSnapshot(`
2578
2635
  "✨ Success! Uploaded 1 files (TIMINGS)
@@ -2605,7 +2662,7 @@ async function onRequest() {
2605
2662
  contents.includes("worker_default as default");
2606
2663
 
2607
2664
  const simulateServer = (
2608
- generatedWorkerJsCheck: (workerJsContent: string) => void
2665
+ generatedWorkerBundleCheck: (workerJsContent: string) => void
2609
2666
  ) => {
2610
2667
  mockGetUploadTokenRequest(
2611
2668
  "<<funfetti-auth-jwt>>",
@@ -2639,9 +2696,9 @@ async function onRequest() {
2639
2696
  "*/accounts/:accountId/pages/projects/foo/deployments",
2640
2697
  async (req, res, ctx) => {
2641
2698
  const body = await (req as RestRequestWithFormData).formData();
2642
- const generatedWorkerJS = body.get("_worker.js") as string;
2699
+ const generatedWorkerBundle = body.get("_worker.bundle") as string;
2643
2700
 
2644
- generatedWorkerJsCheck(generatedWorkerJS);
2701
+ generatedWorkerBundleCheck(generatedWorkerBundle);
2645
2702
 
2646
2703
  return res.once(
2647
2704
  ctx.status(200),
@@ -2674,12 +2731,30 @@ async function onRequest() {
2674
2731
  );
2675
2732
  };
2676
2733
 
2677
- it("should not bundle the _worker.js when both `--bundle` and `--no-bundle` are omitted", async () => {
2734
+ it("should bundle the _worker.js when both `--bundle` and `--no-bundle` are omitted", async () => {
2678
2735
  simulateServer((generatedWorkerJS) =>
2679
- expect(workerIsBundled(generatedWorkerJS)).toBeFalsy()
2736
+ expect(workerIsBundled(generatedWorkerJS)).toBeTruthy()
2680
2737
  );
2681
2738
  await runWrangler("pages publish public --project-name=foo");
2682
- expect(std.out).toContain("✨ Uploading _worker.js");
2739
+ expect(std.out).toContain("✨ Uploading Worker bundle");
2740
+ });
2741
+
2742
+ it("should not bundle the _worker.js when `--no-bundle` is set", async () => {
2743
+ simulateServer((generatedWorkerJS) =>
2744
+ expect(workerIsBundled(generatedWorkerJS)).toBeFalsy()
2745
+ );
2746
+ await runWrangler("pages publish public --project-name=foo --no-bundle");
2747
+ expect(std.out).toContain("✨ Uploading Worker bundle");
2748
+ });
2749
+
2750
+ it("should not bundle the _worker.js when `--bundle` is set to false", async () => {
2751
+ simulateServer((generatedWorkerJS) =>
2752
+ expect(workerIsBundled(generatedWorkerJS)).toBeFalsy()
2753
+ );
2754
+ await runWrangler(
2755
+ "pages publish public --project-name=foo --bundle=false"
2756
+ );
2757
+ expect(std.out).toContain("✨ Uploading Worker bundle");
2683
2758
  });
2684
2759
 
2685
2760
  it("should bundle the _worker.js when the `--no-bundle` is set to false", async () => {
@@ -2689,7 +2764,7 @@ async function onRequest() {
2689
2764
  await runWrangler(
2690
2765
  "pages publish public --no-bundle=false --project-name=foo"
2691
2766
  );
2692
- expect(std.out).toContain("✨ Uploading _worker.js");
2767
+ expect(std.out).toContain("✨ Uploading Worker bundle");
2693
2768
  });
2694
2769
 
2695
2770
  it("should bundle the _worker.js when the `--bundle` is set to true", async () => {
@@ -2699,7 +2774,7 @@ async function onRequest() {
2699
2774
  await runWrangler(
2700
2775
  "pages publish public --bundle=true --project-name=foo"
2701
2776
  );
2702
- expect(std.out).toContain("✨ Uploading _worker.js");
2777
+ expect(std.out).toContain("✨ Uploading Worker bundle");
2703
2778
  });
2704
2779
  });
2705
2780
  });
@@ -326,7 +326,7 @@ describe("publish", () => {
326
326
  await expect(runWrangler("publish index.js")).rejects.toThrowError();
327
327
 
328
328
  expect(std.err).toMatchInlineSnapshot(`
329
- "X [ERROR] In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/api/tokens/create/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.
329
+ "X [ERROR] In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.
330
330
 
331
331
  "
332
332
  `);
@@ -1649,7 +1649,7 @@ addEventListener('fetch', event => {});`
1649
1649
  };
1650
1650
  writeAssets(assets);
1651
1651
  mockUploadWorkerRequest({
1652
- expectedMainModule: "serve-static-assets.entry.js",
1652
+ expectedMainModule: "no-op-worker.js",
1653
1653
  });
1654
1654
  mockSubDomainRequest();
1655
1655
  mockListKVNamespacesRequest(kvNamespace);
@@ -1740,7 +1740,7 @@ addEventListener('fetch', event => {});`
1740
1740
  writeWorkerSource();
1741
1741
  writeAssets(assets);
1742
1742
  mockUploadWorkerRequest({
1743
- expectedMainModule: "serve-static-assets.entry.js",
1743
+ expectedMainModule: "index.js",
1744
1744
  });
1745
1745
  mockSubDomainRequest();
1746
1746
  mockListKVNamespacesRequest(kvNamespace);
@@ -1925,7 +1925,7 @@ addEventListener('fetch', event => {});`
1925
1925
  writeWorkerSource();
1926
1926
  writeAssets(assets);
1927
1927
  mockUploadWorkerRequest({
1928
- expectedMainModule: "serve-static-assets.entry.js",
1928
+ expectedMainModule: "index.js",
1929
1929
  });
1930
1930
  mockSubDomainRequest();
1931
1931
  mockListKVNamespacesRequest(kvNamespace);
@@ -1972,7 +1972,7 @@ addEventListener('fetch', event => {});`
1972
1972
  writeWorkerSource();
1973
1973
  writeAssets(assets);
1974
1974
  mockUploadWorkerRequest({
1975
- expectedMainModule: "serve-static-assets.entry.js",
1975
+ expectedMainModule: "index.js",
1976
1976
  });
1977
1977
  mockSubDomainRequest();
1978
1978
  mockListKVNamespacesRequest(kvNamespace);
@@ -3015,7 +3015,7 @@ addEventListener('fetch', event => {});`
3015
3015
  writeWorkerSource();
3016
3016
  writeAssets(assets, "my-assets");
3017
3017
  mockUploadWorkerRequest({
3018
- expectedMainModule: "serve-static-assets.entry.js",
3018
+ expectedMainModule: "index.js",
3019
3019
  });
3020
3020
  mockSubDomainRequest();
3021
3021
  mockListKVNamespacesRequest(kvNamespace);
@@ -5846,7 +5846,7 @@ addEventListener('fetch', event => {});`
5846
5846
 
5847
5847
  "
5848
5848
  `);
5849
- const output = fs.readFileSync("tmp/d1-beta-facade.entry.js", "utf-8");
5849
+ const output = fs.readFileSync("tmp/index.js", "utf-8");
5850
5850
  expect(output).toContain(
5851
5851
  `var ExampleDurableObject2 = maskDurableObjectDefinition(ExampleDurableObject);`
5852
5852
  );
@@ -6579,6 +6579,47 @@ addEventListener('fetch', event => {});`
6579
6579
  `);
6580
6580
  });
6581
6581
 
6582
+ it("should preserve the entry point file name, even when using a facade", async () => {
6583
+ writeWranglerToml();
6584
+ writeWorkerSource();
6585
+ mockSubDomainRequest();
6586
+ mockUploadWorkerRequest();
6587
+ const assets = [
6588
+ { filePath: "file-1.txt", content: "Content of file-1" },
6589
+ { filePath: "file-2.txt", content: "Content of file-2" },
6590
+ ];
6591
+ const kvNamespace = {
6592
+ title: "__test-name-workers_sites_assets",
6593
+ id: "__test-name-workers_sites_assets-id",
6594
+ };
6595
+ writeAssets(assets);
6596
+ mockListKVNamespacesRequest(kvNamespace);
6597
+ mockKeyListRequest(kvNamespace.id, []);
6598
+ mockUploadAssetsToKVRequest(kvNamespace.id, assets);
6599
+ await runWrangler("publish index.js --outdir some-dir --assets assets");
6600
+ expect(fs.existsSync("some-dir/index.js")).toBe(true);
6601
+ expect(fs.existsSync("some-dir/index.js.map")).toBe(true);
6602
+ expect(std).toMatchInlineSnapshot(`
6603
+ Object {
6604
+ "debug": "",
6605
+ "err": "",
6606
+ "out": "Reading file-1.txt...
6607
+ Uploading as file-1.2ca234f380.txt...
6608
+ Reading file-2.txt...
6609
+ Uploading as file-2.5938485188.txt...
6610
+ ↗️ Done syncing assets
6611
+ Total Upload: xx KiB / gzip: xx KiB
6612
+ Uploaded test-name (TIMINGS)
6613
+ Published test-name (TIMINGS)
6614
+ https://test-name.test-sub-domain.workers.dev
6615
+ Current Deployment ID: Galaxy-Class",
6616
+ "warn": "▲ [WARNING] The --assets argument is experimental and may change or break at any time
6617
+
6618
+ ",
6619
+ }
6620
+ `);
6621
+ });
6622
+
6582
6623
  it("should copy any module imports related assets to --outdir if specified", async () => {
6583
6624
  writeWranglerToml();
6584
6625
  fs.writeFileSync(