tutorialkit icon indicating copy to clipboard operation
tutorialkit copied to clipboard

Referencing a template file from _file results in build error

Open noam-honig opened this issue 1 year ago • 1 comments

Describe the bug

When using typescript, I import a file that exist in the template, from a source file in a lession it works, but fails to build.

Link to a StackBlitz project which shows the error

https://github.com/noam-honig/play-with-tutorial-kit/tree/demo-reference-to-file-in-template

Steps to reproduce

Here's my code: https://github.com/noam-honig/play-with-tutorial-kit/tree/demo-reference-to-file-in-template

In essence, I took the basic template, replace vite to support react and typescript.

Added a file: src\templates\default\other-function.ts

export function otherFunction() {
  alert("other function ");
}

Added a file: src\content\tutorial\1-basics\1-introduction\1-welcome\_files\test.ts

import { otherFunction } from "./other-function";
export function test() {
  otherFunction();
}

It works well when I developer, but it fails build.

There are valid use cases, where I want my user to focus on a specific file, while using code in other files of the project that exist in the template, without seeing them in each lesson

Expected behavior

I wish it would build :)

Screenshots

No response

Platform

  • TutorialKit version: 0.1.2
  • OS: wsl windows
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

noam-honig avatar Aug 04 '24 12:08 noam-honig

I've used exclude: ['src/content'] to avoid these errors. I'm not sure if it's even possible to fix this properly for typescript.

https://github.com/AriPerkkio/tutorial-vite-plugin/blob/1f161a22bd80c9529ceeac8080dfb27f3db8a318/tsconfig.json#L12

AriPerkkio avatar Aug 04 '24 15:08 AriPerkkio