-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Backtics in script break compile step in v8go #121
Comments
Yep. Here's a simpler test case using
The value of |
hi @jimafisk , |
So the problem here is nested template literals. The svelte.compile() function takes a string as its first argument, since we're reading that directly from a component file, we wrap the ctx.RunScript("var { js, css } = svelte.compile(`"+componentStr+"`, {css: false, hydratable: true});", "compile_svelte") The problem is if the component we read has backticks, the componentStr = strings.ReplaceAll(componentStr, "`", "\\`") That would allow us to use simple template strings like: <script>
let test = `Hi.
I'm
Jim
`;
</script>
<h1>{test}</h1> But won't work with expressions like: <script>
let name = "Jim";
let test = `Hi.
I'm
${name}
`;
</script>
<h1>{test}</h1> That'll throw: Originally I thought we might be able to nest templates by preprocessing the backticks and putting them inside a placeholder let e = "expression";
console.log(`template within ${`template with ${e}`}`);
// prints "template within template with expression" This doesn't seem to work because the actual compiling of the component chokes on this syntax. Is there an easy solution here I'm missing? |
Release v0.5.1 should allow the use of simple backtics without blowing up the build, unfortunately it still won't be able to evaluate expressions in replacement patterns |
Template strings with replacements should finally be fixed in v0.6.12 🎉 Just let me know if you hit issues when testing! |
This lifecycle example uses backtics for the API url:
That should work, but it breaks the build:
The text was updated successfully, but these errors were encountered: