-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
dynamic requires don't find files in the browser #377
Comments
Browserify can only analyze static requires. It is not in the scope of browserify to handle dynamic requires. |
You should still get a compile-time error rather than a runtime error. |
@substack Thanks for the answer. That's what I assumed, and now have moved to using browserify only in the apps that depend on the libraries. For future reference, when I have questions like this, do you prefer issues or is there an irc room or message board? I assume that you don't want me to contact you via Twitter or email. |
Just as a reference, got around with this with a hacky solution: http://stackoverflow.com/questions/21642398/compiling-dynamically-required-modules-with-browserify/27672458#27672458 |
hey @substack, is there a specific reason this isn't in scope? I mean, it's a fairly easy use case to have an array of items, and do a simple forEach to require them in... is there something under the hood that is breaking on this, and if so, can I take a look at it for you? |
@therebelrobot you can use a transform like bulkify to do that. |
I'm trying to use the below umd syntax which uses a dynamic require statement:
Do you know if I van use bulkify to do this? |
@kyle-dorman bulkify doesn't understand AMD. You can only give it globs of paths to require. |
Ah ya that makes sense. I think I framed my question incorrectly. This form of UMD uses dynamic require dependancies for CommonJS syntax.
I know this is not supported by Browserify but are you aware of any existing modules that can determine module dependancies for dynamic require statements? |
I'm trying to require a file dynamically.
I have a parse method which parses the DOM for data-view and requires that file.
I then get the following error in the browser "Error: Cannot find module './views/root'". It works when I execute the code in node.js.
The text was updated successfully, but these errors were encountered: