diff
diff copied to clipboard
The UMD build is not loadable into JavaScript modules strict mode context e.g. into the Chrome DevTools console
trafficstars
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/[email protected]/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: https://github.com/umdjs/umd/pull/124 https://github.com/umdjs/umd/pull/125