@soda-gql/swc-transformer
v0.10.2
Published
SWC-based native transformer for soda-gql
Maintainers
Readme
@soda-gql/swc-transformer
High-performance native transformer for soda-gql using SWC and Rust. This package provides the fastest transformation option for large codebases.
Features
- Native performance - Rust-based NAPI module for maximum speed
- Source map chaining - Merges with upstream source maps
- Per-file artifact filtering - Minimizes serialization overhead
- Cross-platform support - macOS, Linux, and Windows binaries
Installation
npm install @soda-gql/swc-transformer
# or
bun add @soda-gql/swc-transformerUsage
This package is typically used through higher-level plugins:
@soda-gql/webpack-plugin- Uses SWC transformer when available- Direct usage in custom build pipelines
Direct Usage
import { createTransformer } from "@soda-gql/swc-transformer";
// createTransformer is async (loads native module)
const transformer = await createTransformer({
artifact: builderArtifact,
config: resolvedConfig,
sourceMap: true, // optional
});
// transform is synchronous after initialization
const result = transformer.transform({
sourceCode: source,
sourcePath: "/path/to/file.ts",
inputSourceMap: existingSourceMap, // optional
});
if (result.transformed) {
const { sourceCode, sourceMap, errors } = result;
// Use transformed code and source map
}Platform Support
The following platforms are supported with pre-built binaries:
| Platform | Architecture | Package |
|----------|--------------|---------|
| macOS | ARM64 | @soda-gql/swc-transformer-darwin-arm64 |
| macOS | x64 | @soda-gql/swc-transformer-darwin-x64 |
| Linux | x64 (glibc) | @soda-gql/swc-transformer-linux-x64-gnu |
| Linux | x64 (musl) | @soda-gql/swc-transformer-linux-x64-musl |
| Windows | x64 | @soda-gql/swc-transformer-win32-x64-msvc |
Platform-specific packages are installed automatically as optional dependencies.
Requirements
- Node.js >= 18
@swc/core>= 1.0.0 (peer dependency)
Related Packages
- @soda-gql/babel-transformer - Babel-based alternative
- @soda-gql/webpack-plugin - Webpack integration
- @soda-gql/builder - Static analysis and artifact generation
License
MIT
