| Crates.io | snapfire_compiler |
| lib.rs | snapfire_compiler |
| version | 0.9.0 |
| created_at | 2025-12-08 23:30:03.033467+00 |
| updated_at | 2025-12-08 23:30:03.033467+00 |
| description | Compile TypeScript for the browser. No Node JS required. Fast, native, opinionated. |
| homepage | https://github.com/excsn/snapfire/compiler |
| repository | https://github.com/excsn/snapfire |
| max_upload_size | |
| id | 1974537 |
| size | 118,474 |
snapfirec)A bespoke, high-performance typescript to browser build tool written in Rust.
Snapfire Compiler replaces the traditional Node.js build chain (TypeScript, Vite/Rollup, PostCSS, Babel) with a single binary. It is designed to compile TypeScript libraries into browser-native ES Modules and standard CSS without requiring a package.json or node_modules folder.
<script type="module">).tsconfig.json and .browserslistrc.import './state') to include extensions (import './state.js'), which is required for native browser modules.console.log and console.debug statements from the output using AST transformations..browserslistrc to determine CSS transpilation targets.Since this is a local toolchain, install it from the source:
# Inside the compiler directory
cargo install --path .
Run the compiler pointing at your project root. It will look for a tsconfig.json to determine input directories and output paths.
snapfirec --root ./example
Inspect the example/dist directory for final output.
| Flag | Description | Default |
|---|---|---|
--root <PATH> |
The root directory of the project to build. | . (Current Directory) |
--config <PATH> |
Path to the tsconfig.json file. |
tsconfig.json |
-d, --out-dir <PATH> |
Override the output directory. | Read from tsconfig or dist |
--strip-log |
Removes all console.log statements from output. |
false |
--strip-debug |
Removes all console.debug statements from output. |
false |
-w, --watch |
Watch for file changes (Not yet implemented). | false |
snapfirec reads the compilerOptions.outDir and include arrays from your tsconfig.json.
{
"compilerOptions": {
"outDir": "dist",
"target": "es2020"
},
"include": ["src"]
}
To ensure your CSS works in specific browsers (and to control how nesting is flattened), add a .browserslistrc file to your project root.
last 2 versions
not dead
> 0.2%
TypeScript allows importing files without extensions, but browsers throw 404s. snapfirec parses the AST and rewrites these paths automatically.
Input (src/index.ts):
import { state } from './state';
Output (dist/index.js):
import { state } from "./state.js";
When using --strip-log or --strip-debug, the compiler removes the specific console statement entirely, ensuring clean production builds without leaving empty lines or semi-colons.
This project uses integration tests to validate the CLI and compiler logic.
# Run the test suite
cargo test
The tests create temporary directories, generate fixture files, run the compiler, and assert on the actual file system output.
This project is licensed under the Mozilla Public License 2.0. See the LICENSE file for details.