-
Notifications
You must be signed in to change notification settings - Fork 144
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
require.js conflict #112
Comments
Thanks for filing Nariman - I believe this is related to #99 |
@nariman-haghighi yep, we're debugging this in #99 and have some ideas here: https://github.com/keenlabs/keen-js/blob/d2ae28359b420a427c00534edfe0693f56f03c4a/test/examples/script-loaders/require/app.js#L4-L7 Care to weigh in? Would love your perspective on an effective pattern here! |
Check out #113. |
@dustinlarimer Does the CDN copy have this change now? |
Per Nariman, the same bug is still present after trying this newest version of the library. |
I'll post and update when the latest distribution has this fix – thanks! On Tue, Jul 22, 2014 at 12:56 PM, Michelle Wetzler <notifications@github.com
|
Thanks Dusitn. FWIW, we're trying the track-only build and that has the same issue, so there's no viable workaround at the moment. Do you suggest we deploy the full build from master to our own CDN and try that? |
I'll have this finished and deployed to our CDN later today – sorry for the On Tue, Jul 22, 2014 at 1:19 PM, Nariman Haghighi notifications@github.com
|
@nariman-haghighi v3.0.5 is in our CDN, and I'll publish a tagged release shortly: |
Running 3.0.5 tracking only, the error is still visible here: http://www.candid.io/joefresh.html |
@nariman-haghighi it looks like there is another anonymous Can you share a bit about your implementation method for the keen library? I'd like to understand better why it's being loaded the way it is. |
@dustinlarimer are you suggesting that we can work around the error by loading it differently? we are following the async pattern as published here to bring in your script through our widget.js: https://github.com/keenlabs/keen-js/wiki/Installation |
We don't control the require.js call on the parent page... we assume keen.io usage is safe "in the wild" when we import it through our widget.js. |
Totally understand, it just appears that the error is related to using multiple anonymous module definitions in the same file. The conflict there is that the RequireJS design pattern also insists that modules are defined anonymously, in their own file. I'm doing some research on my end to better understand what we can do to avoid this issue without breaking expectations for other implementation models. |
@nariman-haghighi this issue seems to be capturing the same issue we're seeing here: |
We can't control where our widget.js (and hence keen.js) is loaded relative to the requirejs on the parent page. I guess that leaves us with one option. We are open to a conditional import of your script that uses require/define if that works? Just let us know the pattern we can try. |
Also, it appears neither the keen lib nor your widgets.js file are loaded with RequireJS.. Is that correct? On Tue, Jul 22, 2014 at 3:59 PM, Nariman Haghighi
|
Correct. |
@nariman-haghighi there is an anonymous |
Are you referring to It's part of https://github.com/bestiejs/json3 |
Ok, gotcha – here's a couple of approaches that may work here:
Do any of these sound doable? |
What about ensuring the tracking only build doesn't depend on requirejs? Shouldn't it be safe anywhere? Our widget.js is ~10KB, adding the 15KB requirejs to load other libraries doesn't add up. |
With JSON3 removed, there is still a conflict between keen and the parent page: |
The wrapper is only designed to define itself as a module when requirejs is present, just as JSON3 does here. The conflict seems to be coming from the fact that our library is being included alongside, though not used with requirejs. I'm looking for better patterns to follow, since we can't control when, where or how we're loaded into a page. |
@nariman-haghighi would you mind giving this a try? Sorry for all the back-and-forth here, I really appreciate your help in ironing this out! |
Works! |
Excellent, I'll get it pushed out and let you know when a versioned release is available! On Wed, Jul 23, 2014 at 2:58 PM, Nariman Haghighi
|
Great, please keep that version up in the meantime. |
@nariman-haghighi v3.0.5 has been updated.. You may need to tack on a cache-buster parameter to bring in the latest: |
This has resurfaced in v3.4.0-rc. |
@elliottshort thanks for reporting - would you mind sharing a bit more about your setup? Which version of RequireJS is causing the issue, and how are you loading/configuring the library? Thanks for your help! |
Also affecting my project with 3.4.0 require.config( {
'baseUrl' : 'app',
'paths' : {
'keen' : "../lib/keen-js/dist/keen"
},
...
} ); 'use strict';
require( [ "angularAMD", "keen" ], function( angularAmd, Keen )
{
angularAmd.service( 'AnalyticsService', function()
{
return Keen;
} );
} ); I immediately load it into my AngularAMD project. If I refresh without clearing cache, everything then loads fine. If I clear cache, it dies. Edit: For now, I am ditching the library because I only need a small set of functions. Instead, I am just directly hitting your api. |
@centaur2048 sorry to hear about this– which version of requirejs are you using? |
Requirejs version: 2.1.16 |
No resolution. I am at the point where I want to begin using your chart libraries; so, would be nice to resolve this. I just pulled 3.4.1-RC4 and the issue still persists. Also using RequireJs 2.2.0 now. |
@centaur2048 Google Charts shipped a UMD/RequireJS bug that has been causing intermittent and difficult-to-debug crashes, so we just recently shipped a version of keen-js that omits GC entirely. Please give this file a try and let me know how it goes: |
Excellent! Tested with both As this version omits GC, does it have any limitations? Will I not be able to render charts with it? |
Closing now– this issue has stood open for a long time as a point of reference for others struggling with the issue, but now our v3 docs should properly highlight the issue. Thanks again @nariman-haghighi @agrapsas for the help here! |
UPDATE: Read the resolution below
The issue is reproduced here:
http://www.candid.io/joefresh.html
The JS error is referencing this doc: http://requirejs.org/docs/errors.html#mismatch
We've done a number of integrations with our script (http://api.getcandid.com/scripts/widget.js) which references keen 3.0.4... this is the first conflict we've seen.
Any ideas would be appreciated.
The text was updated successfully, but these errors were encountered: