gildas-lormeau/zip.js

TypeError: Class extends value undefined is not a constructor or null

maulikpatel-in opened this issue · 1 comments

`
zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:424
class Crc32Stream extends TransformStream {
^

TypeError: Class extends value undefined is not a constructor or null
at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:424:28
at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:4:77
at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:5:3
at ModuleJob.run (internal/modules/esm/module_job.js:145:37)
at async Loader.import (internal/modules/esm/loader.js:182:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5)
`

I'm using npm i @zip.js/zip.js and just import library with:

`
// tried first:
import * as zip from "@zip.js/zip.js";

// tried second:
import * as zip from "./node_modules/@zip.js/zip.js/dist/zip-fs.js";
`

node version: v12.22.3

The runtime you're using does not support the TransformStream API. You can circumvent this issue by importing web-streams-polyfill in your project and add the required classes into globalThis, see below.

var streams = require("web-streams-polyfill/ponyfill");

globalThis.ReadableStream = streams.ReadableStream;
globalThis.WritableStream = streams.WritableStream;
globalThis.TransformStream = streams.TransformStream;