johanholmerin / style9

CSS-in-JS compiler inspired by Meta's stylex
MIT License
570 stars 27 forks source link

Issue with webpack plugin on windows #57

Closed martinbooth closed 2 years ago

martinbooth commented 2 years ago

I guess I must be the only person writing code on windows :)

modules by path ./Application/ 2.22 KiB
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        C:\Source\_\Application\Root.KBftMHg.css doesn't exist
      .tsx
        Field 'browser' doesn't contain a valid alias configuration
        C:\Source\_\Application\Root.KBftMHg.css.tsx doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        C:\Source\_\Application\Root.KBftMHg.css.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        C:\Source\_\Application\Root.KBftMHg.css.js doesn't exist
      as directory
        C:\Source\_\Application\Root.KBftMHg.css doesn't exist
 @ ./Application/app.web.tsx 4:0-26 5:162-166

I have traced the issue down to loader.js:43 where the value of css path is 'C:/Source/_/Application/Root.KBftMHg.css', that is with forward slashes instead of backslashes

I'm not really sure the best fix otherwise I'd have sent through a PR.. it seems deliberate in https://github.com/webpack/loader-utils/blob/master/lib/interpolateName.js#L44

For now, I'm just writing both paths:

virtualModules.writeModule(cssPath.replace(/\//g, "\\"), metadata.style9);
virtualModules.writeModule(cssPath, metadata.style9);
johanholmerin commented 2 years ago

I don't have a good answer for this. It doesn't seem like this error is caused by style9.

Could you see if updating webpack-virtual-modules & loader-utils fixes it?

martinbooth commented 2 years ago

That was one of the first things I tried, but no luck.. I'll try and debug a bit further.. I know the import is being appended with forward slashes, but I guess somewhere along the way it gets converted to backslashes for windows

johanholmerin commented 2 years ago

@martinbooth Can you confirm that the branch windows-virtual-path fixes the issue?

johanholmerin commented 2 years ago

Fixed in 0.13.3