-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
is not shimmed when using --rewriteRelativeImportExtensions
#61541
Comments
We have to draw some line where const foo: any = import.meta;
foo.resolve("x.ts") which we don't have any chance of catching. |
@RyanCavanaugh Hm, I haven't thought of That being said, I'm not sure I agree with
This behavior is broken when the While not pretty, the const { resolve: r$182s9f } = import.meta;
import.meta.resolve = (path) => r$182s9f(path.replace('.ts', '.js')); |
Worth noting there is a stage 2.7 proposal that allows for statically refering to modules for basically this exact usage. |
I mean, the best we can do is make this differently inconsistent, and I'm not seeing a case for why the proposed inconsistency is better than the existing one. The rules today are at least 100% syntactic; you can be sure that if you write const { resolve } = import.meta;
resolve("path") is rewritten or not. Having the rule be simple is super critical for single-file transpilers wanting to replicate TypeScript's behavior, since they don't have the same symbol resolution mechanics that TS does which would allow it to even realize that We also need to consider the case where a runtime adds something like |
π Search Terms
"rewriteRelativeImportExtensions", "import.meta.resolve", "require.resolve", "shim", "experimental-strip-types", "experimental-transform-types"
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
While imports are correctly rewritten/shimmed, calls to
import.meta.resolve
/require.resolve
are not impacted.π Expected behavior
I would expect
import.meta.resolve
to resolve to the same path as an import call, as per MDN Documentation.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: