JoshMarler / react-juce

Write cross-platform native apps with React.js and JUCE
https://docs.react-juce.dev
MIT License
764 stars 79 forks source link

Ship a dev and a production bundle on npm #209

Open nick-thompson opened 3 years ago

nick-thompson commented 3 years ago

Right now, the react-juce package that we ship onto npm has a build step for assembling the files into a bundle before distribution. The npm package itself largely just contains a package.json and that bundle.

So far, that's not a problem, but the change I'd like to add here is simple:

if (process.env.NODE_ENV === 'production') {
  return require('dist/index.production.js');
}

return require('dist/index.development.js');

This way we can ship helpful development tools like shims for __BlueprintNative__ and stuff, but only do it within the development bundle, so that we incur no performance penalties (e.g. for excessive use of Proxy) in the prod bundle.

EDIT: I suppose a first step is to answer the question: do we need the intermediate bundle? This project has come a long way since that workflow was first introduced. I wonder if we're now in a position where we could basically just transpile our Typescript/ES6 into the same file structure but as plain ol' ES5 javascript, and ship our npm package that way. That way this original question just disappears, because we can ship if (process.env.NODE_ENV) code in our npm package and end users will automatically compile it out if they bundle in production modes.