Skip to content

Commit 40f20b2

Browse files
fix: minify and node_compat should be inherited (#1153)
Fixes [#1150](#1150)
1 parent b817136 commit 40f20b2

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(
@@ -729,6 +733,8 @@ describe("normalizeAndValidateConfig()", () => {
729733
cwd: 1555,
730734
watch_dir: 1666,
731735
},
736+
minify: "INVALID",
737+
node_compat: "INVALID",
732738
} as unknown as RawEnvironment;
733739

734740
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -791,7 +797,9 @@ describe("normalizeAndValidateConfig()", () => {
791797
- Expected \\"tsconfig\\" to be of type string but got true.
792798
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
793799
- Expected \\"main\\" to be of type string but got 1333.
794-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
800+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
801+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
802+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
795803
`);
796804
});
797805

@@ -1917,6 +1925,8 @@ describe("normalizeAndValidateConfig()", () => {
19171925
cwd: "CWD",
19181926
watch_dir: "WATCH_DIR",
19191927
},
1928+
minify: true,
1929+
node_compat: true,
19201930
};
19211931

19221932
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -1957,6 +1967,8 @@ describe("normalizeAndValidateConfig()", () => {
19571967
cwd: "ENV_CWD",
19581968
watch_dir: "ENV_WATCH_DIR",
19591969
},
1970+
minify: false,
1971+
node_compat: false,
19601972
};
19611973
const rawConfig: RawConfig = {
19621974
name: "mock-name",
@@ -1976,6 +1988,8 @@ describe("normalizeAndValidateConfig()", () => {
19761988
cwd: "CWD",
19771989
watch_dir: "WATCH_DIR",
19781990
},
1991+
minify: true,
1992+
node_compat: true,
19791993
env: {
19801994
ENV1: rawEnv,
19811995
},
@@ -2226,6 +2240,8 @@ describe("normalizeAndValidateConfig()", () => {
22262240
cwd: 1555,
22272241
watch_dir: 1666,
22282242
},
2243+
minify: "INVALID",
2244+
node_compat: "INVALID",
22292245
} as unknown as RawEnvironment;
22302246

22312247
const { config, diagnostics } = normalizeAndValidateConfig(
@@ -2258,7 +2274,9 @@ describe("normalizeAndValidateConfig()", () => {
22582274
- Expected \\"tsconfig\\" to be of type string but got 123.
22592275
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
22602276
- Expected \\"main\\" to be of type string but got 1333.
2261-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
2277+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
2278+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
2279+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
22622280
`);
22632281
});
22642282

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"] ??
@@ -947,8 +931,22 @@ function normalizeAndValidateEnvironment(
947931
}
948932
),
949933
zone_id: rawEnv.zone_id,
950-
minify: rawEnv.minify,
951-
node_compat: rawEnv.node_compat,
934+
minify: inheritable(
935+
diagnostics,
936+
topLevelEnv,
937+
rawEnv,
938+
"minify",
939+
isBoolean,
940+
undefined
941+
),
942+
node_compat: inheritable(
943+
diagnostics,
944+
topLevelEnv,
945+
rawEnv,
946+
"node_compat",
947+
isBoolean,
948+
undefined
949+
),
952950
};
953951

954952
return environment;

0 commit comments

Comments
 (0)