Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional requires #203

Open
stevenmhunt opened this issue Apr 10, 2020 · 1 comment
Open

Allow optional requires #203

stevenmhunt opened this issue Apr 10, 2020 · 1 comment

Comments

@stevenmhunt
Copy link

stevenmhunt commented Apr 10, 2020

I am attempting to use browserify-cdn to bundle the NPM module 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:

try {
  fs = require('graceful-fs')
} catch(err) {
  fs = require('fs')
}

Would it be possible to add the 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?

@stevenmhunt
Copy link
Author

Update: I was able to find browser-compatible copies of what I wanted, however I think the idea of allowing a way of setting ignoreMissing could still be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant