npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

oxc-loader

v0.0.0-alpha.4

Published

webpack loader for oxc

Readme

oxc-loader

npm version npm downloads bundle JSDocs License

A high-performance webpack loader for transforming JavaScript and TypeScript using oxc.

Features

  • Ultra Fast: 3-5x faster than SWC, 20-50x faster than Babel
  • 🔧 TypeScript Support: Transform TypeScript to JavaScript with type stripping
  • ⚛️ JSX/TSX Support: Transform React JSX with automatic runtime detection
  • 🔄 React Fast Refresh: Built-in support for React development
  • 📦 Small Bundle: Only 2MB vs SWC's 37MB
  • 🛠️ Webpack & Rspack: Compatible with both bundlers
  • 🗺️ Source Maps: Full source map support
  • ⚙️ Configurable: Extensive configuration options
  • 📋 tsconfig.json Support: Automatic detection and configuration from TypeScript config

Node.js Compatibility

  • Node.js 20.19 or higher

Installation

npm install oxc-loader
# or
yarn add oxc-loader
# or
pnpm add oxc-loader
# or
bun add oxc-loader

Usage

Basic Webpack Configuration

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
          loader: 'oxc-loader',
          options: {
            // Options here
          }
        }
      }
    ]
  }
}

Basic Rspack Configuration

// rspack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
          loader: 'oxc-loader',
          options: {
            // Options here
          }
        }
      }
    ]
  }
}

Configuration Options

Basic Options

interface OxcLoaderOptions {
  // Enable source map generation (default: true)
  sourcemap?: boolean

  // Enable React Fast Refresh for development (default: false)
  refresh?: boolean

  // Automatically detect and configure JSX based on file extension (default: true)
  autoDetectJsx?: boolean

  // All oxc-transform options are also supported
  typescript?: TypeScriptOptions
  jsx?: JsxOptions
  target?: string | string[]
  // ... and more
}

TypeScript Configuration

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: {
          loader: 'oxc-loader',
          options: {
            typescript: {
              onlyRemoveTypeImports: true,
              declaration: {
                stripInternal: true
              }
            }
          }
        }
      }
    ]
  }
}

JSX Configuration

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: {
          loader: 'oxc-loader',
          options: {
            jsx: {
              runtime: 'automatic', // or 'classic'
              development: process.env.NODE_ENV === 'development',
              importSource: 'react'
            }
          }
        }
      }
    ]
  }
}

React Fast Refresh

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(jsx|tsx)$/,
        use: {
          loader: 'oxc-loader',
          options: {
            refresh: process.env.NODE_ENV === 'development',
            jsx: {
              runtime: 'automatic',
              development: true
            }
          }
        }
      }
    ]
  }
}

tsconfig.json Support

oxc-loader automatically reads and applies relevant settings from your tsconfig.json file. This feature is enabled by default and helps ensure consistency between your TypeScript configuration and the transformation process.

Supported tsconfig.json Options

The following TypeScript compiler options are automatically mapped to oxc-transform settings:

  • target: Maps to oxc-transform's target option
  • jsx: Configures JSX transformation mode
  • jsxFactory: Sets custom JSX pragma
  • jsxFragmentFactory: Sets custom JSX fragment pragma
  • jsxImportSource: Sets JSX import source for automatic runtime
  • allowImportingTsExtensions: Enables import extension rewriting
  • verbatimModuleSyntax: Enables type-only import removal

Examples

Complete Webpack Configuration

// webpack.config.js
const path = require('node:path')

module.exports = {
  entry: './src/index.tsx',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
          loader: 'oxc-loader',
          options: {
            // Enable source maps
            sourcemap: true,

            // Enable React Fast Refresh in development
            refresh: process.env.NODE_ENV === 'development',

            // TypeScript configuration
            typescript: {
              onlyRemoveTypeImports: true
            },

            // JSX configuration (auto-detected for .jsx/.tsx files)
            jsx: {
              runtime: 'automatic',
              development: process.env.NODE_ENV === 'development'
            },

            // Target modern browsers
            target: ['es2020', 'chrome80', 'firefox80', 'safari14']
          }
        }
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx']
  }
}

Rspack Configuration

// rspack.config.js
const path = require('node:path')

module.exports = {
  entry: './src/index.tsx',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
          loader: 'oxc-loader',
          options: {
            refresh: true, // Enable React Fast Refresh
            typescript: {
              onlyRemoveTypeImports: true
            }
          }
        }
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx']
  }
}

Performance Comparison

| Tool | Transform Speed | Memory Usage | Bundle Size | Packages | |------|----------------|--------------|-------------|----------| | oxc-loader | Baseline | 51 MB | 2 MB | 2 | | swc-loader | 3-5x slower | 67 MB | 37 MB | Multiple | | babel-loader | 20-50x slower | 172 MB | 21 MB | 170+ |

Benchmarks based on oxc-project/bench-transformer

Migration Guide

From babel-loader

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
-         loader: 'babel-loader',
+         loader: 'oxc-loader',
          options: {
-           presets: [
-             '@babel/preset-env',
-             '@babel/preset-react',
-             '@babel/preset-typescript'
-           ]
+           jsx: {
+             runtime: 'automatic'
+           },
+           typescript: {
+             onlyRemoveTypeImports: true
+           }
          }
        }
      }
    ]
  }
}

From swc-loader

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        exclude: /node_modules/,
        use: {
-         loader: 'swc-loader',
+         loader: 'oxc-loader',
          options: {
-           jsc: {
-             parser: {
-               syntax: 'typescript',
-               tsx: true
-             },
-             transform: {
-               react: {
-                 runtime: 'automatic'
-               }
-             }
-           }
+           jsx: {
+             runtime: 'automatic'
+           },
+           typescript: {
+             onlyRemoveTypeImports: true
+           }
          }
        }
      }
    ]
  }
}

Troubleshooting

Native Binding Issues

If you encounter native binding errors, try:

# Remove node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

# Or with pnpm
rm -rf node_modules pnpm-lock.yaml
pnpm install

TypeScript Errors

Make sure your tsconfig.json includes the necessary compiler options:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler"
  }
}

Contributing

Contributions are welcome! Please read our contributing guide for details.

License

MIT License © 2024-PRESENT Sunny-117

Related Projects