Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup build errors #673

Closed
hug0b opened this issue May 6, 2020 · 3 comments
Closed

Rollup build errors #673

hug0b opened this issue May 6, 2020 · 3 comments

Comments

@hug0b
Copy link

hug0b commented May 6, 2020

My goal is to use jszip in a browser application (UMD).

importing jszip (import JSZip from "jszip";) in an application bundled with Rollup causes the following build errors:

src/main.js → dist/jszip-rollup.umd.js...
(!) Missing shims for Node.js built-ins
Creating a browser bundle that depends on 'stream', 'events', 'buffer' and 'util'. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
(!) Plugin node-resolve: preferring built-in module 'stream' over local alternative at 'stream', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at 'events', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
(!) Plugin node-resolve: preferring built-in module 'util' over local alternative at 'util', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
(!) Plugin node-resolve: preferring built-in module 'buffer' over local alternative at 'buffer', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
stream (imported by node_modules/readable-stream/readable.js, stream?commonjs-external, node_modules/readable-stream/lib/internal/streams/stream.js)
events (imported by node_modules/readable-stream/lib/_stream_readable.js, events?commonjs-external)
util (imported by node_modules/readable-stream/lib/_stream_readable.js, util?commonjs-external, node_modules/readable-stream/lib/internal/streams/BufferList.js, node_modules/inherits/inherits.js, node_modules/util-deprecate/node.js)
buffer (imported by node_modules/safe-buffer/index.js, buffer?commonjs-external)
(!) Circular dependencies
node_modules/readable-stream/lib/_stream_readable.js -> node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/readable-stream/lib/_stream_readable.js
node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/readable-stream/lib/_stream_writable.js -> node_modules/readable-stream/lib/_stream_duplex.js
node_modules/readable-stream/lib/_stream_duplex.js -> node_modules/readable-stream/lib/_stream_writable.js -> /var/www/html/rollup-jszip/node_modules/readable-stream/lib/_stream_duplex.js?commonjs-proxy -> node_modules/readable-stream/lib/_stream_duplex.js
...and 3 more
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
stream (guessing 'stream$1')
events (guessing 'events')
buffer (guessing 'buffer')
util (guessing 'util$6')

Sample project based on rollup-starter-lib

EDIT:
What I have gathered so far:

The error I currently have is when executing my build:

bundle.umd.js

...
      // implementation from standard node.js 'util' module
      ctor.super_ = superCtor;
      ctor.prototype = Object.create(superCtor.prototype, {
        constructor: {
          value: ctor,
          enumerable: false,
          writable: true,
          configurable: true
        }
...

TypeError: superCtor is undefined or Uncaught TypeError: Cannot read property 'prototype' of undefined

@hug0b
Copy link
Author

hug0b commented May 7, 2020

I'm not sure if this is the intended behavior but I had to use import JSZip from "jszip/dist/jszip"; instead.

@cortopy
Copy link

cortopy commented Jul 15, 2020

thanks @hug0b for this report and the solution! In my case by just importing "jszip/dist/jszip" fixed it (no need to install any extra rollup plugin)

@risalfajar
Copy link

risalfajar commented Sep 19, 2021

Importing jszip/dist/jszip does not work for me. I still get this error

index.svelte:2006 Uncaught TypeError: JSZip.loadAsync is not a function at onFileImport (index.svelte:2006)

I am using Svelte with Nollup

UPDATE: everything works fine with Rollup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants