-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: plugin no longer crashes in rollup only scenarios #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @xenobytezero! Thanks a lot for the various fixes and adjustments, appreciate it 😃
You've mentioned that you prepared a fixture for the test, but it will always resolve the root packages, right? We could disable hoisting in general as we only have one single production package in the "monorepo" itself.
Let me know what you think :)
I had thought about this, but disabling the hoisting wont on it's own help. In a Rollup scenario, Vite is still as a direct dependency in the root workspace, and the |
f097e9f
to
0afaf42
Compare
Apologies for the extra commits, had to do some author fixing. |
I also added some additional filtering to the |
@all-contributors please add @xenobytezero for bug reports and code |
I've put up a pull request to add @xenobytezero! 🎉 |
@xenobytezero thanks a lot for your efforts on the bugs! I'm now fine merging it even without tests as it seems quite hard to implemented (did some fiddling tonight but couldn't find a way to declare sufficient test cases neither). I'd be fine moving forward and merging your PR - is everything included from your side? I will also merge #70 after this PR got merged. |
Yep, that's now everything from my side. Happy to have the PR merged. |
🎉 This PR is included in version 1.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Tasks
The plugin currently crashes when used in a Rollup only context.
The
registerTools()
function does arequire.resolve
at the top level, which will fail if the requested package does not exist. This commit reworks theregisterTools
function to wrap it in atry/catch
.While doing this, we also found that the code will not resolve packages like Rollup correctly. So this has also been fixed.
A
require.resolve
onrollup
(tested with4.14.3
) will resolve to therollup/dist/rollup.js
path. The current code will then try and find apackage.json
atdist/package.json
which will fail and so not include the package.I attempted to add a rollup fixture for the testing purposes, but the current structure of the tests means that the code will traverse all the way up to the workspace root from the fixture folders and find both
rollup
andvite
, regardless of which fixture is being used. I have the fixture locally but have not included it in this PR to reduce complexity.