-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
import.meta.resolve
doesn't work with npm specifiers.
#16089
Comments
I believe this is correct. If you do |
@bartlomieju Is there any way to get the path of the cached file? I'm using it with |
Not currently, no. You can do that, if you know the exact version you want to use though - It is something I also encountered when trying to write a plugin for |
@oscarotero @bartlomieju Adding an import before the import React from "npm:react";
console.log(import.meta.resolve("npm:react")); |
This is a inconsistency and it doesn't work in all cases. This code returns an error const specifier = "npm:react";
await import(specifier);
console.log(import.meta.resolve(specifier));
/* error: Uncaught (in promise) TypeError: Loading unprepared module: npm:react, imported from: file:///Users/oscarotero/www/test/deno/main.js */ For now, I'm using esm.sh to get the content of the npm packages: https://github.com/lumeland/lume/blob/6cca5823609ee3c036e7e51d918a304067bc9066/plugins/esbuild.ts#L82-L85 |
Thinking in terms of a request URL / response URL may offer a little more flexibility here in in trying to reconcile any differences between |
There's a casuistry that must be taken into account: the |
@oscarotero |
Closed in #21716. |
The following code returns the same npm specifier instead of the url of the resolved file:
The text was updated successfully, but these errors were encountered: