Skip to content

Commit 7713260

Browse files
committed
Lazy reference zip.js
This change will allow a commonJs environment build, where zip.js is loaded later then perf-cascade import itself
1 parent 23ca585 commit 7713260

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/ts/file-reader.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Har } from "har-format";
22

3-
declare const zip: any;
4-
53
// use zip
6-
zip.useWebWorkers = false;
4+
const getConfiguredZipJs = () => {
5+
const zip = window["zip"] || {};
6+
zip.useWebWorkers = false;
7+
return zip;
8+
};
79

810
/** handle client side file upload */
911
export function readFile(file: File,
@@ -25,6 +27,8 @@ export function readFile(file: File,
2527

2628
/** start reading the file */
2729
const extension = (fileName.match(/\.[0-9a-z]+$/i) || [])[0];
30+
const zip = getConfiguredZipJs();
31+
2832
if ([".zhar", ".zip"].indexOf(extension) !== -1) {
2933
/** zhar */
3034
zip.createReader(new zip.BlobReader(file), (zipReader) => {

0 commit comments

Comments
 (0)