Skip to content

Commit 0b928c6

Browse files
fix: warn if the site.entry-point configuration is found during publishing
1 parent b63efe6 commit 0b928c6

File tree

3 files changed

+88
-24
lines changed

3 files changed

+88
-24
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: warn if the `site.entry-point` configuration is found during publishing

packages/wrangler/src/__tests__/publish.test.ts

+77-24
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("publish", () => {
3737
});
3838

3939
it("should be able to use the `build.upload.main` config as the entry-point for ESM sources", async () => {
40-
writeWranglerToml("./index.js");
40+
writeWranglerToml({ main: "./index.js" });
4141
writeEsmWorkerSource();
4242
mockUploadWorkerRequest();
4343
mockSubDomainRequest();
@@ -57,6 +57,35 @@ describe("publish", () => {
5757
expect(stderr).toMatchInlineSnapshot(`""`);
5858
expect(error).toMatchInlineSnapshot(`undefined`);
5959
});
60+
61+
it("should warn if there is a `site.entry-point` configuration", async () => {
62+
writeWranglerToml({
63+
entryPoint: "./index.js",
64+
});
65+
writeEsmWorkerSource();
66+
mockUploadWorkerRequest();
67+
mockSubDomainRequest();
68+
69+
const { stdout, stderr, error, warnings } = await runWrangler(
70+
"publish ./index.js"
71+
);
72+
73+
expect(stripTimings(stdout)).toMatchInlineSnapshot(`
74+
"Uploaded
75+
test-name
76+
(TIMINGS)
77+
Deployed
78+
test-name
79+
(TIMINGS)
80+
81+
test-name.test-sub-domain.workers.dev"
82+
`);
83+
expect(stderr).toMatchInlineSnapshot(`""`);
84+
expect(error).toMatchInlineSnapshot(`undefined`);
85+
expect(warnings).toMatchInlineSnapshot(
86+
`"Deprecation notice: The \`site.entry-point\` config field is no longer used. Please remove it from the \`wrangler.toml\` file."`
87+
);
88+
});
6089
});
6190

