chladog / payload-webp

payloadcms/payload plugin for automatic image conversion to webp format.
https://www.npmjs.com/package/payload-webp
GNU General Public License v3.0
45 stars 5 forks source link

Cannot read property 'debug' of undefined #3

Closed AlexanderJarnehall closed 2 years ago

AlexanderJarnehall commented 2 years ago

Hey @chladog!

This plugin seems awesome, but having a few issues getting it to work. Not sure if it's because I'm doing things wrong or some bug.


If I add the plugin without any options, my Payload-cms server won't run: /node_modules/payload-webp/lib/Plugin.js:76 this.logger = new logger_1.Logger(options.debug || false); ^ TypeError: Cannot read property 'debug' of undefined at new WebpPlugin (/node_modules/payload-webp/lib/Plugin.js:76:51)


When I add debug to the plugin options: plugins: [ webp({ debug: true }) ],

This was solved, see comment below I get the following issue when trying to upload a image: [07:57:23] ERROR (payload): ValidationError: The following field is invalid: webp.sizes.thumbnail.filename at new ExtendableError (/node_modules/payload/src/errors/APIError.ts:26:11) at new APIError (/node_modules/payload/src/errors/APIError.ts:43:5) at new ValidationError (/node_modules/payload/src/errors/ValidationError.ts:6:5) at create (/node_modules/payload/src/collections/operations/create.ts:191:11) at processTicksAndRejections (internal/process/task_queues.js:95:5) at createHandler (/node_modules/payload/src/collections/requestHandlers/create.ts:15:17)


Using payload v.1.0.19 and payload-webp v.1.0.24

AlexanderJarnehall commented 2 years ago

The issue with The following field is invalid: webp.sizes.thumbnail.filename was solved once I deleted the items in my media archive that was added before the plugin!

Still wondering about the Cannot read property 'debug' of undefined

chladog commented 2 years ago

Hello @AlexanderJarnehall Yes, thank you for report. It was due missing options object define check. As you mentioned for now just passing at least empty options object likewebp({}) will do the trick. Already fixed it and will be in next release.

I'll investigate the other issue.

chladog commented 2 years ago

Hi @AlexanderJarnehall, I have published new version fixing the bug in the title. However I couldn't replicate The following field is invalid: webp.sizes.thumbnail.filename bug - I created an upload collection and uploaded some images, then installed a plugin and uploading and even replacing of file in existing media record is working just fine for me.

Can you share a minimal repo with a bug replicated?