Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate pure-go Svelte compiler just like plenti #125

Open
diyism opened this issue Nov 13, 2022 · 7 comments
Open

Integrate pure-go Svelte compiler just like plenti #125

diyism opened this issue Nov 13, 2022 · 7 comments
Labels
feature request Enhancement or feature request

Comments

@diyism
Copy link

diyism commented Nov 13, 2022

The project Plenti(https://github.com/plentico/plenti) has built-in pure-go Svelte compiler,
I'm dreaming an algernon version of built-in Svelete compiler.

@tooolbox
Copy link
Collaborator

Lots of interesting data here: plentico/plenti#3

And follow-up here: plentico/plenti#169

Looks like Matthew Mueller wound up using v8 for Bud though: https://github.com/livebud/bud/tree/de977798451d9b3f84695254a84377581a653286/package/svelte

@diyism
Copy link
Author

diyism commented Nov 15, 2022

@tooolbox yes, the plenti(v8go) performance is very close to the nodejs:
Screenshot 2022-11-15 at 14-20-32 Remove nodejs dependency · Issue #3 · plentico_plenti

@xyproto xyproto changed the title [Feature Request] To integrate pure-go Svelte compiler just like plenti Integrate pure-go Svelte compiler just like plenti Nov 15, 2022
@xyproto xyproto added the feature request Enhancement or feature request label Nov 15, 2022
@xyproto
Copy link
Owner

xyproto commented Nov 15, 2022

Thanks for the feature request!

@jimafisk
Copy link

Hey 👋

Achieving a zero dependency, reactive UI for Go is a problem we're still trying to solve with Plenti. We're currently compiling Svelte in V8 at the moment, and that works, but it's not without blemishes. If you're ever interested in talking through what we've tried, I'd be happy to hop on a call. Thanks!

@xyproto
Copy link
Owner

xyproto commented Jul 23, 2023

@jimafisk Sounds interesting! 👍 I'm on vacation, but I want to take a look at Plenti when I get back.

@diyism
Copy link
Author

diyism commented Sep 12, 2023

I found svelte-bun (https://github.com/terrywh/svelte-bun) which realized realtime building of svelte components on dev environment.
The performance of Bun is touted to be twice that of Deno and six times that of Node.
But Bun is not on golang.

@diyism
Copy link
Author

diyism commented Oct 18, 2023

I've tested svelte-bun with bun, its performance is amazing, the building is realtime.
And I've tried to run svelte-bun with v8go, but I failed.

I packaged the whole svelte-bun project with:
./node_modules/.bin/esbuild ./sbin/server.js --bundle --outfile=out.js --format=esm --platform=node
then run it with test.go:

package main

import (
	"fmt"
	"io/ioutil"

	v8 "rogchap.com/v8go"
)

func main() {
	js, _ := ioutil.ReadFile("./out.js")
	ctx:= v8.NewContext()
	val, err := ctx.RunScript(string(js), "main.js")
	if err != nil {
		fmt.Printf("failed to run JavaScript file: %v\n", err)
		return
	}

	fmt.Println(val)
}

it shows error:
failed to run JavaScript file: SyntaxError: Cannot use import statement outside a module

I guess the corresponding lines are:

import { stat as asyncStat } from "fs/promises";
import { extname, join as join2 } from "path";
import { resolve as resolve2 } from "path";

Maybe an experienced guy can work around it, but I can't.

ref: plentico/plenti#276
ref: terrywh/svelte-bun#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

4 participants