-
Notifications
You must be signed in to change notification settings - Fork 304
Can't use Component modules with a RequireJS environment #627
Comments
Switchery uses ComponentJS as its dependency and build mechanism. There's a compatability issue when a module built with ComponentJS is loaded with dependencies by RequireJS. The fix changes the standalone dist/switchery.js file directly, which is a bad idea. We need to find a better solution for this issue. See componentjs/component#627
No FastClick, provides this to support several module loaders, so this part has nothing to do with component.
no this is wrong, component is throwing an error if a module could not be loaded. It looks like someone is using something wrong, but I'm not sure yet. |
OK, sorry for throwing you in the wrong direction then. See this issue: abpetkov/switchery#22 , if it helps at all... Thanks! |
@timaschew Any news on this issue? Thanks! |
I think this is a switchery/fastclick issue? |
I don't think so - Switchery uses Component as its build/dependency system. It depends on FastClick. |
okay whatever the comment did said: abpetkov/switchery#22 (comment) I tried out to install switchery via
Then I run |
Did you try to build a standalone version of switchery (through component, it has a Makefile and can be built with make standalone), and then require it with RequireJS? It doesn't work. The problem is not with FastClick, It happened to me when I added Hammer.js to Switchery as well (I forked it). The problem is with the fact that Component concatenates all the dependencies when building a standalone file, and then RequireJS breaks when you try to load require Switchery with it. Thanks for the help! |
I think that's a feature, it's by design that you cannot require something from a standalone output, that's why it's called standalone |
So there's no way to use RequireJS to load code that uses Component as a build/dependency system (like Switchery)? |
there is, if you don't use |
Thanks. How can I do that? |
sorry, that was wrong So, if you would use component to build something on top of Switchery, the you should avoid So if you have still a problem provide a script or a repository, how I can reproduce your problem. |
Hi,
I'm trying to use a Component-based module (https://github.com/abpetkov/switchery) with a RequireJS environment.
I'm obviously using the dist/switchery.js files that I guess is called standalone in Component.
The thing is, Switchery depends on FastClick. Somewhere in the standalone dist JS file there is this code:
I guess this is concatenated by Component from the FastClick lib itself.
The first if statement is executed of course (Since define exists because we use a RequireJS environment), and an anonymous RequireJS module is anounced.
The other statements (else if and else) are not executed of course.
This causes 2 major issues:
I gave Switchery as an example, but I believe this happens with all Component builds for modules that have dependencies, and used in a RequireJS environment.
Any input on this issue would be much appreciated!
Thanks,
Bar.
The text was updated successfully, but these errors were encountered: