Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define NODE_ENV to use the production build of React on slatejs.org #1939

Merged

Conversation

schneidmaster
Copy link
Collaborator

Is this adding or improving a feature or fixing a bug?

Improvement

What's the new behavior?

Defines process.env.NODE_ENV through webpack's DefinePlugin. Defining this value causes us to use the production build of React on slatejs.org, which has better performance (and is thus a better representation of how Slate works, especially with large documents).

Specifically -- defining process.env.NODE_ENV makes code paths unreachable within the core React code (by producing, in essence, true === false conditionals), and then Uglify strips out those unreachable code paths, resulting in React not running development code and being faster.

How does this change work?

See previous section

Have you checked that...?

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn prettier.)
  • The relevant examples still work. (Run examples with yarn watch.)

Does this fix any issues or need any specific reviewers?

Reviewers: @ianstormtaylor

@ianstormtaylor
Copy link
Owner

Beautiful, thanks @schneidmaster!

@ianstormtaylor ianstormtaylor merged commit 001460f into ianstormtaylor:master Jul 1, 2018
@schneidmaster schneidmaster deleted the react-production-docs branch July 1, 2018 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants