gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.38k stars 510 forks source link

When trying to use with meteorjs it seems to modify the global package variable #393

Closed imdark closed 1 year ago

imdark commented 1 year ago

even just

require('@zip.js/zip.js')

will cause everything to crash Uncaught SyntaxError: Cannot use 'import.meta' outside a module (at modules.js?hash=886c0c85d0b952d506ded4b863a6b4c16b334665:105718:19) react-fast-refresh.js?hash=2d2cfb538903e27f542f73469113bb56a27e2a7e:17 Uncaught TypeError: Cannot read properties of undefined (reading 'meteorInstall') at react-fast-refresh.js?hash=2d2cfb538903e27f542f73469113bb56a27e2a7e:17:37 at react-fast-refresh.js?hash=2d2cfb538903e27f542f73469113bb56a27e2a7e:982:3 (anonymous) @ react-fast-refresh.js?hash=2d2cfb538903e27f542f73469113bb56a27e2a7e:17 (anonymous) @ react-fast-refresh.js?hash=2d2cfb538903e27f542f73469113bb56a27e2a7e:982

gildas-lormeau commented 1 year ago

You're trying run the library outside an ECMAScript Module but you did not build the library in order to do so.

imdark commented 1 year ago

I just did a meteor npm install which works for most other libraries, how would i go about building to not be a module

gildas-lormeau commented 1 year ago

How do you import zip.js in your project?

imdark commented 1 year ago

By doing, npm install and calling require('@zip.js/zip.js')

gildas-lormeau commented 1 year ago

If you use require, you should write const zip = require("@zip.js/zip.js/index.cjs"); as documented here: https://gildas-lormeau.github.io/zip.js/.