-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
What is the problem this feature would solve?
It is common to write apps and library code in JS that references relative file paths, such as:
- Dynamic JS entry files (in particular, for web workers/service workers/shared workers)
- WASM
- CSS, JSON, arbitrary resources, …
import.meta.resolve(…) provides a standard way to refer to a relative resource, and also supports bare names and absolute paths. It is already supported in all major browsers and deno. It would be valuable for import.meta.resolve(…) to be available in all target environments, including bun.
What is the feature you are proposing to solve the problem?
Implement https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
What alternatives have you considered?
As a library author, I can use code that uses new URL(…, import.meta.url).href instead. However:
import.meta.resolve(…)is more ergonomic and conveys clear intentions compared to being a "magic pattern", and- it is not supported by all bundlers, and it's unclear if it ever will be (possibly due to the previous reason).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request