Skip to content

Commit 33584e5

Browse files
FrederikBoldingPatrykLucka
authored andcommitted
fix: Disable nodeEnv optimization in Webpack (#2970)
Disable the `nodeEnv` optimization in the default Webpack config, this optimization would simply add the `NODE_ENV` environment variable set to `production`, but that is unnecessary since we are already defining `NODE_ENV` ourselves. This prevents an issue where devs would run into warnings when attempting to set `NODE_ENV` themselves.
1 parent 7a32cd6 commit 33584e5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
8484
},
8585
},
8686
],
87+
"nodeEnv": false,
8788
},
8889
"output": {
8990
"chunkFormat": "commonjs",
@@ -255,6 +256,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
255256
},
256257
},
257258
],
259+
"nodeEnv": false,
258260
},
259261
"output": {
260262
"chunkFormat": "commonjs",
@@ -426,6 +428,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
426428
},
427429
},
428430
],
431+
"nodeEnv": false,
429432
},
430433
"output": {
431434
"chunkFormat": "commonjs",
@@ -597,6 +600,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
597600
},
598601
},
599602
],
603+
"nodeEnv": false,
600604
},
601605
"output": {
602606
"chunkFormat": "commonjs",
@@ -767,6 +771,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
767771
},
768772
},
769773
],
774+
"nodeEnv": false,
770775
},
771776
"output": {
772777
"chunkFormat": "commonjs",
@@ -938,6 +943,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
938943
},
939944
},
940945
],
946+
"nodeEnv": false,
941947
},
942948
"output": {
943949
"chunkFormat": "commonjs",
@@ -1109,6 +1115,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
11091115
},
11101116
},
11111117
],
1118+
"nodeEnv": false,
11121119
},
11131120
"output": {
11141121
"chunkFormat": "commonjs",
@@ -1280,6 +1287,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
12801287
},
12811288
},
12821289
],
1290+
"nodeEnv": false,
12831291
},
12841292
"output": {
12851293
"chunkFormat": "commonjs",
@@ -1459,6 +1467,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
14591467
},
14601468
},
14611469
],
1470+
"nodeEnv": false,
14621471
},
14631472
"output": {
14641473
"chunkFormat": "commonjs",
@@ -1623,6 +1632,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
16231632
},
16241633
},
16251634
],
1635+
"nodeEnv": false,
16261636
},
16271637
"output": {
16281638
"chunkFormat": "commonjs",
@@ -1794,6 +1804,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
17941804
},
17951805
},
17961806
],
1807+
"nodeEnv": false,
17971808
},
17981809
"output": {
17991810
"chunkFormat": "commonjs",
@@ -1973,6 +1984,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
19731984
},
19741985
},
19751986
],
1987+
"nodeEnv": false,
19761988
},
19771989
"output": {
19781990
"chunkFormat": "commonjs",
@@ -2152,6 +2164,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
21522164
},
21532165
},
21542166
],
2167+
"nodeEnv": false,
21552168
},
21562169
"output": {
21572170
"chunkFormat": "commonjs",
@@ -2332,6 +2345,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
23322345
},
23332346
},
23342347
],
2348+
"nodeEnv": false,
23352349
},
23362350
"output": {
23372351
"chunkFormat": "commonjs",
@@ -2503,6 +2517,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
25032517
},
25042518
},
25052519
],
2520+
"nodeEnv": false,
25062521
},
25072522
"output": {
25082523
"chunkFormat": "commonjs",
@@ -2674,6 +2689,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
26742689
},
26752690
},
26762691
],
2692+
"nodeEnv": false,
26772693
},
26782694
"output": {
26792695
"chunkFormat": "commonjs",
@@ -2854,6 +2870,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
28542870
},
28552871
},
28562872
],
2873+
"nodeEnv": false,
28572874
},
28582875
"output": {
28592876
"chunkFormat": "commonjs",
@@ -3030,6 +3047,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
30303047
},
30313048
},
30323049
],
3050+
"nodeEnv": false,
30333051
},
30343052
"output": {
30353053
"chunkFormat": "commonjs",
@@ -3187,6 +3205,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
31873205
},
31883206
},
31893207
],
3208+
"nodeEnv": false,
31903209
},
31913210
"output": {
31923211
"chunkFormat": "commonjs",
@@ -3344,6 +3363,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
33443363
},
33453364
},
33463365
],
3366+
"nodeEnv": false,
33473367
},
33483368
"output": {
33493369
"chunkFormat": "commonjs",

packages/snaps-cli/src/webpack/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ export async function getDefaultConfiguration(
373373
optimization: {
374374
minimize: config.output.minimize,
375375

376+
/**
377+
* We disable the nodeEnv optimization as we already add process.NODE_ENV
378+
* via the DefinePlugin in the section above this.
379+
*/
380+
nodeEnv: false,
381+
376382
/**
377383
* The minimizer to use. We set it to use the `TerserPlugin`.
378384
*/

0 commit comments

Comments
 (0)