I would start with
console.log(parsedModule);
console.log(window[`${parsedModule.type}Module`]);
before let newModule = new ...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
For loading additional modules with JS in Vue components I have this error currently
undefined is not a constructor
(evaluating 'new(window[o.isExtendModule?"Module":""
.concat(o.type,"Module")])(o.type)')
This error shows in the application notification on loading of the project in the editor.
It is related to this piece of code
...
addGridModulesToCurrentPage(modules) {
this.pageInstance.removeGridModules();
for(var i = 0; i < modules.length; i++) {
var moduleJSON = modules[i].json;
var parsedModule = JSON.parse(moduleJSON);
// Create new moduleinstance and add it to current page module list.
let newModule = new window[parsedModule.isExtendModule ? `Module` : `${parsedModule.type}Module`](parsedModule.type);
newModule.fillFromJSON(moduleJSON);
// Update id to same in database
newModule.id = modules[i].id
newModule.isGridModule = true;
newModule.isVisible = true
...
this.$store.dispatch('editor/addModule', newModule)
}
},
...
and especially line
let newModule = new window[parsedModule.isExtendModule ? `Module` : `${parsedModule.type}Module`](parsedModule.type);
Either that or
...
// module plugin specific settings if available
let settingHTML = `/modulesettings/${this.moduleInstance.type}Module.html?ver=${window.EDITOR_ASSETS_VERSION}`
if (this.moduleInstance.isExtendModule) {
settingHTML = `/editor/extend-module/${this.moduleInstance.type}/settings?ver=${window.EDITOR_ASSETS_VERSION}`
}
...
The extended modules modules are added. Only thing they seem to miss is their icons.
This error is not caught in Bugsnag nor in console.. only loads briefly in notification bar it seems.
@rhand you can log it and ignore if it's okay for you
let newModule = null;
if (parsedModule.isExtendModule) {
newModule = new window['Module'](parsedModule.type);
} else if (typeof(window[ `${parsedModule.type}Module`]) === 'undefined') {
continue;
} else {
newModule = new window[`${parsedModule.type}Module`](parsedModule.type);
}
or throw some more explaining exception
let newModule = null;
if (parsedModule.isExtendModule) {
newModule = new window['Module'](parsedModule.type);
} else if (typeof(window[ `${parsedModule.type}Module`]) === 'undefined') {
throw new Error(`Unknown module "${parsedModule.type}Module"`);
} else {
newModule = new window[`${parsedModule.type}Module`](parsedModule.type);
}
Please or to participate in this conversation.