Skip to content

Build Server & Client Libraries with esnext and ES Modules #985

Description

@drewpc

Currently, the project uses Gulp and Babel to produce the server and client libraries required to be imported by anyone using react-server. That means those libraries are transpiled down to es5 and end applications can't ship esnext code to browsers as they see fit.

This issue proposes the following:

  • Use Rollup to bundle client and server libraries ending in '.esm.js' as ES Modules. These libraries would not be transpiled by Babel, just bundled by Rollup.
  • This likely will apply to the following packages inside react-server:
    • flab
    • react-server-core-middleware
    • react-server-data-bundle-cache
    • react-server-middleware-json-response
    • react-server
  • Add these libraries to package.json so that Webpack can find and use the ES Modules version when building the final application for the end-developer.
  • The end developer is then required to transpile the final application as they see fit.

All of this paves the way for further enhancements to how react-server leverages Webpack to bundle the final application and transpiles at compile time (not "publish" time for react-server). It further allows the end-developer to make custom decisions about what to transpile. For example, if all of the clients of my application use ES6 compatible browsers, I don't want to transpile everything down to ES5.

See the the article Webpack and Rollup: the same but different for conceptual details.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions