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

module field in package.json should not point to fully uncompiled version #13

Open
vitorbal opened this issue Jan 5, 2018 · 1 comment
Labels

Comments

@vitorbal
Copy link
Contributor

vitorbal commented Jan 5, 2018

The module field in package.json should point to a version of react-element-portal that has ES2015 module syntax but otherwise only syntax features that the target environments support.

Since react-element-portal uses syntax like object rest spread which not all target environments support, those should be compiled before publishing.
More info on rationale here: https://github.com/rollup/rollup/wiki/pkg.module#wait-it-just-means-import-and-export--not-other-future-javascript-features

Most end-users that consume react-element-portal via module field will trip up on this bug, since it's very common to not compile modules from node_modules. Example error:

ERROR in ./node_modules/react-element-portal/src/ElementPortal.js
Module parse failed: /Code/zapier/node_modules/react-element-portal/src/ElementPortal.js Unexpected token (42:8)
You may need an appropriate loader to handle this file type.
|
|       const children = View ?
|         <View {...mapDomNodeToProps(node)} /> :
|         React.Children.only(this.props.children);
|
 @ ./node_modules/react-element-portal/src/index.js 1:0-44
[...]

While we're at it we might also consider switching the build step to use Rollup instead of plain babel.

@vitorbal vitorbal added the bug label Jan 5, 2018
@ngryman
Copy link
Contributor

ngryman commented Jan 5, 2018

After this epic conversation: https://zapier.slack.com/archives/C0466L7SX/p1515145573000212, we decided:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants