[BUG] Requirejs complains Mismatched anonymous define() after upgrade to 1.21.1 related to cssTokenizer
See original GitHub issueContext:
- Playwright Version: 1.21.1
- Operating System: Windows, Linux & Mac
- Node.js version: 14.17.0
- Browser: Chromium
- Extra: This was working with Playwright versions 1.20.1
Describe the bug Under certain conditions, when running a test and launching the browser, I see this in the console
[2022-06-02T16:34:42.594Z] [console] [log] http://HOST/documents/static/gemini/js/main-a95442e.cache.js (0,101691)
[2022-06-02T16:34:42.594Z] [console] WebClient RequireJS Error - Type: mismatch Modules: undefined
[2022-06-02T16:34:42.594Z] [pageerror] Mismatched anonymous define() module: function(exports2) {
[2022-06-02T16:34:42.594Z] var between = function(num, first, last) {
[2022-06-02T16:34:42.594Z] return num >= first && num <= last;
[2022-06-02T16:34:42.594Z] };
[2022-06-02T16:34:42.594Z] function digit(code) {
If I inspect the code on the launched chrome browser, I see that there is injected code by playwright that seems to cause this issue
// packages/playwright-core/src/server/isomorphic/cssTokenizer.js
var require_cssTokenizer = __commonJS({
"packages/playwright-core/src/server/isomorphic/cssTokenizer.js"(exports) {
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define(["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
factory(root);
}
})(exports, function(exports2) {
This happens right when we run this piece of code on our side
require(['jquery', 'underscore', 'backbone', 'core/init'], function($, _, Backbone, init) {
init.start();
});
On reloading the page, this issue disappears.
We do have other bundles that are loaded as a result of the require code. The exact file loaded inside a bundle when this issue happens has the following require header:
define([
'jquery',
'underscore',
'core/osnGlobals',
'ojs/ojcore',
'knockout',
'core/home/AppHomeViewModel',
'core/view/BaseView',
'core/home/AppHomeView.template',
'css!geminiCss/gemini-home'
], function($, _, osn, oj, ko, AppHomeViewModel, BaseView, renderAppHomeViewTemplate) {
"use strict";
Our require config has the following paths
paths: {
underscore: '../node_modules/underscore/underscore',
backbone: '../node_modules/backbone/backbone',
i18n: '../libs/i18n',
gdk: '../libs/gdk/GDKFormat_1_0_0_130930_1',
jquery: '../libs/jet/12.1.1/3rdparty/jquery/jquery-3.6.0.min',
'jqueryui-amd': '../node_modules/jquery-ui/ui',
knockout: '../libs/jet/12.1.1/3rdparty/knockout/knockout-3.5.1',
hammerjs: '../libs/jet/12.1.1/3rdparty/hammer/hammer-2.0.8.min',
ojdnd: '../libs/jet/12.1.1/3rdparty/dnd-polyfill/dnd-polyfill-1.0.2.min',
signals: '../libs/jet/12.1.1/3rdparty/js-signals/signals.min',
"preact/compat": '../libs/jet/12.1.1/3rdparty/preact/compat/dist/compat.umd',
"preact/hooks": '../libs/jet/12.1.1/3rdparty/preact/hooks/dist/hooks.umd',
preact: '../libs/jet/12.1.1/3rdparty/preact/dist/preact.umd',
text: '../libs/jet/12.1.1/3rdparty/require/text',
css: '../libs/jet/12.1.1/3rdparty/require-css/css.min',
ojs: '../libs/jet/12.1.1/default/js/min',
ojL10n: '../libs/jet/12.1.1/default/js/ojL10n',
ojtranslations: '../libs/jet/12.1.1/default/js/resources',
},
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
RequireJS Error: Mismatched Anonymous Define() Module
Templates with scripts that leverage RequireJS code and were working prior to upgrading to 9.0 now show an error in the console of...
Read more >Mismatched anonymous define() module - Stack Overflow
The requirejs file was loading asynchronously so I suspect that the require's define was defined after the other libraries define, hence the ...
Read more >Common Errors - RequireJS
Mismatched anonymous define() modules . ... you manually code a script tag in HTML to load a script with an anonymous define() call,...
Read more >Uncaught Error: Mismatched anonymous define() module
After that use this file again in this path = app/code/Sample/Module/view/adminhtml/web/js/restore-order.js where you are defining it
Read more >Mismatched anonymous define() module error when using ...
I understand that RequireJS is a JavaScript file and module loader, but I know very little about javascript; so any suggestions for the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same issue with version 1.21.1 and 1.22.2.
With 1.20.2 not problem ! 🎉
Full requirejs error log :
Console log
Same issue with v1.24.1