TypeScriptToLua icon indicating copy to clipboard operation
TypeScriptToLua copied to clipboard

rootDirs support

Open dustinlacewell opened this issue 7 years ago • 1 comments

Currently, when a transpiled file depends on another typescript file, tstl needs to determine:

  • Where to emit the corresponding Lua file
  • How to require the corresponding Lua file

As of now, tstl only considers the rootDir compiler option when attempting resolve a relative path from the file doing the importing, to the imported file. If the imported file is not actually relative to rootDir, the whole absolute path sequence is retained in both emission of the Lua file, and when requiring it.

tstl should instead check every path in rootDirs. If it finds that the dependency is relative to one of the rootDirs it should perform the same "relativizing" it does for rootDir.

This will have the advantage of allowing the use of (particularly developement) typescript libraries to be shared across transpiled projects without deeply nested, host-specific emissions arising in tstl output.

dustinlacewell avatar Jan 29 '19 18:01 dustinlacewell

I've experimented with that (for #432), and it looks like rootDirs doesn't affect output structure by design (see https://github.com/microsoft/TypeScript/issues/8245). If there's a need for that, we can:

  • Investigate if that use case is covered by modules (yarn workspaces?) or project references
  • Document how API can be used to manipulate output structure
  • Add a new option

ark120202 avatar Oct 16 '19 05:10 ark120202