Repository navigation
fix(config): normalize file URLs for options taking absolute paths - #22059
Pcmhacker-piro wants to merge 1 commit into
Conversation
Commit 3a69d29 updated the schema validator to accept file URLs wherever an option takes an absolute path, and normalized file URLs for options like context, output.path, cacheDirectory, etc. However, several other options accepting absolute paths per schema were omitted from normalization in lib/config/normalization.js: - module.noParse: NormalModule checks content.startsWith(rule) which silently failed to match filesystem paths against file URLs. - resolve.restrictions and resolveLoader.restrictions: passed to enhanced-resolve as file URLs, causing resolution errors for allowed paths. - stats.context: passed to RequestShortener / contextify, causing broken relative paths. - dotenv.dir and experiments.buildHttp: passed to path join utilities expecting filesystem paths. Now all of these options convert file URLs to filesystem paths during options normalization. Closes webpack#22057.
|
👋 Hi there! This PR was automatically flagged and closed by our quality checks. If you believe this was a mistake, please review our contributing guidelines |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughWebpack now converts file URLs to filesystem paths for additional configuration options. Unit tests cover conversion and preservation of existing values. A new configuration case verifies file URL support for ChangesFile URL normalization
Change: Bug fix · Severity of issue fixed: Medium Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Superseded by #22066. |
Summary
In #22012 / commit 3a69d29, webpack added support for
file://URLs wherever options take an absolute path, converting them during options normalization inlib/config/normalization.jsfor options likecontext,output.path,snapshot.managedPaths,cacheDirectory, etc.However, several other options that take
"absolutePath": trueperschemas/WebpackOptions.jsonwere omitted from normalization:module.noParse:NormalModule.applyNoParseRulecomparescontent.startsWith(rule). Sincecontentis a filesystem path andruleremained afile://URL, they never matched, causing modules to be parsed unexpectedly.resolve.restrictions&resolveLoader.restrictions: passed directly toenhanced-resolveasfile://URLs, causing resolution failures for allowed paths.stats.context: passed toRequestShortener/contextifywithout normalization, causing broken relative paths.dotenv.dir&experiments.buildHttp: passed to path utilities expecting filesystem paths.This PR normalizes file URLs to filesystem paths for these options in
lib/config/normalization.js.Fixes #22057.
What kind of change does this PR introduce?
bugfix
Did you add tests for your changes?
Yes:
test/Normalization.unittest.jscovering normalization ofmodule.noParse,resolve.restrictions,resolveLoader.restrictions,stats.context,dotenv.dir, andexperiments.buildHttp.test/configCases/no-parse/file-url/(gated withsupportsFileUrlPaths()matchingtest/configCases/rule-set/file-url-condition/).Does this PR introduce a breaking change?
No. Non-file-URL values, RegExps, and functions pass through unchanged.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Yes
Summary by CodeRabbit
New Features
noParsesupports file URLs, allowing selected modules to remain unparsed while other modules continue to be processed normally.Bug Fixes