I have a Nuxt 3 plugin a chat one the file name is chat.client.ts here is the script I have changed the url so that the company name wont be exposed. this code works fine when running on a dev mode but after building it fails
const cssLink = document.createElement("link");
cssLink.rel = "stylesheet";
cssLink.href = "https://x.com/im_livechat/external_lib.css";
document.head.appendChild(cssLink);
const script = document.createElement("script");
script.src = "https://x.com/im_livechat/external_lib.js";
script.onload = () => {
odoo.define("web.session", function (require) {
const Session = require("web.Session");
const modules = odoo._modules;
return new Session(undefined, "https://x.com", { modules: modules, use_cors: true });
});
odoo.define("im_livechat.livesupport", function (require) {
const rootWidget = require("root.widget");
const im_livechat = require("im_livechat.legacy.im_livechat.im_livechat");
const button = new im_livechat.LivechatButton(rootWidget, "https://x.com", {
header_background_color: "#4E6C62",
button_background_color: "#4E6C62",
title_color: "#FFFFFF",
button_text_color: "#FFFFFF",
button_text: "Chat",
input_placeholder: false,
default_message: "Hello, before we continue, can I please have your email address ?",
channel_name: "Main Chat",
channel_id: 1,
current_partner_id: 4,
default_username: "Visitor",
});
button
.appendTo(document.body)
.then(() => {
window.livechat_button = button;
// Ensure the button is properly appended before triggering the click
nextTick();
})
.catch((error) => {
console.error("Failed to append the livechat button:", error);
});
});
};
document.body.appendChild(script);
here is the error:
TypeError: Cannot read properties of undefined (reading 'static')
external_lib.js:3296 Undefined dependency: web.Session
require @ external_lib.js:3296
(anonymous) @ BcV-9UXX.js:58
(anonymous) @ external_lib.js:3292
processJob @ external_lib.js:3292
odoo.processJobs @ external_lib.js:3300
odoo.define @ external_lib.js:3278
t.onload @ BcV-9UXX.js:58
load (async)
(anonymous) @ BcV-9UXX.js:58
iI @ BcV-9UXX.js:58
(anonymous) @ BcV-9UXX.js:18
r @ BcV-9UXX.js:18
runWithContext @ BcV-9UXX.js:14
sw @ BcV-9UXX.js:18
(anonymous) @ BcV-9UXX.js:18
run @ BcV-9UXX.js:10
runWithContext @ BcV-9UXX.js:18
rw @ BcV-9UXX.js:18
a @ BcV-9UXX.js:18
ow @ BcV-9UXX.js:18
await in ow (async)
Lp @ BcV-9UXX.js:63
(anonymous) @ BcV-9UXX.js:63
external_lib.js:3291 Error while loading web.session: r is not a constructor TypeError: r is not a constructor
at BcV-9UXX.js:58:45150
at external_lib.js:3292:63
at new Promise (<anonymous>)
at processJob (external_lib.js:3292:9)
at odoo.processJobs (external_lib.js:3300:1)
at odoo.define (external_lib.js:3278:161)
at t.onload (BcV-9UXX.js:58:45069)
...
external_lib.js:3296 Undefined dependency: im_livechat.legacy.im_livechat.im_livechat
I have checked the sources the script is there, the network works the versions are same