brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
671 stars 30 forks source link

Telefunc with SWC #30

Open Aslemammad opened 2 years ago

Aslemammad commented 2 years ago

Idea: Next 12.2

Just an issue for creating the plugin, I'm going to work on this!

brillout commented 2 years ago

Neat 👍

brillout commented 1 year ago

@Aslemammad es-module-lexer has a wasm build. So I think we can use it to write a SWC plugin? Looks like SWC supports Wasm.

When using es-module-lexer, the Telefunc transfomer is just string concatenation, so it should be easy to implement that SWC plugin.

Very much looking forward to having first class support for Next 13's dev --turbo. Turbopack looks real neat.

Let me know what you think!

(Hope things are well on your side 😊.)

Aslemammad commented 1 year ago

I'd like to deliver this, but now, there's no way to identify which phase of the bundling we are in (Server or Client) in SWC/Next since we need this to differentiate between different telefunc builds. If you think this is possible, let me know.

brillout commented 1 year ago

Good point. I'll have a look at it.

brillout commented 1 year ago

Looking at current SWC plugins (swc-project/plugins) I couldn't find any client/server discrimination so far.

I wonder what get_context() returns? Maybe the info whether the code is being transformed for the client/server is in there.

There is also get_experimental_context() and get_raw_experimental_context() but I don't know what the difference with get_context() is.

Also: https://github.com/swc-project/plugins/issues/102.