-
Notifications
You must be signed in to change notification settings - Fork 507
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
Using Babel NODE_ENV for separate dev & prod plugins #687
Comments
So this is a valid use-case, but there's sort of an issue with it when it comes to the ESM build -- there's only one ESM build (though maybe we'll find a workaround for this soon since React is currently facing the same issue). So I'm not really sure what it should do in that case.
Indeed there is -- put your export function MyComponent ({ props }) {
// ...
}
if (process.env.NODE_ENV === 'development') {
MyComponent.propTypes = {
// ...
}
} Per the docs, the prod CJS version will strip it out entirely. |
@agilgur5 thanks for the answer! Regarding the ESM build, unless I misunderstood its purpose, I'd treat it as a development plugin. Since I read it's meant to be minified or otherwise processed by a consumer, I think it's fine to build it without stripping anything. If the consumer of the bundle wants to strip it, it can still use As for the workaround, thanks! But the production bundle still has Anyway, it's not possible to use |
The ESM build isn't a development build and it'll probably be used by consumers of your library that use Webpack. We just can't make separate dev/prod bundles of ESM, so we expect a bundler to handle that (and basically only bundlers read
So there's some issues with this approach:
Not sure I understand why that would give you a type error if |
Hi @agilgur5, sorry for replying so late. Regarding the ESM module, I just tried to be helpful, but given my limited experience with bundlers and modules, feel free to ignore my suggestion :) |
Current Behavior
I'd like to use
babel-plugin-transform-react-remove-prop-types
to remove prop-types from production build, while leaving them in the development build. I've added this to my .babelrc.jsHowever I see that tsdx produces its
.cjs.production.min.js
without setting NODE_ENV, so I can apply my trasformation either on both builds or none of them...Desired Behavior
The ability to have different transformations applied on development / production build. NODE_ENV is the standard way AFAIK, but if there's another way to obtain the same results I'll be happy to follow it.
Thanks!
The text was updated successfully, but these errors were encountered: