enhanced-resolve icon indicating copy to clipboard operation
enhanced-resolve copied to clipboard

enhanced-resolve is broken on Windows

Open scott-cornwell opened this issue 4 years ago • 1 comments

https://github.com/webpack/enhanced-resolve/blob/c960801d5cfbb6a472e40a7fe8f6c0679955a13b/lib/AliasPlugin.js#L70

This line needs to normalize paths between unix paths and Windows. When using packages like Linaria on Windows (that depend on enhanced-resolve), aliases don't work (which is the only way to get alias with Linaria currently). The paths end up mixed slashes with the base alias path having Windows backslashes and the end concatenated on is forward slashes.

scott-cornwell avatar Apr 09 '22 07:04 scott-cornwell

alias is string to string mapping. please provide webpack.config + what request you are trying to resolve

vankop avatar Apr 09 '22 17:04 vankop

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

alexander-akait avatar Apr 11 '23 19:04 alexander-akait

The problem is still relevant. For example, if you write this code in css:

background-image:url("..\..\..\..\..\..\..\src\components\blocks\saver\[email protected]");

We will get an error

ERROR in ./.cache/css/app-dev/src/components/blocks/saver/index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./.cache/css/app-dev/src/components/blocks/saver/index.css)
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
Error: Can't resolve '..............src
omponents
[email protected]' in 'D:\project\www\.cache\css\app-dev\src\components\blocks\saver'
    at finishWithoutResolve (D:\project\www\node_modules\enhanced-resolve\lib\Resolver.js:309:18)

askuzminov avatar Apr 18 '23 06:04 askuzminov

@askuzminov Is it scss/sass/less? I think you are out of root of your filesystem

alexander-akait avatar Apr 18 '23 09:04 alexander-akait

Raw css. After changing ..\..\..\ to ../../../ - it works as needed.

askuzminov avatar Aug 11 '23 11:08 askuzminov