andrewplummer / Sugar

A Javascript library for working with native objects.
https://sugarjs.com/
MIT License
4.53k stars 305 forks source link

can't use sugar or sugar-core npm modules if Sugar is already loaded globally on the page #690

Open bradgearon opened 1 month ago

bradgearon commented 1 month ago

if I have Sugar loaded globally on a page and then try to use one of the modules sugar or sugar-core in one of my modules it throws an error:

TypeError: Cannot read properties of undefined (reading 'hasOwn') at ../node_modules/sugar/common/var/coreUtilityAliases.js (coreUtilityAliases.js:6:1)

this is because if core.js finds Sugar as existing on the global or window object it won't set the module.exports to anything

I have a pull request that will make it still set module.exports when it find's the existing Sugar module I will submit to close this issue