fix(webpack-plugin): fix webpack plugin loader dirname path construction#836
Open
yang991178 wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(webpack-plugin): fix webpack plugin loader dirname path construction#836yang991178 wants to merge 2 commits intomicrosoft:mainfrom
yang991178 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
On Windows, `new URL(import.meta.url).pathname` returns a URL-encoded string (e.g., %20 for spaces), causing webpack to fail to resolve the virtual loader when the project path contains spaces. Using `fileURLToPath` from `node:url` correctly decodes the path. Agent-Logs-Url: https://github.com/yang991178/griffel/sessions/ecf6c457-0cf7-4168-b422-06646a01c1d8 Co-authored-by: yang991178 <16064741+yang991178@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree |
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.
The loader in the webpack plugin seems to have an issue on Windows when the path contains spaces. Specifically,
new URL(import.meta.url).pathnamereturns URL-encoded strings (e.g.,%20for spaces), causing webpack to fail when the project path contains spaces. This PR updates the line to usefileURLToPath, which should correctly handle path decoding on all platforms.In
packages/webpack-plugin/src/webpackLoader.mts:fileURLToPathfrom'node:url'const __dirname = path.dirname(new URL(import.meta.url).pathname);→const __dirname = path.dirname(fileURLToPath(import.meta.url));