huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
861 stars 28 forks source link

client and server boundary code split are not accurate #477

Closed huozhi closed 3 months ago

KajSzy commented 3 months ago

I'm using bunchee to create a toolbar for nextjs that combines client and server components. In my project when file with 'use client' imports another file with 'use server' directive bunchee outputs file with both directives.

You can see repro here https://github.com/KajSzy/next-cache-toolbar/tree/rc/0.2.0

File src/feature/cache-panel/cache-refresh-data.tsx is outputs with

'use server';
'use client';
huozhi commented 3 months ago

Thanks fore reporting @KajSzy , I was looking at your codebase now and testing locally but didn't find the repro. Are you still having the issue on that branch?

KajSzy commented 3 months ago

I've found a fix to that issue, removing 'use server' from entry file made all other chunks to split more properly. https://github.com/KajSzy/next-cache-toolbar/commit/9d6684477fc66c673b95190534f2aacc8bd83b2f#diff-0b5adbfe7b36e4ae2f479291e20152e33e940f7f265162d77f40f6bdb5da7405L1

Also I've updated to beta version 5.0.0-beta.4

huozhi commented 3 months ago

Good to hear that 👏

huozhi commented 3 months ago

This was raised in a SWR PR but also resolved. Closed this as cancelled