Skip to content

Updating package.module to transpiled ES6 modules (CRA compatibility issue) #1284

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

Closed
interactivellama opened this issue Feb 20, 2018 · 3 comments

Comments

@interactivellama
Copy link
Contributor

interactivellama commented Feb 20, 2018

Create React App now supports ES6 modules (and the transpiling of node_modules folder) and is now using package.modules. I think this is what is causing #1269. I propose switching package.modules to be a transpiled version except for ES6 modules and not the source code.

I'm hesitant to add a third version of this library within the node module, but main should be ES5/CJS and modules should be ES6, and I'd like to the source code present, especially for internal library users that are using .babelrc and want to use master branch pull downs in their app, etc.

Another option is remove the CJS version and require ES6 module usage.

This will most likely be 0.9.x and include #1265 's module.export fixes.

@interactivellama interactivellama changed the title Consider upgrading package.main to ES6 modules Consider upgrading package.modules to ES6 modules Feb 20, 2018
@interactivellama interactivellama changed the title Consider upgrading package.modules to ES6 modules Consider upgrading package.module to ES6 modules Feb 20, 2018
@interactivellama interactivellama changed the title Consider upgrading package.module to ES6 modules Consider upgrading package.module to transpiled ES6 modules Feb 20, 2018
@interactivellama
Copy link
Contributor Author

The other option is to remove package.module completely and say folks have to eject their CRA app, etc. if they want to do tree shaking or other ES6 things.

@interactivellama interactivellama changed the title Consider upgrading package.module to transpiled ES6 modules Consider updating package.module to transpiled ES6 modules Feb 20, 2018
@interactivellama
Copy link
Contributor Author

After considering and reading many Github issue threads across a variety of projects, I am leaning toward a third copy of this library being included in the NPM module.

Basis

  • package.module can no longer point to stage < 4 code
  • package.main still needs to point to commonjs at the moment. lib or dist should be a compiled module that works in current Node version. ES6 module copy of library is not a compiled “lib”-like module until package.mode: esm is available
  • package.module entry point code will be used no matter what by Webpack if it exists. package.esm: true proposal would invalidate /lib usage though, since it is CJS—although that folder/code should die at some point eventually, since babel-env supports browser targets field. /lib was originally only included to support project like Create React App that didn't transpile. Who doesn't transpile React libraries, now that CRA does? is a good question.

Proposal

  • /components contains source files (stage < 4 code) (changing file names is a breaking change)
  • /lib contains CommonJS (changing export variables is a breaking change, changing file names/folders is NOT a breaking change, since these are built modules)
  • /module contains ES6 modules (JSX and stage < 4 features are transpiled. compatible with bable-env basically) (folder shouldn't need to be changed in the future). (changing export variables is a breaking change, changing file names/folders is NOT a breaking change, since these are built modules)

Aside: It’s annoying that TC39 is a zero-based index. I get why--it's a programming spec, but it’s confusing sometimes. FYI: There are five stages and number four is the finished stage.

@interactivellama
Copy link
Contributor Author

Adding to thread. @nutchanon-pho @tswardenski

@interactivellama interactivellama changed the title Consider updating package.module to transpiled ES6 modules Consider updating package.module to transpiled ES6 modules (CRA compatibility issue) Mar 1, 2018
@interactivellama interactivellama changed the title Consider updating package.module to transpiled ES6 modules (CRA compatibility issue) Ppdating package.module to transpiled ES6 modules (CRA compatibility issue) Mar 1, 2018
@interactivellama interactivellama changed the title Ppdating package.module to transpiled ES6 modules (CRA compatibility issue) Updating package.module to transpiled ES6 modules (CRA compatibility issue) Mar 1, 2018
@interactivellama interactivellama added this to the Backlog milestone Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants