Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Question: Is it a bad practice to use react-transform for production code? #79

Closed
slestang opened this issue Jan 28, 2016 · 1 comment
Closed

Comments

@slestang
Copy link

All example and documentation seems to be about setting up react-transform only on development mode (with the help of .babelrc env property). But I recently started to use the Sentry transform that is clearly made for production code. Their documentation clearly state that they enable react-transform in production.

So I was wondering if they were any impact on my code (I think mostly about perf) about using react-transform for production code?

Related question (but slightly off topic): Does anybody know a way to have a production and development configuration for react-transform in .babelrc without duplicate part between the 2 environment?
My current .babelrc looks like this:

{
  "presets": ["es2015", "react", "stage-0"],
  "env": {
    "development": {
        "plugins": [
          [
            "lodash",
           ["react-transform", {
              "transforms": [
                {
                  "transform": "react-transform-sentry",
                  "imports": ["react"]
                },
                {
                  "transform": "react-transform-hmr",
                  "imports": ["react"],
                  "locals": ["module"]
                },
                {
                  "transform": "react-transform-catch-errors",
                  "imports": ["react", "redbox-react"]
                },
              ]
            }]
          ]
        ]
    },
    "production": {
        "plugins": [
          [
            "lodash",
           ["react-transform", {
              "transforms": [
                {
                  "transform": "react-transform-sentry",
                  "imports": ["react"]
                }
              ]
            }]
          ]
        ]
    }
  }
}
@slestang slestang changed the title Question: It is a bad practice to use react-transform for production code? Question: Is it a bad practice to use react-transform for production code? Jan 28, 2016
@gaearon
Copy link
Owner

gaearon commented Jan 28, 2016

So I was wondering if they were any impact on my code (I think mostly about perf) about using react-transform for production code?

Not really as long as you keep track of what transforms do and how invasive they are. For example, you don't want to enable react-transform-hmr in prod because it proxies every method and class making them much slower.

@gaearon gaearon closed this as completed Jan 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants