Polight / lego

🚀 Low-Tech Web-Components Made Lightweight & Future-Proof.
https://lego.js.org
MIT License
123 stars 19 forks source link

Typescript #45

Closed monsterbitar closed 1 year ago

monsterbitar commented 1 year ago

I don't see any mention of typescript in this project, is there any setup where typescript can be used here?

vinyll commented 1 year ago

The idea of the framework is to minimize dependencies and run bare metal with no/low transpilation. TypeScript still requires to be compiled to JavaScript. You should very probably be able to write typescript in your <script> tag from your brick components and then use Babel/Webpack/Rollup or other to transpile from the Lego output folder (dist by default) to a TS->JS version.

A support of TypeScript will strongly be considered as soon as browsers will directly support it. Also if you see any mean to support TypeScript without adding dependencies and complexity, we will totally consider the option.

monsterbitar commented 1 year ago

I'll fiddle around with this for a bit and will come back.

monsterbitar commented 1 year ago

I think I can make this work, here's how:

Once I figure out how to deal with all the paths and scripted up the build process I'll come back with an example.

monsterbitar commented 1 year ago

I've been at this for a bit longer now, and not as sure anymore. I've managed to make parcel pick up what files to include, and typescript to get compiled down to regular js, but since there is no direct reference from my code to the component functions/classes, it just gets tree-shaken out of the bundle.

If I paste the code directly in the script tag instead of doing an import, it isn't detected as typescript and fails in other ways.

Going to call it a day here - it should be doable somehow, but the otherwise clean integration gets messy here, so will have to do without.

Closing this since my question has been answered.