Skip to content

Releases: faultyserver/ts-docs-loader

v0.3.2 - Location information!

Choose a tag to compare

@faultyserver faultyserver released this 29 Nov 21:48

The transformer now adds location information to all named values that it processes. This information includes:

  • A trimmed filePath, based on options mentioned below.
  • The starting line for the node.
  • The ending line for the node.

By default, the transformer uses whatever filePath it finds when resolving a file with the typescript resolver. This ends up being an absolute path, which is great for uniqueness, but hard to do anything meaningful with.

You can now specify a basePath when configuring the loader, which will strip that content from the beginning of every path when generating IDs. For example, with a basePath of /users/myname/sites/project1/, a file at /users/myname/sites/project1/path/to/file would end up with using just /path/to/file in the location information.

This is great for generating GitHub links from generated documentation. You can also query the current commit SHA in your build process to be able to generate a permalink that's always accurate, no matter when someone looks at the build!

v0.3.0 - Much faster type binding resolution

Choose a tag to compare

@faultyserver faultyserver released this 18 Sep 03:06

A while ago, this switched from a simple global type scope to using an adaptation of babel-type-scopes, but the library was doing a lot of repetitive work, re-traversing the AST on every type lookup. In large files, this ends up being the majority of the time spent processing the file.

This version replaces that library adaptation with a new, pre-emptive, cached traversal of all type scopes in the file to create a re-usable map of bindings, meaning the file only needs to be traversed once, and afterwards every usage can just do a quick (recursive) lookup into the map.

In practice, this reduced the time to process import * as React from up to 5 seconds to consistently under 1 second on an M2 MacBook.

v0.2.0

Choose a tag to compare

@faultyserver faultyserver released this 17 Sep 16:37

A lot of the loader code has been refactored to make it possible to cache individual symbols, skip processing of intermediate files that don't get used, and improve handling of circular dependencies.