Skip to content

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

Closed
@stoyan

Description

@stoyan

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

Activity

HatemJerbi

HatemJerbi commented on Sep 2, 2016

@HatemJerbi

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

tbillington

tbillington commented on Sep 2, 2016

@tbillington

@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

stoyan commented on Sep 2, 2016

@stoyan
Author

@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

tbillington commented on Sep 2, 2016

@tbillington

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

tbillington

tbillington commented on Sep 2, 2016

@tbillington

@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

gaearon commented on Sep 2, 2016

@gaearon
Contributor

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.

locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @stoyan@gaearon@tbillington@HatemJerbi

        Issue actions

          request: produce two JS bundles - lib and app · Issue #536 · facebook/create-react-app