IjzerenHein / react-native-bundle-visualizer

See what packages are increasing your react-native bundle size 📦
MIT License
1.44k stars 42 forks source link

Module parse failed: Unexpected token #16

Closed el-lsan closed 4 years ago

el-lsan commented 5 years ago

I'm getting following error:

./node_modules/redux-persist-filesystem-storage/index.js 10:19
Module parse failed: Unexpected token (10:19)
You may need an appropriate loader to handle this file type.
|   storagePath: `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`,
|   encoding: 'utf8',
>   toFileName: (name: string) => name.split(':').join('-'),
|   fromFileName: (name: string) => name.split('-').join(':'),
| }
@ ./src/store/index.js 1:396-439
@ ./index.js

This is the line which it complains: https://github.com/robwalkerco/redux-persist-filesystem-storage/blob/master/index.js#L10

Any idea how to fix this ?

I'm using: node v8.11.4 react-native : ^0.59.4 react: ^16.8.6

webytecno commented 5 years ago

I was facing the same issue, but I really needed this library to know which bundle was increasing my app size. I found out, there's a file called haul.config.js inside the package, where you can exclude certain packages from "node_modules" for the analysis.

So I added there the two packages I wanted to exclude, and now it works like a charm.

You have to modify the line 11, in my case, I excluded native-base-shoutem-theme and redux-persist-fs-storage, which was causing the trouble: config.module.rules[1].exclude = /node_modules(?!.*[\/\\](react|@react-navigation|**native-base-shoutem-theme|redux-persist-fs-storage**|@react-native-community|@expo|pretty-format|haul|metro))/;

Of course is not a "REAL" solution, but it can help you to achieve what you're trying to do.

Hope it helps!

el-lsan commented 5 years ago

@webytecno Thanks for sharing your solution! cheers 🍻

IjzerenHein commented 4 years ago

Hi, a new V2 version has been created which most likely solves this problem as well: https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2

IjzerenHein commented 4 years ago

Closing as the problem described was a Haul related problem and V2 has been released which uses the Metro bundler