Skip to content

Commit

Permalink
fix: Disable nodeEnv optimization in Webpack (#2970)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FrederikBolding authored Dec 20, 2024
1 parent 8b2bada commit 3e615f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/snaps-cli/src/webpack/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -255,6 +256,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -426,6 +428,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -597,6 +600,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -767,6 +771,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -938,6 +943,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1109,6 +1115,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1280,6 +1287,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1459,6 +1467,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1623,6 +1632,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1794,6 +1804,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -1973,6 +1984,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -2152,6 +2164,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -2332,6 +2345,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -2503,6 +2517,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -2674,6 +2689,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -2854,6 +2870,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -3030,6 +3047,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -3187,6 +3205,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down Expand Up @@ -3344,6 +3363,7 @@ exports[`getDefaultConfiguration returns the default Webpack configuration for t
},
},
],
"nodeEnv": false,
},
"output": {
"chunkFormat": "commonjs",
Expand Down
6 changes: 6 additions & 0 deletions packages/snaps-cli/src/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ export async function getDefaultConfiguration(
optimization: {
minimize: config.output.minimize,

/**
* We disable the nodeEnv optimization as we already add process.NODE_ENV
* via the DefinePlugin in the section above this.
*/
nodeEnv: false,

/**
* The minimizer to use. We set it to use the `TerserPlugin`.
*/
Expand Down

0 comments on commit 3e615f5

Please sign in to comment.