selfrefactor / rambdax

Extended version of Rambda
https://selfrefactor.github.io/rambdax
MIT License
221 stars 26 forks source link

Provide ES5 precompiled source #4

Closed voodoods closed 6 years ago

voodoods commented 6 years ago

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: https://github.com/facebookincubator/create-react-app/issues/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: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/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 commented 6 years ago

@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 commented 6 years ago

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

Similar issue is with Rambda - https://github.com/selfrefactor/rambda/issues/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.