bvaughn / react-highlight-words

React component to highlight words within a larger body of text
https://bvaughn.github.io/react-highlight-words/
MIT License
2.16k stars 170 forks source link

dist is very large #86

Open Daniel15 opened 5 years ago

Daniel15 commented 5 years ago

dist/main.js is 57 KB: https://unpkg.com/react-highlight-words@0.16.0/dist/. Looking at the JS file, it appears to have chunks of React init (eg. PropTypes): https://unpkg.com/react-highlight-words@0.16.0/dist/main.js

If I use your code from Git rather than npm, it shaves 13 KB off the minified size, mainly due to no longer including duplicate modules in the bundle, and PropTypes properly using the production mode. In my package.json I'm doing:

"react-highlight-words": "bvaughn/react-highlight-words#2d214bd70182a4ca95d50f18e74bd821e0847dcd"

Would it be possible to publish an ES6 Module version to npm too, so as to not introduce duplicate modules to apps that want to use this one?

Thanks!

bvaughn commented 5 years ago

Haven't used this library in years. No current plans to update it and no desire to maintain it. Would be happy to give you permission to publish an update though if you'd be interested?

Daniel15 commented 5 years ago

Thanks for the reply! Unfortunately I don't think I'll get any time to look into it any time soon :( I ended up using a different library instead.

jseminck commented 4 years ago

I've noticed the same and tried to spend some time to reduce the bundle size, however I'm not able to get anywhere with adding this babel plugin: https://www.npmjs.com/package/babel-plugin-transform-react-remove-prop-types

Could it be because the version of babel is too old (babel 5.x)?

ModuleBuildError: Module build failed: TypeError: The plugin "transform-react-remove-prop-types" didn't export a Plugin instance
    at PluginManager.validate (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-core/lib/transformation/file/plugin-manager.js:164:13)
    at PluginManager.add (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-core/lib/transformation/file/plugin-manager.js:213:10)
    at File.buildTransformers (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-core/lib/transformation/file/index.js:237:21)
    at new File (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-core/lib/transformation/file/index.js:139:10)
    at Pipeline.transform (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
    at transpile (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-loader/index.js:12:22)
    at Object.module.exports (/Users/joachimseminck/git/react-highlight-words/node_modules/babel-loader/index.js:71:12)
    at NormalModule.onModuleBuildFailed (/Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at runSyncOrAsync (/Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:173:4)
    at nextLoader (/Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:290:3)
    at /Users/joachimseminck/git/react-highlight-words/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
    at Storage.finished (/Users/joachimseminck/git/react-highlight-words/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at /Users/joachimseminck/git/react-highlight-words/node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)