-
Notifications
You must be signed in to change notification settings - Fork 3k
Add support for CommonJS #3031
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
Comments
What version of ui-router are you using? The legacy versions should be returning "ui.router" when In 1.0, you should use Please see https://ui-router.github.io/guide/ng1/migrate-to-1_0#commonjs-module-name |
Thank you @christopherthielen for a comprehensive explanation. I will look into it. Maybe it is possible to use the |
I think the workaround (changing the index to Because of that, I personally think the existing setup is "good enough". I'm closing this issue, but I'm open to hearing about other possible approaches, if it can be shown that they won't cause problems with other module setups. |
I'm not sure I understand how the offered workaround could create issues, could you please elaborate on this? The |
CommonJS supports either a single default export or multiple named exports, but they are mutually exclusive (as far as I know). There are many other symbols exported from ui-router that people can currently import, e.g.,
This problem is a ES6->CJS interop issue and those modules aren't authored in ES6. |
Hmm. Do we really need to import something from the module directly? Isn't it a best practice to use configuration providers and services to interact with the module? angular.module('app', [
require('angular-ui-router')
])
.config(function (traceProvider) {
traceProvider.enable();
}) Actually, I'm not seeing something being imported from the module directly in the documentation or in the examples (at first glance). Could you give me a link where this use case is documented? |
All you have to do is add |
Hello!
Thank you for this great library!
However, right now, when this module is used in CommonJS it leads to errors, because the module returns the factory function instead of the Angular.js module's name.
Please see how this is implemented for native Angular.js router:
https://github.com/angular/bower-angular-route/blob/master/index.js
Notice how module's name is returned to the caller of
require()
.Usage example
Workaround
Right now, I have to use it this way, which is cumbersome:
Thanks!
The text was updated successfully, but these errors were encountered: