nieldlr / hanzi

HanziJS is a Chinese character and NLP module for Chinese language processing for Node.js
http://hanzijs.com
MIT License
375 stars 56 forks source link

[react-native] Rename data file to .js extension #40

Closed zurawiki closed 6 years ago

zurawiki commented 6 years ago

The main benefit of this PR is that it ensures Hanzi works in react native (RN) out of the box.

RN strongly encourages using the create-react-native-app toolkit to run your app. This setup comes with a predetermined webpack configuration and build system that discards many non .js file types. This was causing hanzi to fail as seen in @Dans-io issue: https://github.com/nieldlr/Hanzi/issues/38. I changed all of the data files to make sure they have a .js extension. Note that the require() calls did not have to change because a .js extension is added by default.

On the downside, we now would have large (megabytes-big) JS files in the repo which could slow down (or maybe crash) tooling we use in this project including linting, prettier formatting, Babel transpiling, and npm publishing.

This fix seems to work though from this issue https://github.com/nieldlr/Hanzi/issues/38. Therefore, I would support merging this change into master.

@nieldlr I would love your thoughts on this change. CC @Dans-io

zurawiki commented 6 years ago

Travis-ci failed because PR #37 isn't merged in yet

nieldlr commented 6 years ago

Heya @zurawiki,

firstly. Hugely thanks for jumping on this for @Dans-io. You're a legend.

I ran some tests locally and it seems like these changes didn't quite impact performance for me (I have 2017 MacBook Pro, so not sure if that might bias things for me). So I think it's save to go ahead with this change for now. If things crop up due to performance we can take a look at this again.