Open fuweichin opened 4 years ago
In the browser I get the error
TypeError: Cannot set properties of undefined (setting 'untar')
at untar.js:1:118
at untar.js:1:123
using https://unpkg.com/js-untar@2.0.0/build/dist/untar.js.
Currently I handle the error and continue
try {
await import('https://unpkg.com/js-untar@2.0.0/build/dist/untar.js');
} catch(e) {
console.log(e);
} finally {
// do stuff
}
The TypeError
is thrown due to
https://github.com/InvokIT/js-untar/blob/49e639cf82e8d58dccb3458cbd08768afee8b41c/src/untar.js#L5
this
is not defined in Ecmascript Modules. Substituting globalThis
avoids the error.
Overview
The UMD wrapper js-untar currently in use may cause an error in certain circumstances.
Steps to Reproduce:
jquery
andpako
are okay with native ESM loader, whilejs-untar
will throw an errorPossible Solution:
Use a more versatile variant of UMD, e.g. returnExportsGlobal.js