Nuxt 3 livechat plugin works on dev but not on production

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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật