Skip to content

Commit 144efe4

Browse files
authored
Fix JSZip dynamic import for esbuild (#5858)
Previously webpack was always using the CommonJS modules and had a transform for ES modules. JSZip is a CommonJS module, but it looks like now esbuild returns an ES module namespace object for dynamic imports of CommonJS modules. Because of that, the JSZip import contents live inside .default. I checked other dynamic imports too and it looks like this is the only one that is affected. [Before](https://profiler.firefox.com/from-url/https%3A%2F%2Ffirefox-ci-tc.services.mozilla.com%2Fapi%2Fqueue%2Fv1%2Ftask%2Faq0v3RbWRP62PNONPZ3kkQ%2Fruns%2F0%2Fartifacts%2Fpublic%2Ftest_info%2Fprofile_speedometer3.zip) / [After](https://deploy-preview-5858--perf-html.netlify.app/from-url/https%3A%2F%2Ffirefox-ci-tc.services.mozilla.com%2Fapi%2Fqueue%2Fv1%2Ftask%2Faq0v3RbWRP62PNONPZ3kkQ%2Fruns%2F0%2Fartifacts%2Fpublic%2Ftest_info%2Fprofile_speedometer3.zip)
1 parent 6a096f1 commit 144efe4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/actions/receive-profile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ async function _extractZipFromResponse(
11781178
// that comes from this realm.
11791179
const typedBuffer = new Uint8Array(buffer);
11801180
try {
1181-
const JSZip = await import('jszip');
1181+
const { default: JSZip } = await import('jszip');
11821182
const zip = await JSZip.loadAsync(typedBuffer);
11831183
// Catch the error if unable to load the zip.
11841184
return zip;
@@ -1369,7 +1369,7 @@ export function retrieveProfileFromFile(
13691369
if (_deduceContentType(file.name, file.type) === 'application/zip') {
13701370
// Open a zip file in the zip file viewer
13711371
const buffer = await fileReader(file).asArrayBuffer();
1372-
const JSZip = await import('jszip');
1372+
const { default: JSZip } = await import('jszip');
13731373
const zip = await JSZip.loadAsync(buffer);
13741374
await dispatch(receiveZipFile(zip));
13751375
} else {

0 commit comments

Comments
 (0)