fix: make "url" optional in resolver created with createResolve#44
Conversation
rchl
commented
Apr 29, 2022
| export function createResolve (defaults?: ResolveOptions) { | ||
| return (id, url) => { | ||
| return (id: string, url?: ResolveOptions['url']) => { | ||
| return resolve(id, { url, ...defaults }) |
Contributor
Author
There was a problem hiding this comment.
I've also noticed that the logic here is incorrect as the defaults will override the url even when it is explicitly provided. I didn't want to mix that fix in into this one but I can create a follow-up PR for that.
rchl
commented
Apr 29, 2022
Comment on lines
+3
to
+4
| const resolve = createResolve({ url: import.meta.url }) | ||
| console.log(await resolve('./cjs.mjs')) |
Contributor
Author
There was a problem hiding this comment.
I see that those test files are not really used for anything right now (which is a shame because it would have caught an issue otherwise) but I've changed this to create a local variable rather than assigning to import.meta.resolve as import.meta.resolve has its own type already (coming from Node) so even though it's our custom resolver, it has still used the Node type and thus wouldn't check type issues if those would be inconsistent.
pi0
approved these changes
Jun 16, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
urlargument to resolver created withcreateResolveis made optional. The point is that the defaults are used and theurldoesn't have to be provided, same as in Node'simport.meta.resolveAPI.checkJSso that the*.mjsfiles intest/fixtureare least type checked (mostly for the editor's sake).mllypath mapping intsconfig.jsonso that there are no errors reported intest/fixturewhen importing frommlly.