6291
describe("asset upload", () => {
@@ -69,7 +98,7 @@ describe("publish", () => {
6998
title: "__test-name_sites_assets",
7099
id: "__test-name_sites_assets-id",
71100
};
72-
writeWranglerToml("./index.js", "assets");
101+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
73102
writeEsmWorkerSource();
74103
writeAssets(assets);
75104
mockUploadWorkerRequest();
@@ -106,7 +135,7 @@ describe("publish", () => {
106135
title: "__test-name_sites_assets",
107136
id: "__test-name_sites_assets-id",
108137
};
109-
writeWranglerToml("./index.js", "assets");
138+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
110139
writeEsmWorkerSource();
111140
writeAssets(assets);
112141
mockUploadWorkerRequest();
@@ -148,7 +177,7 @@ describe("publish", () => {
148177
title: "__test-name_sites_assets",
149178
id: "__test-name_sites_assets-id",
150179
};
151-
writeWranglerToml("./index.js", "assets");
180+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
152181
writeEsmWorkerSource();
153182
writeAssets(assets);
154183
mockUploadWorkerRequest();
@@ -189,7 +218,7 @@ describe("publish", () => {
189218
title: "__test-name_sites_assets",
190219
id: "__test-name_sites_assets-id",
191220
};
192-
writeWranglerToml("./index.js", "assets");
221+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
193222
writeEsmWorkerSource();
194223
writeAssets(assets);
195224
mockUploadWorkerRequest();
@@ -230,7 +259,11 @@ describe("publish", () => {
230259
title: "__test-name_sites_assets",
231260
id: "__test-name_sites_assets-id",
232261
};
233-
writeWranglerToml("./index.js", "assets", ["file-1.txt"]);
262+
writeWranglerToml({
263+
main: "./index.js",
264+
bucket: "assets",
265+
include: ["file-1.txt"],
266+
});
234267
writeEsmWorkerSource();
235268
writeAssets(assets);
236269
mockUploadWorkerRequest();
@@ -269,7 +302,11 @@ describe("publish", () => {
269302
title: "__test-name_sites_assets",
270303
id: "__test-name_sites_assets-id",
271304
};
272-
writeWranglerToml("./index.js", "assets", undefined, ["file-2.txt"]);
305+
writeWranglerToml({
306+
main: "./index.js",
307+
bucket: "assets",
308+
exclude: ["file-2.txt"],
309+
});
273310
writeEsmWorkerSource();
274311
writeAssets(assets);
275312
mockUploadWorkerRequest();
@@ -308,7 +345,11 @@ describe("publish", () => {
308345
title: "__test-name_sites_assets",
309346
id: "__test-name_sites_assets-id",
310347
};
311-
writeWranglerToml("./index.js", "assets", ["file-2.txt"]);
348+
writeWranglerToml({
349+
main: "./index.js",
350+
bucket: "assets",
351+
include: ["file-2.txt"],
352+
});
312353
writeEsmWorkerSource();
313354
writeAssets(assets);
314355
mockUploadWorkerRequest();
@@ -349,9 +390,11 @@ describe("publish", () => {
349390
title: "__test-name_sites_assets",
350391
id: "__test-name_sites_assets-id",
351392
};
352-
writeWranglerToml("./index.js", "assets", undefined, [
353-
"assets/file-1.txt",
354-
]);
393+
writeWranglerToml({
394+
main: "./index.js",
395+
bucket: "assets",
396+
exclude: ["assets/file-1.txt"],
397+
});
355398
writeEsmWorkerSource();
356399
writeAssets(assets);
357400
mockUploadWorkerRequest();
@@ -398,7 +441,7 @@ describe("publish", () => {
398441
title: "__test-name_sites_assets",
399442
id: "__test-name_sites_assets-id",
400443
};
401-
writeWranglerToml("./index.js", "assets");
444+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
402445
writeEsmWorkerSource();
403446
writeAssets(assets);
404447
mockUploadWorkerRequest();
@@ -444,7 +487,7 @@ describe("publish", () => {
444487
title: "__test-name_sites_assets",
445488
id: "__test-name_sites_assets-id",
446489
};
447-
writeWranglerToml("./index.js", "assets");
490+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
448491
writeEsmWorkerSource();
449492
writeAssets(assets);
450493
mockUploadWorkerRequest();
@@ -487,9 +530,11 @@ describe("publish", () => {
487530
title: "__test-name_sites_assets",
488531
id: "__test-name_sites_assets-id",
489532
};
490-
writeWranglerToml("./index.js", "assets", undefined, [
491-
"assets/file-1.txt",
492-
]);
533+
writeWranglerToml({
534+
main: "./index.js",
535+
bucket: "assets",
536+
exclude: ["assets/file-1.txt"],
537+
});
493538
writeEsmWorkerSource();
494539
writeAssets(assets);
495540
mockUploadWorkerRequest();
@@ -523,7 +568,7 @@ describe("publish", () => {
523568
title: "__test-name_sites_assets",
524569
id: "__test-name_sites_assets-id",
525570
};
526-
writeWranglerToml("./index.js", "assets");
571+
writeWranglerToml({ main: "./index.js", bucket: "assets" });
527572
writeEsmWorkerSource();
528573
writeAssets([longFilePathAsset]);
529574
mockUploadWorkerRequest();
@@ -550,22 +595,30 @@ describe("publish", () => {
550595
});
551596

552597
/** Write a mock wrangler.toml file to disk. */
553-
function writeWranglerToml(
554-
main?: string,
555-
bucket?: string,
556-
include?: string[],
557-
exclude?: string[]
558-
) {
598+
function writeWranglerToml({
599+
main,
600+
bucket,
601+
include,
602+
exclude,
603+
entryPoint,
604+
}: {
605+
main?: string;
606+
bucket?: string;
607+
include?: string[];
608+
exclude?: string[];
609+
entryPoint?: string;
610+
} = {}) {
559611
fs.writeFileSync(
560612
"./wrangler.toml",
561613
[
562614
`compatibility_date = "2022-01-12"`,
563615
`name = "test-name"`,
564616
main !== undefined ? `[build.upload]\nmain = "${main}"` : "",
565-
bucket || include || exclude ? "[site]" : "",
617+
bucket || include || exclude || entryPoint ? "[site]" : "",
566618
bucket !== undefined ? `bucket = "${bucket}"` : "",
567619
include !== undefined ? `include = ${JSON.stringify(include)}` : "",
568620
exclude !== undefined ? `exclude = ${JSON.stringify(exclude)}` : "",
621+
entryPoint !== undefined ? `entry-point = "${entryPoint}"` : "",
569622
].join("\n"),
570623
"utf-8"
571624
);

packages/wrangler/src/publish.ts

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ export default async function publish(props: Props): Promise<void> {
8888
file = path.resolve(path.dirname(__path__), build.upload.main);
8989
}
9090

91+
if (config.site?.["entry-point"]) {
92+
console.warn(
93+
"Deprecation notice: The `site.entry-point` config field is no longer used. Please remove it from the `wrangler.toml` file."
94+
);
95+
}
96+
9197
if (props.legacyEnv) {
9298
scriptName += props.env ? `-${props.env}` : "";
9399
}

0 commit comments

Comments
 (0)