stackblitz / tutorialkit

TutorialKit by StackBlitz - Create interactive tutorials powered by the WebContainer API
https://tutorialkit.dev
MIT License
503 stars 48 forks source link

A way to validate the typescript of assembled tutorial sections #395

Open noam-honig opened 3 weeks ago

noam-honig commented 3 weeks ago

Is your feature request related to a problem?

Today, the actual lesson is a combination of files from the template and from the lesson itself. When I use vs code - or when I build astro typescript files - the build fails, because the template may refer to files that exist only on the lesson and vice versa.

I wish there was a way to validate that.

Describe the solution you'd like.

One "dummy" thought, is a cli command to "build" all the lessons with their files and template files into a temp folder and run typescript build there - to validate that all is ok

Describe alternatives you've considered.

The other way I can think of is duplicating many files - but that's maintanance hell.

Additional context

Love this project

AriPerkkio commented 3 weeks ago

Could you set up minimal reproduction for this? For example using https://node.new and running npm create tutorial there to get started?

noam-honig commented 3 weeks ago

Hi, here it is: https://stackblitz.com/edit/node-e7zju9

The lesson itself, that is the combination of the template and the lesson is valid but nore the templare nor the lesson are.

You can verify that its valid by using "open in stackblitz"

If I run astro build I get an error - and that's ok - I exclude template and content from the ts file.

I wish there was a way to generate to some temp folder, the "merged" lessons and build them to make sure its all ok.

AriPerkkio commented 3 weeks ago

I'm not sure how this could be implemented. I thought tsconfig.json's paths would do this automatically, but looks like relative imports are not remapped via paths. So something like this does not work:

{
  "compilerOptions": {
    "paths": {
+     "./src/content/tutorial/1-basics/1-introduction/1-welcome/_files/*": [
+       "./src/templates/default/*"
+     ]
    }
  }
}
noam-honig commented 3 weeks ago

I'm old school - if there was away to reuse the logic you use to build the source folder for the web container, and just output it to a tmp folder - with a folder for each lesson, and run the tsc there - that would be a good start.