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
Support require fallback for strange environments #624
Comments
If I understand you correctly, currently you can add a piece of code like this to implement needed functionality:
because browserify already defers lookup to another function named |
This is going to be a bit more complex actually: ~ cat b.js
require('X');
~ browserify b.js
Error: module "X" not found from "/.../b.js" When the flag is enabled we need to defer to $name rather than freak out at bundle time. |
This can almost be done with
The problem is that ignore-missing doesn't seem to defer to an existing require call in the environment properly. |
since all the modules are getting wrapped in function(require,module,exports){} wrappers the call will always get bound to that name, you'd need to have browserify pass the re-call the function at require time, i.e the final step before throwing an error tries window.require |
@calvinmetcalf , just to be clear, we don't always want a global require to be what we defer to some places (mongodb, etc.) do not leave require as a global. |
Shouldn’t this be doable with |
Sorry, probably I got this wrong. But the std prelude searches for an already present Here for example I had to change the call to the outer require because Titanium’s implementation throws when you call it with more than one argument. |
As noted, the standard prelude already calls to a global require if a module can't be found. You should be able to implement a global require before including the browserify bundle that delegates to any (sync) source that you want, and have browserify exclude bundling the modules you don't want to bundle. Does this resolve the issue for everyone? |
I don't believe there's a way to ignore a whole module with its files currently if you don't have a local copy of it. Something like |
See: https://twitter.com/rwaldron/status/430414189413138433
Basically: there is a need to allow non-browserifieds modules to defer to another
require
function. In this example @rwaldron wanted to usenode-serialport
fromnode-webkit
's require inside of abrowserify
bundle.Solution: --require-fallback $name
Make a CLI option to fallback to an environment's require function if we did not bundle that file.
The text was updated successfully, but these errors were encountered: