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

Support for compile-to-JS languages? #98

Closed
spiffytech opened this issue Dec 2, 2016 · 12 comments
Closed

Support for compile-to-JS languages? #98

spiffytech opened this issue Dec 2, 2016 · 12 comments

Comments

@spiffytech
Copy link

Can Svelte be used with compile-to-JS languages, like TypeScript and ClojureScript? How can I tell Svelte to look for behaviors in my generated code?

@Rich-Harris
Copy link
Member

No reason this wouldn't work – as long as Svelte takes delivery of ES<=2017 that adheres to the component spec, it'll take it from there. So you would just need to preprocess your TypeScript accordingly.

Eventually it'd be nice to allow pluggable transpilers a la vue-loader, but it's probably a ways down the priority list tbh.

@spiffytech
Copy link
Author

spiffytech commented Dec 3, 2016

#65 sounds like Svelte won't load external .js files - like it requires behaviors to be specified inside a script tag in the template file. And that at this time there's no ready-made tooling to inject .js files into a template. Is that correct? Is that the expected way to deliver the TypeScript output to Svelte?

@Rich-Harris
Copy link
Member

@spiffytech For now, yes – you'd need to glue the code together before passing it to Svelte, until #65 is implemented.

@Datamance
Copy link

Could you support this how handlebars does it - with the type attribute of the script tag?

@Rich-Harris Rich-Harris mentioned this issue Jan 4, 2017
@Conduitry
Copy link
Member

Closing this since we have svelte.preprocess. If someone disagrees, we can reopen.

@jaccarmac
Copy link

Is this essentially dead given the changes in Svelte 3 or is there some programmatic way to hook into the compiler? I've been playing with various approaches to integrating shadow-cljs, but the new syntax introduced to Svelte seems to be a wall.

@TehShrike
Copy link
Member

@jaccarmac preprocess support was added back in Svelte 2, and is still around in Svelte 3.

@jaccarmac
Copy link

CLJS is something of a special case given the Closure integration and the necessity of implementing sugar for things like $:. (Unless there's a non-sugared syntax in Svelte for the like. Haven't yet taken a deep look at the compiler source.)

@jaccarmac
Copy link

jaccarmac commented May 12, 2019

No reason this wouldn't work – as long as Svelte takes delivery of ES<=2017 that adheres to the component spec, it'll take it from there.

Specifically, this seems to no longer be the case.

@TehShrike
Copy link
Member

Are you saying that you're using a language that doesn't give you a way to generate JS labels?

That seems like a separate issue from this general "support compile-to-JS transforms" issue.

You could bring up specific details in the Discord chat if you want to look for some help brainstorming?

@jaccarmac
Copy link

jaccarmac commented May 12, 2019

Had not realized $ was a valid label (or remembered that JS had labels), thanks! Emitting arbitrary JS isn't something I know how to do in CLJS but that makes things significantly simpler. I'll take further discussion to the Discord indeed.

TehShrike added a commit that referenced this issue May 12, 2019
Inspired by #98 (comment) , I wanted to make it a bit more explicit that the `$:` label was actual JS syntax.
tomoam pushed a commit to svelte-jp/svelte-site-jp that referenced this issue Feb 2, 2021
Inspired by sveltejs/svelte#98 (comment) , I wanted to make it a bit more explicit that the `$:` label was actual JS syntax.
@seanthingee
Copy link

Are there any updates on this topic? I'm curious about integrating Clojurescript as well.

tomoam pushed a commit to svelte-jp/svelte-site-jp that referenced this issue Oct 30, 2021
Inspired by sveltejs/svelte#98 (comment) , I wanted to make it a bit more explicit that the `$:` label was actual JS syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants