-
Notifications
You must be signed in to change notification settings - Fork 53
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
[Seeking Help] Adding Typescript Support #212
Comments
Re:
Then it can live in your existing build pipeline which has to do something like that for |
@nickreese Do you have any suggestions or ideas for how a project would opt into using Typescript? I think the first step is to follow @orta's advice for setting up the proper build with a ts template project, but I imagine that it'd be nice to setup some sort of nice setup script to go with these new changes. It might be nice to follow the I am going to try to get a working ts starter project running, but I'd appreciate some input on how to deliver this in the end as well. |
@orta should this code say |
Yeah. You’ll want to use As far as delivery a script that customizes the template seems like a good plan. Let me know how I can support. I’m on the svelte discord if you need a faster feedback loop. |
@orta const jsversion = esbuild.transformSync("routes.ts", { loader: 'ts' }) But the return type of export interface TransformResult {
code: string;
map: string;
warnings: Message[];
} Thanks in advance for any help, much appreciated |
I'd read up on the docs from esbuild, I just took this from their sample code |
Thank you for your hard working! I'm very sorry for spamming, but is there any progress on this? It would be great if we can use Typescript for Elder.js. |
Hey All! I'm not a TS expert, yet many people in the community are asking for TS support. That said, I'd love the help from someone who knows TS and common TS toolchains to help us get native TS support in Elder.js.
Hurdles Blocking TS Support
At a high level the main hurdle to implementing TS for Elder.js really comes down to:
The fact that there are several files that read the system expects
.js
files in specific places. These files include:routes.ts
externalHelpers.ts
plugins.ts
rollupPlugin.ts
(look for./server.js
)When Should Elder.js Compile TS?
Accepting TS files in the above listed code isn't a hard problem to solve, there was a partial attempt to get these playing nicely which you can see on this PR (#170)... the main problem comes down to when we compile TS and run that code.
The way I understand it there are two options:
Update the Elder.js
srcDir
to match theoutDir
found in thetsconfig
and update all of the files Elder.js reads looking for.js
and allow it to accept.ts
as well. This would be done ingetConfig
and let the user handle the compilation in their own tool chain. I planned on using this approach in alpha versions of Elder.js.Another suggestion from @orta that is on the TS team mentioned that we could just use an esbuild background process to transpile TS on the fly and just run the output as if it was a JS file.
The main reason neither of these have been implemented is that I just don't understand TS tooling well enough to make a decision because I don't know the pros/cons of each.
If anyone has strong opinions or would like to offer support, I'm all ears. 👂 👂 👂
The text was updated successfully, but these errors were encountered: