browserify / watchify

watch mode for browserify builds
Other
1.79k stars 181 forks source link

`extension` option not working #133

Closed srph closed 9 years ago

srph commented 9 years ago

I have this package.json:

{
  "scripts": {
    "build": "browserify ./src/App.js > dist/script.js -v -d",
    "watch": "watchify ./src/App.js -o dist/script.js -v -d"
  },
  "browserify": {
    "extension": [ "jsx" ],
    "transform": [ [ "reactify", { "es6": true } ] ]
  }
}

npm run build (browserify) works as intended, reading .jsx files without specifying the extension (require('./components/Yolo') works where in Yolo is a jsx file, Yolo.jsx). However, watchify throws an error:

Error: Cannot find module './components/Carousel/Carousel' from '/Users/Froilan/_/j/src'

I tried adding --extension=.jsx to the watch command which works. However, I'd like to put the extension option away to make the commands DRY and clean as possible

"watch": "watchify ./src/App.js --extension=.jsx -o dist/script.js -v -d"

Is there anything I am doing wrong? Thanks.

zertosh commented 9 years ago

npm run build probably isn't working either, you just can't see it because you're swallowing the error with the -v for version. You need to specify --extension for both. "extension" in the browserify field doesn't work. This should do it and keep it "symmetrical" looking:

  "scripts": {
    "build": "browserify ./src/App.js --extension=.jsx --verbose -d > dist/script.js",
    "watch": "watchify ./src/App.js --extension=.jsx --verbose -d -o dist/script.js"
  },
  "browserify": {
    "transform": [ [ "reactify", { "es6": true } ] ]
  }
srph commented 9 years ago

Oh, I see. I apologize for not closing this issue asap when this has been answered in Stack Overflow.

Thanks :+1: