Skip to content

Use of process.env.NODE_ENV in ESM bundle #1112

@jstayton

Description

@jstayton

👋🏻

I recently upgraded to v2 and ran into an issue when bundling your ESM export with my code. It looks look you include process.env.NODE_ENV in your bundle, which isn't automatically replaced by the bundler I use, Vite. This resulted in the browser reporting that process is not defined.

I had to add the following to my Vite config to resolve the issue:

export default defineConfig({
  // ...
  define: {
    'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV || 'development'),
  },
  // ...
})

That's not a huge deal, but I wonder whether there's a way to bundle your ESM export that doesn't require that extra step of defining process.env.NODE_ENV?

Thanks for the consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions