Skip to content

Warn when code is uglified but not envified #1029

Closed
@gaearon

Description

@gaearon

From my series of tweets:

https://twitter.com/dan_abramov/status/665109454870982656
https://twitter.com/dan_abramov/status/665111615520563200
https://twitter.com/dan_abramov/status/665113061590761472
https://twitter.com/dan_abramov/status/665113349248704512

It's a common problem that people don't know they need to envify CommonJS builds. We need to help educate them about it, both in the docs and in the running code.

In the docs, we need to mention that you need tools like loose-envify (Browserify) or DefinePlugin (Webpack) to set process.env.NODE_ENV to 'production'. Otherwise you're running a slower development-only build of React, Redux, and other libraries.

In the source, we might want to try checking whether a local identifier is crushed. If it is, we're running in minified mode. If we're running in minified mode and process.env.NODE_ENV is something other than 'production', we should console.error, explain the mistake, and point to the relevant doc (a Medium article anyone?) about envifying.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions