Skip to content

Commit

Permalink
fix: let "assets" in wrangler.toml be a string (#5938)
Browse files Browse the repository at this point in the history
The experimental "assets" field can be either a string or an object. However the type definition marks it only as an object. This is a problem because we use this to generate the json schema, which gets picked up by vscode's even better toml extension, and shows it to be an error when used with a string (even though it works fine). The fix is to simply change the type definition to add a string variant.
  • Loading branch information
threepointone authored May 30, 2024
1 parent e0e7725 commit 9e4d8bc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-pets-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

fix: let "assets" in wrangler.toml be a string

The experimental "assets" field can be either a string or an object. However the type definition marks it only as an object. This is a problem because we use this to generate the json schema, which gets picked up by vscode's even better toml extension, and shows it to be an error when used with a string (even though it works fine). The fix is to simply change the type definition to add a string variant.
3 changes: 0 additions & 3 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,6 @@ addEventListener('fetch', event => {});`
it("should error if config.assets and --site are used together", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "abc",
});
writeWorkerSource();
Expand Down Expand Up @@ -2323,7 +2322,6 @@ addEventListener('fetch', event => {});`
it("should error if config.assets and config.site are used together", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "abc",
site: {
bucket: "xyz",
Expand Down Expand Up @@ -2407,7 +2405,6 @@ addEventListener('fetch', event => {});`
it("should warn if config.assets is used", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "./assets",
});
const assets = [
Expand Down
3 changes: 0 additions & 3 deletions packages/wrangler/src/__tests__/dev.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,6 @@ describe("wrangler dev", () => {
it("should error if config.assets and --site are used together", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "abc",
});
fs.writeFileSync("index.js", `export default {};`);
Expand All @@ -1290,7 +1289,6 @@ describe("wrangler dev", () => {
it("should error if config.assets and config.site are used together", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "abc",
site: {
bucket: "xyz",
Expand Down Expand Up @@ -1342,7 +1340,6 @@ describe("wrangler dev", () => {
it("should warn if config.assets is used", async () => {
writeWranglerToml({
main: "./index.js",
// @ts-expect-error we allow string inputs here
assets: "./assets",
});
fs.writeFileSync("index.js", `export default {};`);
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export interface ConfigFields<Dev extends RawDevConfig> {
browser_TTL: number | undefined;
serve_single_page_app: boolean;
}
| string
| undefined;

/**
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e4d8bc

Please sign in to comment.