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

Provide ES5 precompiled source #4

Closed
voodoods opened this issue Dec 7, 2017 · 2 comments
Closed

Provide ES5 precompiled source #4

voodoods opened this issue Dec 7, 2017 · 2 comments

Comments

@voodoods
Copy link

voodoods commented Dec 7, 2017

Issue Description

Currently rambdax is using ES6 syntax within its source like i.e. arrow functions, see example: https://github.com/selfrefactor/rambdax/blob/master/dist/rambdax.esm.js#L125

This leads to compatibility issues with legacy browsers that do not yet support ES6 features, i.e. IE11 or Edge 14. Example screenshots taken from IE11 developer tools console debugger, project setup using Babel 6 + Webpack 3:

Console error:
error_console_rambdax

... leads to:
bundlejs-rambdax-error

Context

I'm using rambdax v0.7.7 in a project that needs to be transpiled to ES5 to be compatible with IE >= 11 using Babel.

Unfortunately Babel does not support the transpilation of ES6 features within the source code of node_modules, mainly because of build speed reasons. You can read more about the discussion here: facebook/create-react-app#1125

Furthermore the build process will fail when using i.e. the UglifyJS plugin for Webpack. Running:

npm run build

in a given setup leads to

ERROR in bundle.js from UglifyJs Unexpected token: operator (>) [../node_modules/rambda/dist/rambda.esm.js:3,0][bundle.js:1,73120]

Related issue: webpack-contrib/uglifyjs-webpack-plugin#104

Usually you could handle such cases within your own source code too using Babel. But since Babel will not touch the node_modules, what comes in ES6 syntax will remain ES6 in the bundle.

Suggestion

Precompiling the source to ES5 or using an ES5 friendly syntax would enable rambdax to be used in projects suitable for legacy browsers and would also solve build problems.

@domis4
Copy link

domis4 commented Dec 11, 2017

@voodoods @selfrefactor i'm having the same problem and can't seem to find a solution. Even my hacky hotfix to compile it myself did not work, as i'm missing all the .babelrc plugins from rambdax.

exclude: [
  /node_modules(?!\/rambdax)/
]

@selfrefactor
Copy link
Owner

selfrefactor commented Dec 11, 2017

Thank you @voodoods for bringing this up. I was a bit surprised as I assumed that nobody uses this library and I am glad that I was mistaken.

Anyway, I pushed two new versions - 0.8.0 and 0.8.1

  • 0.8.0 is build against node4.0.0 and it doesn't have arrow functions. This build should work in your case. Let me know if you still face issues.

  • 0.8.1 is build against version 9.2.0

Similar issue is with Rambda - selfrefactor/rambda#52 and there we agreed to wait for the relevant Webpack bug to be fixed. That is why I approached this issue in this manner.

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

No branches or pull requests

3 participants