-
Notifications
You must be signed in to change notification settings - Fork 153
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: handle node:
prefix
#285
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.
We could add a unit fixture that uses node:
imports/requires here https://github.com/vercel/nft/tree/main/test/unit would be good to ensure fs/path usage via node:fs
and node:path
catches the files it's reading correctly
Codecov Report
@@ Coverage Diff @@
## main #285 +/- ##
==========================================
+ Coverage 80.43% 80.44% +0.01%
==========================================
Files 13 13
Lines 1482 1483 +1
Branches 552 555 +3
==========================================
+ Hits 1192 1193 +1
Misses 120 120
Partials 170 170
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Looks like that didn't fix it after all 😬 |
@Rich-Harris let me know if I can assist with any NFT stuff anytime - it seems like the unit test just needs to be updated? The logging isn't ideal, may make sense to log the error before the warning to ensure the error can be seen at that call site in https://github.com/vercel/nft/blob/main/test/unit.test.js#L175. |
@guybedford if you are able to get this working, that would be terrific — unfortunately I'm maxed out at the moment otherwise I'd spend more time digging into it. Right now I'm just working around it: traced.warnings.forEach((error) => {
// pending https://github.com/vercel/nft/issues/284
if (error.message.startsWith('Failed to resolve dependency node:')) return;
console.error(error);
}); |
I don't have time to clone and PR right now, especially since I'm on Windows here. But I'd just suggest the following change in analyze.ts: Line 305 change: const m = staticModules[specifier.startsWith('node:') ? specifier.slice(5) : specifier]; line 345 change: const staticModule = staticModules[source.startsWith('node:') ? source.slice(5) : source]; |
Co-authored-by: Guy Bedford <guybedford@gmail.com>
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.
Thanks!
import fs from 'fs'; | ||
import * as path from 'path'; | ||
import fs from 'node:fs'; | ||
import * as path from 'node:path'; |
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.
Should this test be reverted so we cover both cases?
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.
Yeah we can revert this one since we have the separate fixtures now, updated in #287
This appears to be enough to fix #284, but I'm not sure where a test would go