browserify / browserify/wzrd.in
Allow optional requires
- Dominant language
- JavaScript
- Stars
- 637
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
I am attempting to use browserify-cdn to bundle the NPM module [cucumber](https://www.npmjs.com/package/cucumber), however I receive the following error:
Error: "browserify exited with code 1"
code: 1
stderr: Error: Cannot find module 'graceful-fs' from '/tmp/cucumber120310-6085-1fs7afr.h95u/node_modules/cucumber/node_modules/mz'
at /home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
at process (/home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
at ondir (/home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
at load (/home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /home/wzrd/wzrd.in/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:153:21)
After further investigation, I identified the following lines of code within a dependency [mz](https://github.com/normalize/mz/blob/master/fs.js#L4):
try {
fs = require('graceful-fs')
} catch(err) {
fs = require('fs')
}
Would it be possible to add the [browserify-optional](https://github.com/devongovett/browserify-optional) transform into browserify-cdn to support this situation? Perhaps there could be a flag to enable this as an optional configuration?
Alternatively the built-in `ignoreMissing` option may work for my use case. Would it be possible to add support to allow this option to be passed into the bundler?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how browserify-cdn invokes the bundler and how bundler options are passed. Review the browserify-optional transform and the built-in ignoreMissing option mentioned in the issue, then determine which approach fits. Done means optional requires like mz's graceful-fs fallback bundle successfully, with the chosen configuration exposed by browserify-cdn.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- build-system, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100