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

Ship a dev and a production bundle on npm #209

Open
nick-thompson opened this issue Jan 10, 2021 · 0 comments
Open

Ship a dev and a production bundle on npm #209

nick-thompson opened this issue Jan 10, 2021 · 0 comments
Milestone

Comments

@nick-thompson
Copy link
Collaborator

nick-thompson commented Jan 10, 2021

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:

  • Build both a development version (webpack --mode=development) and a production version (webpack --mode=production) bundle
  • Include both bundles in our npm package
  • Include a main entrypoint that basically looks like the following
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.

@nick-thompson nick-thompson added this to the beta milestone Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant