slightlyfaulty / stylus-native-loader

✒️ A super fast Stylus loader for Webpack that leverages the built-in power of Stylus.
MIT License
15 stars 1 forks source link

Glob not working case #2

Closed phaistonian closed 3 years ago

phaistonian commented 4 years ago

@import '!(index)*.styl'

It seems the above is not working - It does work with stylus loader.

slightlyfaulty commented 4 years ago

I suspect this might be due to another issue with the alias evaluator. I don't suppose you have a ! alias in your webpack config?

In any case please update to the latest version and give it a try. If it's still not working please post back any errors.

FYI you can do @require '*' instead of @import '!(index)*.styl'. It doesn't work in stylus-loader, but it works in vanilla stylus (and this loader) 😉

slightlyfaulty commented 4 years ago

Have you had a chance to test this again with the latest version @phaistonian?

I added a test case for this which is passing: https://github.com/slightlyfaulty/stylus-native-loader/tree/master/test/fixtures/globs

Would be great to get your feedback so I can make sure there are no more problems and close out this issue.

phaistonian commented 4 years ago

Sorry, not yet.

Will get to do it eventually.

slightlyfaulty commented 4 years ago

No problem. I'm gonna go ahead and close this for now. If you're still running into issues we can re-open.

Thanks very much for your feedback so far 👍

phaistonian commented 3 years ago

So here's why it did not work and how I handled it.

slightlyfaulty commented 3 years ago

Nice catch @phaistonian. I'm not sure why exactly the resolveUrl option is causing Stylus to bug out on glob imports, but I'm looking into it and will hopefully have a fix out soon.

slightlyfaulty commented 3 years ago

So it looks like Stylus has a bug that messes up glob imports in the entry file when resolveURL is true or { nocheck: false }, specifically when external imports are added via the imports option.

Since stylus-native-loader uses the imports option to import a file that disables built-in vendor prefixing, this bug is triggered every time (when vendors !== true).

What I've done is add a workaround so that Stylus thinks resolveURL nocheck is true when resolving imports, avoiding this bug altogether. I've tested it pretty extensively and it doesn't seem to break any other functionality.

I'd really appreciate if you could test the update on your side and let me know if it's working for you.

As an aside, unless you specifically need to check for the existence of url() files, you can set resolveUrl: 'nocheck' to speed up compilation a bit (while also avoiding this bug and the workaround).

phaistonian commented 3 years ago

The workaround worked.

Thank you.

Ps: url(), I am afraid, is needed in our scenario(s).