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
Use named define, to prevent RequireJS error. #11852
Conversation
This fixes the error 'Mismatched anonymous define() module' when another identical looking define call occurs on the same page.
Hi @MaartenStaa @sgiehl a couple of tests are failing with:
Could it be due to the removal of line endings? |
Hi @MaartenStaa |
As we haven't heard back from @MaartenStaa, will close the pull request for now. If you can, please ask us to re-open or re-create the PR answering the questions, thanks 👍 |
I can confirm that Piwik breaks Moodle js code. "Uncaught Error: Mismatched anonymous define() module: function(){return g}" Had to turn Piwik off. |
It be interesting to know if moodle maybe uses JSON3 (http://bestiejs.github.io/json3)? We define 2 modules
Any chance you can set up an HTML page where we can reproduce this issue? |
@mattab This issue is causing problems on other AMD implementations too. We are seeing this exact problem on Liferay DXP which uses its own AMD Loader implementation. |
@yuchi in case you know how to fix the issue feel free to issue a PR and we can have a look 👍 |
Hallo @tsteur, thank you for your quick reply. This PR nails the problem directly, but as far as I see it is solving it by modifying what looks to me as a generated file ( First of all let’s understand the origin of the issue. A JavaScript file can Unnamed (aka anonymous) modules are a completely different beast. Since the loader (when called through Usually you “configure” the loader by telling it that a module with the name If a random |
Since it looks like you are using JSON3 as a dependency, probably there’s some mis-configuration in your bundling process. Some thoughts without looking at the structure of the codebase here:
Those are my first ideas to where to find a culprit |
we'll remove JSON3 in Matomo 4 in #6093 anyway so might not do anything for now. IF someone wants to create a PR to fix the issue feel free to do so. Ideally it would not add much additional JS, ideally none to the JS tracker. |
After reviewing the tracker code, it appears to be hand written, and not using any bundler at all. |
Thanks for the feedback @yuchi - would you be able to re-create this PR with naming the module |
@MaartenStaa sorry about not following up in quite a while! In Matomo 4 we have now removed JSON 3 so it'll be no longer needed. Thanks though for creating this PR! |
This fixes the error 'Mismatched anonymous define() module' when another identical looking define call occurs on the same page.
In particular, this happened to me in Moodle where there was a
define(function() { return g })
from another minified Javascript, causing some kind of conflict with Piwik which happened to also be minified asdefine(function() { return g })
.