Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

import.meta.resolve consensus discussion #458

Open
guybedford opened this issue Dec 19, 2019 · 6 comments
Open

import.meta.resolve consensus discussion #458

guybedford opened this issue Dec 19, 2019 · 6 comments

Comments

@guybedford
Copy link
Contributor

I've just opened the PR in nodejs/node#31032 for import.meta.resolve support.

This is something there have been browser discussions around for quite a while, so I've reached out to those working on this there on this feature to ensure that whatever is done here can align between the platforms.

Specifically, we don't want either Node.js or the browser shipping something the other won't want to implement.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2019

Once we decide on API and semantics, I'd love to build it in https://npmjs.com/resolve as well.

@bmeck
Copy link
Member

bmeck commented Dec 19, 2019

I'll be rather busy in the next week as will several others I'm sure so we might want to setup a timeline to avoid this being under reviewed and/or just give a clear timeline when the discussion is over so that we don't merge too quickly after discussion ends.

@frank-dspeed
Copy link

this is maybe related nodejs/node#31120

@SMotaal
Copy link

SMotaal commented Jan 9, 2020

@frank-dspeed can you please elaborate with examples of using import.meta.resolve per your custom loader? I think it may be relevant but I don't want to assume from my end.

Note — node's ESM module loader does not directly support https: but a custom loader doing it is a subtle difference to consider imho.

@frank-dspeed
Copy link

@SMotaal my loader would simply extract all imports and pass them to import.resolve if needed
but at present my esm-loader has node esm module resolve already it only can't handle relative urls thats where import resolve can help at present i would use import meta url and resolve relativ to that.

@frank-dspeed
Copy link

i have a exra helper that i call resolvePath()

// gets called with a import.meta.url returns path 
export function resolvePath(url){
    return urlToPath(url)
}

i import that helper into any module and call it with the modules import.meta.url to retrive relativ path to current module

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants