A Rust port of the TypeScript 7 compiler and language server, offered as a drop-in replacement for type checking and emit.
johnsoncodehk/muggle-string
A dependency-free TypeScript library for rewriting source text from multiple writers and mapping the result back via language-server spans and v3 source maps.
- Stars
- 20
- Forks
- 2
- Open issues
- 0
- Last commit
- yesterday
What is it?
muggle-string rewrites a source text from several places at once and maps the rewritten output back to the original source. It was written for vuejs/language-tools to turn Vue single-file components into TypeScript for the language server, where several plugins edit the same block and the output must keep editor features such as hover, completion and rename.
Edits are recorded as appends to per-writer lists and only sorted when rendering, so edits never search or copy text. Writers carry ranks that decide ordering at the same position, so the plugin order rather than call order determines the result. Removals combine, and a cut lets a range be moved elsewhere in the output while keeping its mapping.
The same rendered pieces produce either language-server spans (Verbatim and Atom) or a v3 source map. The library ships as ES modules only and has no dependencies.
Key features
- 01Multiple writers edit the same source, with ordering by rank rather than call order.
- 02Removals and replacements combine without undoing each other.
- 03Cut ranges can be moved to another position in the output.
- 04Renders language-server spans or a v3 source map from the same pieces.
- 05Works with TypeScript, with no runtime dependencies.
Use cases
- Building a language server plugin that generates TypeScript from a template-based file format.
- Compiling a template language to HTML while keeping a mapping to the original positions.
- Producing a source map for a code transformation tool that performs many edits to one file.
In collections
Topics
FAQ
- What is muggle-string?
- A dependency-free TypeScript library for rewriting source text from multiple writers and mapping the result back via language-server spans and v3 source maps. muggle-string rewrites a source text from several places at once and maps the rewritten output back to the original source. It was written for vuejs/language-tools to turn Vue single-file components into TypeScript for the language server, where several plugins edit the same block and the output must keep editor features such as hover, completion and rename.
- Is muggle-string free to use? What license does it have?
- muggle-string is open source under the MIT license. Check the license terms before using it in commercial products.
- Is muggle-string still maintained?
- Actively maintained. The last commit to muggle-string was on Nov 5, 2026.
- What can I use muggle-string for?
- Building a language server plugin that generates TypeScript from a template-based file format. Compiling a template language to HTML while keeping a mapping to the original positions. Producing a source map for a code transformation tool that performs many edits to one file.
- Where can I get muggle-string?
- The source code and installation instructions are on GitHub: https://github.com/johnsoncodehk/muggle-string
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
An experimental Rust port of the TypeScript 7 compiler (tsc), with the same CLI, language server and API, plus built-in Effect diagnostics.
A JavaScript parser, mangler and compressor toolkit for ES6+ code, a maintained fork of uglify-es for minifying modern JavaScript.
Open-source automated refactoring engine that applies recipes to source code across many repositories, covering framework migrations and security fixes.
Vue language tooling built on Volar.js, providing the Vue editor language server, vue-tsc type checker and related packages.
Official Microsoft C/C++ extension for VS Code, providing IntelliSense editing and debugging for C and C++ code.