-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Treat new URL('relativePathHere', import.meta.url)
as assets.
#45955
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
Comments
https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
|
But why it can copy JSON files with resolveJsonModule? And I belive they'll also do this for wasm files (#39784) |
How are we supposed to know that |
It's hard coded in all of the toolchains like how they treat |
Therein lies the answer to
|
Because in |
Yes, and more generally, we have to process imports and exports in order for modules to work, and there is unambiguous syntax, not dependent on type definitions, that triggers an import. |
What if we have this import reflection proposal in the ECMAScript? Can TypeScript copy the asset for the following code? (tc39/proposal-source-phase-imports#16 (comment)) import u from './x.png' as 'asset-reference'
await readFile(u) |
Suggestion
When using a file in TypeScript,
new URL("./file.png", import.meta.url)
, TypeScript should copy this file to the output folder, like what it did for importingJSON
files.🔍 Search Terms
new URL import meta url
✅ Viability Checklist
My suggestion meets these guidelines:
📃 Motivating Example
This is useful when writing a library with assets referenced otherwise we need extra steps to copy those files.
The text was updated successfully, but these errors were encountered: