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.
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/__tests__/d1/execute.test.ts +1 -1
- package/src/__tests__/init.test.ts +1 -1
- package/src/__tests__/middleware.test.ts +2 -1
- package/src/__tests__/pages/functions-build.test.ts +44 -45
- package/src/__tests__/pages/publish.test.ts +136 -61
- package/src/__tests__/publish.test.ts +48 -7
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +1 -1
- package/src/api/dev.ts +0 -1
- package/src/api/pages/publish.tsx +31 -51
- package/src/bundle.ts +4 -0
- package/src/dev/dev.tsx +0 -2
- package/src/dev/local.tsx +4 -15
- package/src/dev/start-server.ts +1 -4
- package/src/dev.tsx +0 -3
- package/src/miniflare-cli/index.ts +1 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/pages/build.ts +262 -104
- package/src/pages/buildFunctions.ts +13 -6
- package/src/pages/dev.ts +4 -15
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +48 -33
- package/src/pages/functions/buildWorker.ts +20 -17
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/publish.tsx +1 -10
- package/src/user/user.ts +1 -1
- package/templates/gitignore +1 -0
- package/templates/tsconfig.init.json +1 -2
- package/wrangler-dist/cli.d.ts +1 -9
- package/wrangler-dist/cli.js +528 -423
|
@@ -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:
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
1149
|
-
expect(
|
|
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
|
|
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.
|
|
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(
|
|
1318
|
-
expect(
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
1515
|
-
expect(
|
|
1516
|
-
expect(
|
|
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
|
|
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.
|
|
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
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
2699
|
+
const generatedWorkerBundle = body.get("_worker.bundle") as string;
|
|
2643
2700
|
|
|
2644
|
-
|
|
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
|
|
2734
|
+
it("should bundle the _worker.js when both `--bundle` and `--no-bundle` are omitted", async () => {
|
|
2678
2735
|
simulateServer((generatedWorkerJS) =>
|
|
2679
|
-
expect(workerIsBundled(generatedWorkerJS)).
|
|
2736
|
+
expect(workerIsBundled(generatedWorkerJS)).toBeTruthy()
|
|
2680
2737
|
);
|
|
2681
2738
|
await runWrangler("pages publish public --project-name=foo");
|
|
2682
|
-
expect(std.out).toContain("✨ Uploading
|
|
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
|
|
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
|
|
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
|
-
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mIn 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/
|
|
329
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mIn 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.[0m
|
|
330
330
|
|
|
331
331
|
"
|
|
332
332
|
`);
|
|
@@ -1649,7 +1649,7 @@ addEventListener('fetch', event => {});`
|
|
|
1649
1649
|
};
|
|
1650
1650
|
writeAssets(assets);
|
|
1651
1651
|
mockUploadWorkerRequest({
|
|
1652
|
-
expectedMainModule: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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/
|
|
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": "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe --assets argument is experimental and may change or break at any time[0m
|
|
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(
|