jspm / project

Roadmap and management repo for the jspm project
159 stars 8 forks source link

ReferenceError in importmap for @zoom/meetingsdk #331

Closed wbugenis closed 4 months ago

wbugenis commented 4 months ago

Hello again! When trying to use the @zoom/meetingsdk package in my project with importmap-rails, I get the following error (happens on 3.1.6, 3.1.4, and 3.1.2, I didn't try any others yet) -

ReferenceError: _ is not defined
    at Object.<anonymous> (zoomus-websdk.umd.min.js:12257:21)
    at Object.e (zoomus-websdk.umd.min.js:12151:32)
    at c (zoomus-websdk.umd.min.js:29631:29)
    at 38274 (zoomus-websdk.umd.min.js:12343:27)
    at c (zoomus-websdk.umd.min.js:29631:29)
    at 63200 (zoomus-websdk.umd.min.js:12315:29)
    at c (zoomus-websdk.umd.min.js:29631:29)
    at zoomus-websdk.umd.min.js:29799:125
    at _e (zoomus-websdk.umd.min.js:527:20)
    at 894 (zoomus-websdk.umd.min.js:29801:67)

Thanks for your help, as always!

guybedford commented 4 months ago

I think this is a library error in the Zoom SDK - it is expecting _ to be defined as a global, when modular applications shouldn't rely on globals. We try to convert CJS and global scripts into modules in JSPM, but that conversion won't do global redefinitions and can't trace globals it doesn't know about.

You can patch it manually with:

import lodash from 'lodash';
window._ = lodash;

Here's a sandbox link showing that working - https://jspm.org/sandbox#H4sIAAAAAAAAA32UW0/bMBTHn8enOGQPwERiUnaB0qIyDSEu3dCisvE0uclpY0jsyHYoLeK778RpS1ugT5F9Tn7+n2trM1GxHRcIqc2z443W7IM8Od4AaOVoOcQp1wZt2yvtwD/wnMEKm+FxT7pv0mL1ef6L5Dm2vQeBo0Jp60GspEVJiJFIbNpO8EHE6LvDLggprOCZb2KeYTukB1qsVtDqq2TsqJu+Tx+Ai+i6C2coUXOrNJznFR+6vHDW00RY6P2+alI8tjBNxoYz1+DOFHkgFPvYa9ykt2ff73909/Q4mlxEvTCNL+8uJwfsZrIX/ryKZTcaH/4a/70dhXfXN93R+UmZPR4eRr0TesX3K0HQMrEWhYUqe21POB05L0j8E5mnF8ZrwpNT5nUmSuUsR7RCDk1yTxZvLpLP1ckib666dvaDL0GDCZngIzl6uzUxUwk36SLHQSi3bGoiv+fK2TOxKnBBzBsPz42V1j7vY8Z0SeXNkWqRFagNQ5Mz1b/D2EaFpvo01sWwhOh8Cxqfg/B90ktYbwa2Aq8dOkQkbjiNdglB0NiuITh7JzwIGsEeo4wFK8l1iKR8XIsgO2loUFxomDu+Bvg2LeW6Yi94dRoB4SrYXI1jPVd13Himqah7ruq/6UzAaQRdlZQZQpSK3DRnE0GtaKBQ2XggsgwGNCoqS1BDX6uRoRLASNhUlRbEgr8pC3fYxiFEfMC1gPBrsL8z7flZy3MzljEYHbffCwqNnztVvqlUdcLgINhniTCWrZiqICHWyhilxVDItselkuNclcY7Xg14aeRqittGH6ZB1I0AA61y2KoPW0eVfUQJVaPgH7SnPtXtIv1dNMwS9InChu58JutHXk/1US0VgDH4o4VFyqyQUBNpDSa0alHjLlBFCMjBYMFpQSFQodBVhS49Sq4H3Fot+iXZlASb4oxSaw3cM7RYjcowyNRw+0XdznJ8LVbvUVqrbr//BzID8pb3BQAA

I would recommend encouraging the SDK developers not to rely on the lodash global and to move to modules!

wbugenis commented 4 months ago

Sorry this one ended up being a bit outside of your purview... I really appreciate you still taking the time to find a solution anyway. Thank you!

guybedford commented 3 months ago

Sure, and feel free to share any further issues you find, I may not respond immediately but I'll get to them when I can.