Skip to content

Rspack / Webpack integration

@zntc/rspack-loader is a loader that runs source through ZNTC (Zig-based transpiler) instead of swc-loader, esbuild-loader, or babel-loader. It handles TypeScript / JSX / Flow / decorators.

It is a drop-in replacement for builtin:swc-loader. Because the loader API is shared between webpack and rspack, the same code runs on both bundlers.

Terminal window
bun add -D @zntc/rspack-loader @zntc/core
# or
npm i -D @zntc/rspack-loader @zntc/core

@zntc/core ships the NAPI binary as a dependency.

rspack.config.mjs
export default {
module: {
rules: [
{
test: /\.(?:tsx?|jsx?)$/,
exclude: /node_modules/,
loader: '@zntc/rspack-loader',
options: {
transpileOptions: { target: 'es2020', jsx: 'automatic' },
},
},
],
},
};
webpack.config.mjs
export default {
module: {
rules: [
{
test: /\.(?:tsx?|jsx?)$/,
exclude: /node_modules/,
use: {
loader: '@zntc/rspack-loader',
options: {
transpileOptions: { target: 'es2020', jsx: 'automatic' },
},
},
},
],
},
};
interface ZntcLoaderOptions {
transpileOptions?: Omit<TranspileOptions, 'filename'>;
tsconfigCache?: boolean;
}

Caches the tsconfig autodiscover walk per worker. During dev/watch, files in the same workspace are only walked once — saves 5–10 fs syscalls per file. Automatically ignored when transpileOptions.tsconfigPath or tsconfigRaw is set.

Same as @zntc/core TranspileOptions (the loader fills filename from this.resourcePath). See the Transpile Options reference or the @zntc/core source for the full list.

Common options:

OptionTypeDescription
target'es5' | 'es2015' | ... | 'esnext'ES down-level target
browsersliststring | string[]browserslist query (overrides target)
platform'browser' | 'node' | 'neutral' | 'react-native'Target platform
format'esm' | 'cjs'Module format
jsx'classic' | 'automatic' | 'automatic-dev'JSX runtime
jsxImportSourcestringautomatic import source (default react)
tsconfigPathstringPath to tsconfig.json
tsconfigRawstringInline tsconfig JSON
flowbooleanStrip Flow types
experimentalDecorators / emitDecoratorMetadatabooleanLegacy decorators
defineArray<{ key, value }>Identifier replacement (value is raw JSON)
sourcemapbooleanEmit source map
minify / dropConsole / dropDebuggerbooleanMinification
{
loader: '@zntc/rspack-loader',
options: {
transpileOptions: {
define: [
{ key: 'process.env.NODE_ENV', value: '"production"' },
{ key: '__DEV__', value: 'false' },
],
},
},
}
{
test: /\.js$/,
loader: '@zntc/rspack-loader',
options: { transpileOptions: { flow: true, jsx: 'automatic' } },
}
{
loader: '@zntc/rspack-loader',
options: {
transpileOptions: {
tsconfigPath: './tsconfig.json',
experimentalDecorators: true,
emitDecoratorMetadata: true,
},
},
}
  • @rspack/core >= 1.0.0 (optional, supports rspack 1.x and 2.x)
  • webpack >= 5.0.0 (optional)

Either is fine — only one needs to be installed.

Rspack’s builtin:swc-loader is compiled into rspack core in Rust, and external packages cannot register under the same prefix. @zntc/rspack-loader follows the same JS loader model as esbuild-loader, calling the ZNTC native binary through NAPI.