enkidevs / react-search-input

:mag: Simple react.js component for a search input, providing a filter function.
302 stars 72 forks source link

Using the src directory instead of the lib directory #100

Open camlough opened 7 years ago

camlough commented 7 years ago

My project seems to be pulling the code from the src directory, which is es6. This is causing the following error: Module parse failed: .../node_modules/react-search-input/src/index.js Unexpected token

This is being cause by the spread operator.

Any idea why my project isn't pulling the code from the lib directory instead?

mathieudutour commented 7 years ago

are you using rollup? It's probably following this: https://github.com/enkidevs/react-search-input/blob/master/package.json#L6

camlough commented 7 years ago

I don't believe i'm using rollup. But that line is clearly what is causing my issue. My solution for now is just to include node_modules in my webpack babel loader

breezykermo commented 7 years ago

This happens for me when installing in conjunction with the latest react boilerplate as well. I get the following error when trying to run webpack:

ERROR in ./node_modules/react-search-input/src/index.js
Module parse failed: /Users/lachlankermode/freelance/cult/plastic-anthony/node_modules/react-search-input/src/index.js Unexpected token (50:112)
You may need an appropriate loader to handle this file type.
| 
|   render () {
|     const {className, onChange, caseSensitive, sortResults, throttle, filterKeys, value, fuzzy, inputClassName, ...inputProps} = this.props // eslint-disable-line no-unused-vars
|     inputProps.type = inputProps.type || 'search'
|     inputProps.value = this.state.searchTerm
 @ dll reactBoilerplateDeps

I fixed this for the time being by removing "src" from the "files" field in the module's package.json, and modifying the "jsnext:main" value from "src/index.js" to "lib/index.js". This allows Babel to parse the file without errors... possibly related to https://github.com/jsforum/jsforum/issues/5

(nb: you can use my fork of the repo if you need it before this get fixed in the NPM package)