Skip to content

Commit

Permalink
Get js.code value.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Jul 8, 2020
1 parent 3449d96 commit c9e366a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/build/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func Client(buildPath string) string {
contentStr := strings.Replace(string(content), "self.performance.now();", "'';", 1)
ctx, _ := v8go.NewContext(nil)
ctx.RunScript(contentStr, "ejected/bundle.js")
//ctx.RunScript("var js = '';", "ejected/bundle.js")

// Go through all file paths in the "/layout" folder.
layoutFilesErr := filepath.Walk("layout", func(layoutPath string, layoutFileInfo os.FileInfo, err error) error {
Expand All @@ -53,7 +54,9 @@ func Client(buildPath string) string {
destFile = strings.TrimSuffix(destFile, filepath.Ext(destFile)) + ".js"

//val, err := ctx.RunScript("component='"+layoutPath+"'", "ejected/bundle.js")
val, err := ctx.RunScript("svelte.compile('"+layoutPath+"', {css: false});", "ejected/bundle.js")
//val, err := ctx.RunScript("svelte.compile('"+layoutPath+"', {css: false});", "ejected/bundle.js")
ctx.RunScript("var obj = svelte.compile('"+layoutPath+"', {css: false});", "ejected/bundle.js")
val, err := ctx.RunScript("obj.js.code;", "ejected/bundle.js")
if err != nil {
fmt.Printf("V8go could not execute: %v", err)
}
Expand Down

0 comments on commit c9e366a

Please sign in to comment.