Replies: 3 comments 3 replies
-
Hey @jimafisk 🙂 So those functions are for compiling one Svelte file to JS. I'm guessing in Plenti, you'll want to support imports as well. To do that you'll need to wrap those functions as plugins in ESBuild to get one large blob of bundled JS. You can find that code here: Line 55 in 2cc8d0a (The transformer contains the Svelte compiler) Once you have that blob of JS, you can call v8.Eval on it: bud/framework/view/ssr/ssr_test.go Line 132 in 2cc8d0a That would call Component.render() and return HTML. |
Beta Was this translation helpful? Give feedback.
-
Hey @matthewmueller, I hope you're doing well! I've been spending some time this weekend trying to improve my Svelte compilation. I was able to incorporate your transformed compiler (https://github.com/livebud/bud/blob/main/package/svelte/compiler.js) into Plenti and that seemed to work well! Looks like it was using Svelte version
It seems to work fine at generating the compiler file, but when trying to use the compiler in my project I'm running into a variety of errors like expr := fmt.Sprintf(`;__svelte__.compile({ "path": %q, "code": %q, "target": "dom", "css": false, hydratable: true })`, layoutPath, componentStr)
result, err := ctx.RunScript(expr, "compile_svelte")
if err != nil {
return fmt.Errorf("Can't compile '%s' component file: %w", layoutPath, err)
} Question: Have you tried upgrading to a newer version of Svelte and run into similar problems? Just curious if there's an issue you're aware of, or if I'm just doing something incorrect with esbuild. Thanks again for all the help! |
Beta Was this translation helpful? Give feedback.
-
Hey Jim, nice to hear from you.
I haven't yet tried to bump up Svelte yet. Currently focused on other
aspects of the framework right now, so probably won't try for another month
or so. Please let me know if you find a solution!
…On Sat, May 27, 2023 at 11:26 AM Jim Fisk ***@***.***> wrote:
Hey @matthewmueller <https://github.com/matthewmueller>,
I hope you're doing well!
I've been spending some time this weekend trying to improve my Svelte
compilation. I was able to incorporate your transformed compiler (
https://github.com/livebud/bud/blob/main/package/svelte/compiler.js) into
Plenti and that seemed to work well!
Looks like it was using Svelte version 3.47.0, so I tried creating a
newer version off 3.59.1 using your go:generate command
<https://github.com/livebud/bud/blob/main/package/svelte/compiler.go#LL3C134-L3C154>
as a model (and copying shimssr.ts
<https://github.com/livebud/bud/blob/main/package/svelte/shimssr.ts>
locally):
./node_modules/.bin/esbuild node_modules/svelte/compiler.js --format=iife --global-name=__svelte__ --bundle --platform=node --inject:shimssr.ts --external:url --outfile=my_compiler.js --log-level=warning
It seems to work fine at generating the file, but when trying to use it in
my project I'm running into a variety of errors starting with TypeError:
Template must be a string.
Have you tried upgrading to a newer version of Svelte and run into similar
problems? Just curious if there's an issue you're aware of, or if I'm just
doing something incorrect with esbuild. Thanks again for all the help!
—
Reply to this email directly, view it on GitHub
<#353 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABJSO3YAUXUYAT6OB2GL6DXIITMTANCNFSM6AAAAAATZYSDK4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi @matthewmueller!
I was exploring how I might leverage your V8 / Svelte compilation in Plenti. Your API is really nicely written 👌
Simple example compiling Svelte files from a "templates" folder to an "output" folder
My question: Is there a way to run Component.render(props) from your
svelte
package to generate HTML? Thank you!Related issues:
Beta Was this translation helpful? Give feedback.
All reactions