-
-
Notifications
You must be signed in to change notification settings - Fork 599
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(node-resolve): Resolve local files if resolveOption
is set
#337
fix(node-resolve): Resolve local files if resolveOption
is set
#337
Conversation
Thanks for the PR! I might be missing something here, entirely possible, but if this change were successful, wouldn't the deepEqual fail for the
|
Hello @shellscape. I'm the one probably missing something here. For what I understood about the issue #209 is that the So in the |
Yeah I think I mistook the differences between imports and resolved. I would like to try and get some test in place that has something we can check that asserts that the local file did resolve. It looks like the lack of warnings is the signal that it's successful but that feels brittle. Nothing to block this PR on but if you can think of anything that'd be cool. I'd like @lukastaegert to put some quick eyes on this, but it looks good to me so far. |
Great! I don´t have a deep understanding of the Rollup internal types and properties, so I might be wrong, but after a fast check, I thing we can use the ´PreRenderedChunk.modules´ property, and test if the modules that should be resolved are contained in that dictionary keys. If it works as I think, this might give the tests a little more confidence. Other option I can think of is searching inside the generated code, but it is far more ugly and fragile than searching inside the imported or resolved modules. If you have any more ideas I would be more than happy to try them. |
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.
Looks good to me. Regarding the question of testing, a stable way to check if a module has been bundled would be to change in the test
const imports = await getImports(bundle);
to
const { output: [{imports, modules}]} = await bundle.generate({ format: 'esm' });
Then modules
is an object the keys of which are the resolved included modules, so you could for instance
t.assert(Object.keys(modules).includes(path.resolve('only.js')))
@JaviIG would you like to try Lukas' test suggestions before we merge? |
Thank you both! I´ve just uploaded the improved tests. That was the idea I had, but I wasn´t 100% sure about the behavior of the |
…lup#337) * fix(node-resolve): Resolve local files if `resolveOption` is set * format(node-resolve): Remove empty line in `fixtures/only.js` * test(node-resolve): add assertion to 'resolveOnly' tests to check resolved modules Co-authored-by: Javier Iglesias García <javieri@empathy.co>
Rollup Plugin Name:
node-resolve
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
This PR fixes the issue #209, where using the
resolveOnly
option at thenode-resolve
plugin prevented the resolution of local modules.