Skip to content

Crashes when used in a Cloudflare Worker #205

@Yvem

Description

@Yvem

While it's explicitly stated in the doc:

We expect process.env.NODE_ENV to be available at module compilation. We cache this value.

In some js runtimes such as Cloudflare Workers and overall many lambda runtimes (WinterCG) the node.js globals are not available.

In tiny-invariant case, it causes the line const isProduction: boolean = process.env.NODE_ENV === 'production'; to crash at import time, because process is undefined.

I don't know how to properly fix this, as the exact expression process.env.NODE_ENV is used by bundlers, as summarized by [Claude][https://claude.ai/share/39324895-61ee-468d-a768-4362aa910e89).

I'm still creating this ticket in order to:

  • share it with relevant parties such as WinterTC so that this feature may be standardized at some point in the future?
  • get help from the community. Maybe there are some solutions I didn't think of?

Thanks for the great lib anyway!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions