-
Notifications
You must be signed in to change notification settings - Fork 361
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
Production bundle #115
Comments
Sure thing, but could you specify for which format u'd like to output those 2 builds? Seems only relevant for umd (and maybe cjs targeting node). |
Well my idea is to make my library provide both production and development builds if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
} So i can add useful debug code for development but also provide the smallest code in production |
is your library targeting node, browsers or both? |
Just browser. Mostly React
A domingo, 8/04/2018, 18:45, Mateusz Burzyński <[email protected]>
escreveu:
… is your library targeting node, browsers or both?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAeeLltNZ48O9L93Q_6_xaJwrTKrib11ks5tmky9gaJpZM4TLLQJ>
.
|
For browsers u dont need this. Just use Example in the wild can be check here. |
Ok, i get it, will use that for now! |
The same #181 ? |
Just referencing one issue we got reported over at mobx: mobxjs/mobx-react#801 @Andarist I tend to agree that this should be indeed a concern for consumer bundlers. What about UMD? There is no bundling happening, it's used directly and it's unlikely user will be mocking Furthermore, when I look for inspiration to React package, they indeed are keeping env checks in development bundles, but removing (evaluating) them for a production bundle: https://unpkg.com/browse/[email protected]/cjs/react.development.js The TSDX went a slightly different route, they are keeping ESM bundle with those checks because it's a good assumption that one will be bundled by a consumer. But UMD is stripped down. For CJS the approach from #115 (comment) works very well. Have a look at Formik for example. |
Definitely should be replaced, UMDs are intended to be used "as is".
Keep in mind that actually this is React's entry point - https://unpkg.com/[email protected]/index.js . This is a proxy file to prod/dev bundles (similar strategy is used by https://preconstruct.tools/ ). It's written like this because process.env is supposedly slow in node, so better to just read it one time rather than all over the place. Also that dev bundle has actually replaced all I believe a similar strategy (proxy file) could be used for CJS entries in microbundle |
Yea, so ultimately I believe the TSDX has chosen the right path and it would be nice if microbundle could follow :)
Yea, but their development bundle still refers to |
Heya, I'm getting this in a UMD build, any idea what the fix was @developit ? |
I don't recall. If you're trying to use env checks in UMD that's not recommended. If you're trying to use the React package and seeing this in bundles, try passing |
Thanks, |
Hi, would it be possible to add an option to use https://github.com/rollup/rollup-plugin-replace
To be able to make different builds for development and production
The text was updated successfully, but these errors were encountered: