-
Notifications
You must be signed in to change notification settings - Fork 421
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
AMD Consistency #211
Comments
I think these are good suggestions and will mark it for 1.2. The problem is, that when changing the module return value all the code referencing that module (AMD or Steal) needs to be changed. We also need a way of documenting the module return values. Also, EJS and Mustache have to return then |
While it's not about consistency, I actually noticed another dependency-related issue. |
For 1.2 I also want to remove the global |
People can overwrite the can module to require other things. I don't think we should remove the global can: https://twitter.com/TalentedMrJones/status/309481689468506112 |
on |
http://bugs.jquery.com/ticket/10545
|
We have a very large website. Now for the little apps we use canjs 1.0.5. For a new module we are currently canjs 1.1.5 (the AMD-version). The problem that we are having right now is that if I'm loading the topnav in the new module then the global can is being overridden with two versions of canjs. No I was hoping that if I updated these little apps to an AMD version I could contain the version of canjs within the scope of that script. But if this isn't the case like mentioned above I have to rewrite these little apps so they can work without canjs because for future modules we want to use future code of canjs. But there isn't always the time to update the topnav to the new version and certainly is no time to update all old canjs-modules. Because of this, I think it's better to remove can from the global scope. edit: |
I think GLOBALCAN is a good enough solution for now. If someone has problems with this, we can add can.noConflict() type thing that restores the original can. I'm not sure why AMD would complain though ... as long as you are using the can passed to you, you should be fine. |
This topic came up briefly in a previous AMD issue.
In AMD it's typical for a module to return a handle to the functionality it provides. It becomes a little less clear what to do when the module represents a plugin or there is a centralized namespace also receiving the functionality like with CanJS.
I think the important thing is to be consistent and CanJS is not quite so.
Observe
plugins, i.e.can/observe/*
, return a handle toObserve
orObserve.List
, which I think makes sense; howeverControl
andConstruct
plugins, i.e.can/construct/*
andcan/control/*
, return a handle tocan
instead. I think it would be more consistent if they returnedConstruct
andControl
respectively.While
can/util/deferred
provides bothcan.Deferred
andcan.when
, thewhen
method is also added to theDeferred
object, which means you could return justDeferred
from the module.All of the core modules, i.e.
can/*
, return appropriate handles, e.g.can/route
returnsroute
, except forcan/view
which returnscan
instead ofview
.The
can/view/ejs
andcan/view/mustache
modules both returncan
. At the very least they should probably returnview
but there's probably an argument to be made that they should returnEJS
andMustache
respectively.There may be other modules one could argue for a change in what is returned, but these were the ones that stood out to me.
In regards to
EJS
andMustache
, now that CanJS has more than integratedview
engine, thecan
module dependencies should be updated. Currently it includescan/view/ejs
. Either it should...can/view
and force the developer to pick an enginecan/view/library
similar tocan/util/library
, which defaults toEJS
but would allow the developer to override it with a configuration mapping.The latter seems more in line with what CanJS has already done.
The text was updated successfully, but these errors were encountered: