Skip to content

import.meta.runtime #19

@guybedford

Description

@guybedford

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions