Ephem / rollup-plugin-preserve-directives

A Rollup plugin to preserve directives like "use client" when preserveModules is true
MIT License
67 stars 8 forks source link

Compatibility issues with Rollup v 2.60.0 #8

Open pawelshopstory opened 1 year ago

pawelshopstory commented 1 year ago

Hello!

First of all, thank you for your job! This plugin is truly useful in the world of React Server Components and Next App Router :)

I've experienced an issue while using your plugin with Rollup v2.60.0 and wanted to report it to you. I've used it the following way:

import preserveDirectivesPlugin from 'rollup-plugin-preserve-directives';

plugins: [preserveDirectivesPlugin()]

Rollup was throwing the below error:

[!] (plugin preserve-directives) Error: Error running plugin hook renderChunk for preserve-directives, expected a function hook.

I've made some tweaks and ended up with this working:

import preserveDirectivesPlugin from 'rollup-plugin-preserve-directives';

const preserveDirectivesPlugin = preserveDirectives();

plugins: [{ ...preserveDirectivesPlugin, renderChunk: preserveDirectivesPlugin.renderChunk.handler, }]

Cheers!

Ephem commented 1 year ago

Thanks for reporting this! I haven't seen this before, but not sure I've tested with earlier versions either. Out of curiosity, does upgrading to the latest Rollup 2.X version work (if that's feasible to test of course)?

pawelshopstory commented 1 year ago

I will try to test it, because I couldn't make an upgrade at the moment when I was trying it out.

Ephem commented 4 months ago

Judging from a newly opened issue I suspect this plugin simply doesn't support Rollup v2. On the other hand, v2 version is quite old by now and I barely have time to maintain this plugin as is so I'll go ahead and remove it from the peerDependencies to indicate that you need a newer version for this plugin to work.

I'll keep this issue open until I've done so.

If anyone instead wants to pick this up and see what needs to be done to support v2, do feel free to!

Ephem commented 4 months ago

Actually, I just saw how many downloads v2 still has, which is a lot, so I might hold off on that peerDependency update and do some research instead.