How to specify browser extension in .json package?
In package.json:
...
"browserify": {
"transform": [
"coffee-reactify"
],
"extension": [ ".cjsx", ".coffee", ".js", ".json" ],
"extensions": [ ".cjsx", ".coffee", ".js", ".json" ]
},
...
When using the browser function it transform
works as expected, however the browser doesn't see the option extension(s)
- it throws an error and I need to pass the extension parameters manually to the browser ...
in gulpfile.coffee
b = browserify
entries: './' # ./ = root = directory where package.json is
debug: true
b.bundle()
.pipe(source('client.js'))
.pipe(buffer())
.pipe(gulp.dest(distDir))
in package.json
"browser": "src/client/client",
"browserify": {
"transform": [
"coffee-reactify"
],
"extension": [
"cjsx",
"coffee",
"js",
"json"
]
},
Cci / client / client.cjsx
otherModule = require './other-module' # other-module.cjsx
-
When I remove
coffee-reactify
fromtransforms
in package.json then loop through the error throwParsing file .../src/client/client.cjsx: Unexpected token (2:16)
-
When I return
coffee-reactify
totransforms
in package.json, then the browser will parse successfullyclient.cjsx
unless I need other.cjsx
files fromclient.cjsx
. So, for the example codeclient.cjsx
above, the browser is throwing an error:Cannot find module './other-module' from '/src/client
- the browser still doesn't recognize the extension ...
So the browser view reads package.json (recognizes package.browserify.transforms and package.browser but doesn't recognize extensions)
source to share
Try the following:
"browserify": {
"transform": [
"coffee-reactify"
],
"extension": [
"cjsx",
"coffee",
"js",
"json"
]
},
Delete points .
. Take a look at this question .
source to share