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

request: produce two JS bundles - lib and app #536

Closed
stoyan opened this issue Sep 1, 2016 · 6 comments
Closed

request: produce two JS bundles - lib and app #536

stoyan opened this issue Sep 1, 2016 · 6 comments

Comments

@stoyan
Copy link

stoyan commented Sep 1, 2016

One e.g. create-react-app-v0.2.js that can be hosted by volunteering CDNs and shared among all the apps and another one bundle.js that is app-specific

@HatemJerbi
Copy link

it will be nice if the build generate one hashed vendor bundle (modules imported from node_modules) and one app hashed bundle.

@tbillington
Copy link

@stoyan The only dependencies that all create-react-app apps share is react and react-dom, is that what you mean?

@HatemJerbi The benefit would be small I think? Often changing your app code will use more/less of the library code, which will mean that the uglified version of your 'node_modules' bundle will be different.

@stoyan
Copy link
Author

stoyan commented Sep 2, 2016

@tbillington yeah, I guess so. I just created a test app, deleted everything except index.js and built. The result is 160K (46K after gzip) of stuff. So ideally this can be shared between all apps, it's independent of the application code.

Question: When does create-react-app pull the current version of react+reactdom? When you generate a new app or when you install/update create-react-app?

@tbillington
Copy link

@stoyan It gets react+dom when you generate a new app.

@tbillington
Copy link

tbillington commented Sep 2, 2016

@stoyan you could do something like eject (or modify the internal of react-scripts) to tell webpack to assume react is provided by the environment, then link to react on a cdn in your html.

That way your app will not bundle react which will greatly reduce the size, and you get cdn benefits. The 160kb base blob you mentioned is essentially just react and webpack module wrapping + some polyfill as far as I know..

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2016

We tried this before in #210 and found some issues with Webpack. I want to revisit this after Webpack 2 is declared stable and we switch to using it.

@gaearon gaearon closed this as completed Sep 3, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants