The UMD build is not loadable into JavaScript modules strict mode context e.g. into the Chrome DevTools console
sompylasar opened this issue · comments
I'm trying to use deep-diff
in the Chrome DevTools debugger to compare two objects while sitting paused on a breakpoint, for that I'm trying to use import()
to load deep-diff
into the page to use it later via a global variable when paused.
To reproduce the failure to load, try running this in Chrome DevTools console (Chrome 67):
import('https://unpkg.com/deep-diff@1.0.1/index.js').then((module) => { console.log(module) })
Actual:
Uncaught (in promise) TypeError: Cannot set property 'DeepDiff' of undefined
at index.js:521
at index.js:2
at index.js:23
Expected: it loads fine and prints the module exports.
Here's what needs to change in the UMD wrapper:
- }(this, function (root) {
+ }(typeof self !== 'undefined' ? self : this, function (root) {
Related: umdjs/umd#124 umdjs/umd#125