dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
4.54k stars 121 forks source link

improve ignore rollup react directives warning #102

Closed himself65 closed 9 months ago

himself65 commented 1 year ago

We could use a good library to handle this.

https://github.com/SukkaW/rollup-plugin-swc/tree/0.9.0#react-server-component-directives-use-client-and-use-server

himself65 commented 1 year ago

source code: https://github.com/SukkaW/rollup-plugin-swc/blob/0.9.0/src/directive.ts

dai-shi commented 1 year ago

It would be super nice if we can remove our hack: https://github.com/dai-shi/waku/blob/34188f0965d8f4ec48163aec480f54f6fc36e9b5/src/lib/vite-plugin/rsc-transform-plugin.ts#L40-L44

SukkaW commented 1 year ago

@huozhi and I have created a standalone rollup plugin rollup-swc-preserve-directives for collecting and prepend directives (swc is only used for parsing, while the magic-string does the rest transformation).

It would be super nice if we can remove our hack:

https://github.com/dai-shi/waku/blob/34188f0965d8f4ec48163aec480f54f6fc36e9b5/src/lib/vite-plugin/rsc-transform-plugin.ts#L40-L44

The directives usually stay at the top of the file. It seems that in the context of the waku, this convention is not followed. Would you like to share more information about this?

dai-shi commented 1 year ago

Would you like to share more information about this?

As far as I remember, react plugin adds import statement for jsx. Maybe, it's out of the scope of your lib.

himself65 commented 9 months ago

I think we don't have such warning now