mentaljam / rollup-plugin-zip

Rollup plugin to zip up emitted files.
https://www.npmjs.com/package/rollup-plugin-zip
MIT License
4 stars 5 forks source link

Rollup Plugin Zip does not work if Rollup cache is not enabled #9

Open clalexander opened 8 months ago

clalexander commented 8 months ago

This plugin is failing if the Rollup cache is not enabled.

[!] (plugin zip) TypeError: The "paths[0]" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:406:5)
    at validateString (node:internal/validators:162:11)
    at Object.resolve (node:path:171:9)
    at C:\project\node_modules\rollup-plugin-zip\dist\index.cjs.js:90:53
    at Array.forEach (<anonymous>)
    at C:\project\node_modules\rollup-plugin-zip\dist\index.cjs.js:77:36
    at new Promise (<anonymous>)
    at Object.writeBundle (C:\project\node_modules\rollup-plugin-zip\dist\index.cjs.js:72:16)
    at C:\project\node_modules\rollup\dist\shared\rollup.js:1002:40
    at async Promise.all (index 0)

The issue is path.resolve(distDir, fileName) at index.ts:77 is failing because distDir is undefined instead of a string. It is undefined because when no cache is specified in the RollupOptions, Rollup defaults to NO_CACHE and returns undefined for all keys. const distDir = this.cache.get<string>(Cache.distdir) at index.ts:67 sets distDir to undefined.

When I set cache to true in the RollupOptions, the plugin works as expected.

Versions

package version
rollup 4.13.0
rollup-plugin-zip 1.0.3
JoshMcCullough commented 7 months ago

Agreed. Just tried this plugin for the first time and got this same immediate failure. :frowning:

I'll turn cache on but it seems that this is a bug that most people will run into.