rsms / js-lru

A fast, simple & universal Least Recently Used (LRU) map for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minifying problem with create-react-app build

opened this issue · comments

Thanks for this really useful library!

My project was created from FB create-react-app. When trying to prepare the production bundle the build step fails due to minifying issue with js-lru. I'm quoting their explanation for the error:

Some third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years.

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify

# npm run build
...
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/lru_map/lru.js:85

Read more here: http://bit.ly/2tRViJ9

Same here with webpack v3.8.1:

ERROR in yappy.min.js from UglifyJs
Unexpected token: name (entry) [./node_modules/lru_map/lru.js:85,0][yappy.min.js:111219,6]

Is there a workaround?

UPD
Got it working by telling babel to transpile node_modules/lru_map. Loader example in case anyone needs it:

{
    test: /\.js(x)?$/,
    loader: 'babel-loader',
    include: [
        ...
        path.resolve(__dirname, 'node_modules/lru_map'),
    ]
}

Fixed in 2bd7270