-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace resolve with require.resolve #12
Comments
This change is desirable and makes a lot of sense. If you have an idea how to implement it I'd be more than happy to accept a PR. |
Sure! I can submit a PR shortly after testing it works on our setup |
One potential blocker: it looks like there is some existing code that uses the following options from
All that said, this may likely be a breaking change for folks. I think it would certainly modernize this package! But some of the old behavior may go away. Given all that, do the breaking changes seem like OK tradeoffs? |
What do you think about using enhanced-resolve or unrs/unrs-resolver instead ? |
Those are both great options! I didn’t know about those. Can’t really go wrong with either—enhanced-resolve is by some of the webpack team it looks like; unrs-resolver is from the UnJS team that does great work. Neither has the |
Hello! Thanks for taking on maintenance of this plugin, you’ve done a great job!
Problem
One issue with the original rollup-plugin-styles is the old, outdated module resolution handled by the
resolve
package. Specifically, it doesn’t respectpackage.json
exports that are essential and standard nowadays.For example, we have a pnpm monorepo, and in one package we have
.css
files in the./dist/
folder that we shorten the import path for:So you’d import them at
@import "local-pkg/foo.css"
instead of@import "local-pkg/dist/foo.css"
. This plugin gives the following error:This is a longstanding problem with resolve, which has fallen behind modern ESM support.
Suggested solution
Simply replacing with Node’s built-in require.resolve() should perform much better, would support all of Node’s new ESM features and resolution. Node’s built-in resolve has come a long way and is now more mature than the old resolve package.
For example, my error comes from utils/resolve.ts, where the following change works:
Note: this is just an example; there’d be other related changes, but you get the idea
Would be happy to help with this change if this is desirable 🙂
The text was updated successfully, but these errors were encountered: