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

Typescript #45

Closed
monsterbitar opened this issue Jun 4, 2023 · 4 comments
Closed

Typescript #45

monsterbitar opened this issue Jun 4, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@monsterbitar
Copy link

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

@vinyll
Copy link
Member

vinyll commented Jun 11, 2023

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.

@vinyll vinyll added the enhancement New feature or request label Jun 11, 2023
@monsterbitar
Copy link
Author

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

@monsterbitar
Copy link
Author

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

  • in my component HTML file, I import the script (and stylesheet, but not relevant here) from a separate file.
  • lego compiles the component such that the "script" ends up being just the import statement
  • I include the component index file that lego generates in my project
  • Parcel (my bundler) finds the component files, the import from the component file and detects that it is TS, then bundles everyhing up.

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants