-
Notifications
You must be signed in to change notification settings - Fork 11
Description
The runtime keys gives useful information about the environment to the resolver, but there is currently no way to inspect this information from within the runtime environment.
I understand this proposal is moving to a more general package.json spec, but before we do that, I wanted to discuss the possibility of an import.meta.runtime
object which would expose a frozen bag of booleans corresponding to the runtime key environment.
Would be useful for platform checks:
if (import.meta.runtime.node) { ... }
As well as dev / production checks:
if (import.meta.runtime?.development) { ... }
Having a standard like this would get support between Node.js and tools - of course we can't get support in browsers, but that might be acceptable having this as a build time inlining. And perhaps the browser does even define import.meta.runtime = { browser: true }
one day.