Skip to content

Commit 177562b

Browse files
fix: minify and node_compat should be inherited
Fixes [cloudflare#1150](cloudflare#1150)
1 parent a8c509a commit 177562b

File tree

4 files changed

+44
-21
lines changed

4 files changed

+44
-21
lines changed

.changeset/eighty-kangaroos-sneeze.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: `minify` and `node_compat` should be inherited
6+
7+
Fixes [#1150](https://github.com/cloudflare/wrangler2/issues/1150)

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ describe("normalizeAndValidateConfig()", () => {
6161
data_blobs: undefined,
6262
workers_dev: undefined,
6363
zone_id: undefined,
64+
minify: undefined,
65+
node_compat: undefined,
6466
});
6567
expect(diagnostics.hasErrors()).toBe(false);
6668
expect(diagnostics.hasWarnings()).toBe(false);
@@ -662,6 +664,8 @@ describe("normalizeAndValidateConfig()", () => {
662664
},
663665
],
664666
},
667+
minify: true,
668+
node_compat: true,
665669
};
666670

667671
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -721,6 +725,8 @@ describe("normalizeAndValidateConfig()", () => {
721725
cwd: 1555,
722726
watch_dir: 1666,
723727
},
728+
minify: "INVALID",
729+
node_compat: "INVALID",
724730
} as unknown as RawEnvironment;
725731

726732
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -783,7 +789,9 @@ describe("normalizeAndValidateConfig()", () => {
783789
- Expected \\"tsconfig\\" to be of type string but got true.
784790
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
785791
- Expected \\"main\\" to be of type string but got 1333.
786-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
792+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
793+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
794+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
787795
`);
788796
});
789797

@@ -1912,6 +1920,8 @@ describe("normalizeAndValidateConfig()", () => {
19121920
cwd: "CWD",
19131921
watch_dir: "WATCH_DIR",
19141922
},
1923+
minify: true,
1924+
node_compat: true,
19151925
};
19161926

19171927
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -1952,6 +1962,8 @@ describe("normalizeAndValidateConfig()", () => {
19521962
cwd: "ENV_CWD",
19531963
watch_dir: "ENV_WATCH_DIR",
19541964
},
1965+
minify: false,
1966+
node_compat: false,
19551967
};
19561968
const rawConfig: RawConfig = {
19571969
name: "mock-name",
@@ -1971,6 +1983,8 @@ describe("normalizeAndValidateConfig()", () => {
19711983
cwd: "CWD",
19721984
watch_dir: "WATCH_DIR",
19731985
},
1986+
minify: true,
1987+
node_compat: true,
19741988
env: {
19751989
ENV1: rawEnv,
19761990
},
@@ -2221,6 +2235,8 @@ describe("normalizeAndValidateConfig()", () => {
22212235
cwd: 1555,
22222236
watch_dir: 1666,
22232237
},
2238+
minify: "INVALID",
2239+
node_compat: "INVALID",
22242240
} as unknown as RawEnvironment;
22252241

22262242
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -2253,7 +2269,9 @@ describe("normalizeAndValidateConfig()", () => {
22532269
- Expected \\"tsconfig\\" to be of type string but got 123.
22542270
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
22552271
- Expected \\"main\\" to be of type string but got 1333.
2256-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
2272+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
2273+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
2274+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
22572275
`);
22582276
});
22592277

packages/wrangler/src/config/validation.ts

+16-18
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,6 @@ export function normalizeAndValidateConfig(
9494
"boolean"
9595
);
9696

97-
validateOptionalProperty(
98-
diagnostics,
99-
"",
100-
"minify",
101-
rawConfig.minify,
102-
"boolean"
103-
);
104-
105-
validateOptionalProperty(
106-
diagnostics,
107-
"",
108-
"node_compat",
109-
rawConfig.node_compat,
110-
"boolean"
111-
);
112-
11397
// TODO: set the default to false to turn on service environments as the default
11498
const isLegacyEnv =
11599
(args as { "legacy-env": boolean | undefined })["legacy-env"] ??
@@ -928,8 +912,22 @@ function normalizeAndValidateEnvironment(
928912
}
929913
),
930914
zone_id: rawEnv.zone_id,
931-
minify: rawEnv.minify,
932-
node_compat: rawEnv.node_compat,
915+
minify: inheritable(
916+
diagnostics,
917+
topLevelEnv,
918+
rawEnv,
919+
"minify",
920+
isBoolean,
921+
undefined
922+
),
923+
node_compat: inheritable(
924+
diagnostics,
925+
topLevelEnv,
926+
rawEnv,
927+
"node_compat",
928+
isBoolean,
929+
undefined
930+
),
933931
};
934932

935933
return environment;

0 commit comments

Comments
 (0)