refactor(compiler): potential undefined access in getWebpackConfigPath#3296
Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom Apr 7, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts getWebpackConfigPath to use an explicit builder.type === 'webpack' branch and return early when a webpack config path is found, aiming to avoid propagating unexpected undefined values.
Changes:
- Refactors
getWebpackConfigPathfrom a ternary assignment to an explicitif/early-return structure. - Adds an inline comment describing the intended fallback behavior when no config path is provided.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0c38afd to
e58842b
Compare
The function accesses `builder.options?.configPath` without verifying `builder.options` exists. While optional chaining prevents a crash, if `builder.options` is undefined, `webpackPath` becomes undefined and is returned — but the caller may expect a valid path. This can lead to runtime errors downstream when the path is used (e.g., in file system operations or webpack CLI invocation). Signed-off-by: Zendy <50132805+zendy199x@users.noreply.github.com>
e58842b to
5733ca7
Compare
Contributor
Author
|
The changes look good and address a potential issue where
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The function
getWebpackConfigPathaccessesbuilder.options?.configPathwithout verifyingbuilder.optionsexists. While optional chaining prevents a crash, ifbuilder.optionsisundefined,webpackPathbecomesundefinedand is returned — but the caller may expect a valid path. This can lead to runtime errors downstream when the path is used (e.g., in file system operations or webpack CLI invocation).Issue Number: N/A
What is the new behavior?
The function now includes an explicit null/undefined check for
builder.optionsandconfigPath. Ifbuilder.type === 'webpack'but noconfigPathis specified, a more robust handling (e.g., logging or erroring) is introduced to prevent unexpectedundefinedpaths from propagating.Does this PR introduce a breaking change?
Other information
lib/compiler/helpers/get-webpack-config-path.tsrefactor: potential undefined access in getwebpackconfigpath