Elderjs / elderjs

Elder.js is an opinionated static site generator and web framework for Svelte built with SEO in mind.
https://elderguide.com/tech/elderjs/
MIT License
2.11k stars 53 forks source link

Writing routes in typescript #167

Open asterius1 opened 3 years ago

asterius1 commented 3 years ago

I usually write all my projects in typescript and indeed elderjs has nice support for typescipt in most cases, but I can't make it work to write elderjs routes in typescript. Changing routes.js to routes.ts makes it so elderjs doesn't see this route file.

From what i've seen in elderjs code all references to finding routes have hardcoded *.js extensions without mention of *.ts option.

Does it mean there is no way to write elderjs project in 100% typescript?

nickreese commented 3 years ago

That does sound right. I wasn’t a huge TS user when I wrote Elder.js and all of my projects use JS currently.

For a while we checked the dist folder defined in the tsconfig when files weren’t found but that support got dropped pre 1.0 IIRC.

I’d love to have support for this but can’t commit to developing it myself. This should be a relatively straight forward PR though. Simply check the tsconfig for the distdir and update the appropriate fields in getConfig.ts.

Happy to review a PR for this if you or someone else wants to tackle it.

nickreese commented 3 years ago

Today I was chatting with @orta from the TS team about how to implement this.

He recommended looking into using esbuild in memory transpiling and just evaluating the resulting code whenever a ts file is imported.