bito-code-review[bot] commented on code in PR #44459:
URL: https://github.com/apache/superset/pull/44459#discussion_r4072642220
##########
superset-frontend/webpack.config.js:
##########
@@ -65,700 +61,709 @@ const ROOT_DIR = path.resolve(__dirname, '..');
// any url prefix.
const MINI_CSS_EXTRACT_PUBLICPATH = './';
-const {
- mode = 'development',
- devserverPort: cliPort,
- devserverHost: cliHost,
- measure = false,
- nameChunks = false,
-} = parsedArgs;
-
-// Precedence: CLI args > env vars > defaults
-const devserverPort = cliPort || process.env.WEBPACK_DEVSERVER_PORT || 9000;
-const devserverHost =
- cliHost || process.env.WEBPACK_DEVSERVER_HOST || '127.0.0.1';
-
-const isDevMode = mode !== 'production';
-const isDevServer = process.argv[1]?.includes('webpack-dev-server') ?? false;
-
-// TypeScript checker memory limit (in MB)
-const TYPESCRIPT_MEMORY_LIMIT = 8192;
-
-const defaultEntryFilename = isDevMode
- ? '[name].[contenthash:8].entry.js'
- : nameChunks
- ? '[name].[chunkhash].entry.js'
- : '[name].[chunkhash].entry.js';
-
-const defaultChunkFilename = isDevMode
- ? '[name].[contenthash:8].chunk.js'
- : nameChunks
- ? '[name].[chunkhash].chunk.js'
- : '[chunkhash].chunk.js';
-
-const output = {
- path: BUILD_DIR,
- publicPath: '/static/assets/',
- filename: pathData =>
- pathData.chunk?.name === 'service-worker'
- ? '../service-worker.js'
- : defaultEntryFilename,
- chunkFilename: pathData =>
- pathData.chunk?.name === 'service-worker'
- ? '../service-worker.js'
- : defaultChunkFilename,
-};
+const generateWebpackConfigWithCustomInputs = (env, args) => {
+ const {
+ devserverPort: cliPort,
+ devserverHost: cliHost,
+ measure = false,
+ nameChunks = false,
+ } = env;
+ const { mode } = args;
+
+ // Precedence: CLI args > env vars > defaults
+ const devserverPort = cliPort || process.env.WEBPACK_DEVSERVER_PORT || 9000;
+ const devserverHost =
+ cliHost || process.env.WEBPACK_DEVSERVER_HOST || '127.0.0.1';
+
+ const isDevMode = mode !== 'production';
+ const isDevServer = process.argv[1]?.includes('webpack-dev-server') ?? false;
+
+ // TypeScript checker memory limit (in MB)
+ const TYPESCRIPT_MEMORY_LIMIT = 8192;
+
+ const defaultEntryFilename = isDevMode
+ ? '[name].[contenthash:8].entry.js'
+ : nameChunks
+ ? '[name].[chunkhash].entry.js'
+ : '[name].[chunkhash].entry.js';
Review Comment:
<!-- Bito Reply -->
The suggestion from the reviewer is correct. In the provided code snippet,
the ternary operator for `defaultEntryFilename` uses the same value for both
the `nameChunks` true and false branches:
```javascript
: nameChunks
? '[name].[chunkhash].entry.js'
: '[name].[chunkhash].entry.js';
```
Since both branches return `'[name].[chunkhash].entry.js'`, the `nameChunks`
condition has no effect. You should simplify this logic by removing the
redundant ternary check.
**superset-frontend/webpack.config.js**
```
const defaultEntryFilename = isDevMode
? '[name].[contenthash:8].entry.js'
: '[name].[chunkhash].entry.js';
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]