Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Secrets | View in Orca |
guybedford
left a comment
There was a problem hiding this comment.
Thanks for posting this, it is definitely a missing feature and the last missing feature before this resolver implementation can be considered complete (given this resolve feature landed in Node.js later itself).
I left a couple of comments. That said I don't think the implementation is complete and likely needs a closer look at the spec. It also needs tests to land.
If you need implementation inspiration, perhaps take a look at rollup/plugins#1549 which was very nicely written.
| (a, b) => b.length - a.length | ||
| )) { | ||
| if (!match.endsWith("/")) continue; | ||
| for (const match of Object.keys(matchObj).sort((a, b) => b.length - a.length)) { |
There was a problem hiding this comment.
This sort should be updated to use the order defined by PATTERN_KEY_COMPARE in https://nodejs.org/dist/latest-v20.x/docs/api/esm.html#resolution-and-loading-algorithm.
| if (job.ts && path.startsWith(job.base) && path.slice(job.base.length).indexOf(sep + 'node_modules' + sep) === -1 && await job.isFile(path + '.ts')) return path + '.ts'; | ||
| if (job.ts && path.startsWith(job.base) && path.slice(job.base.length).indexOf(sep + 'node_modules' + sep) === -1 && await job.isFile(path + '.tsx')) return path + '.tsx'; |
There was a problem hiding this comment.
Perhaps abstract this into an extensions configuration rather, so it can be configured and not necessarily the default (sincethis will match ./file.ts before file.js).
|
Okay I'll go over this again soon. Side note: it seems like a shame to have all these separate implementations of the node module resolution algorithm. Is there really no package that's flexible enough to be used in all of these cases? I've used the |
fixes #266
Supports trailing characters after the
*in wildcardexportspatterns, e.g.I copied the logic from Node's resolve implementation.