
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@stylexswc/turbopack-plugin
Advanced tools
Part of the StyleX SWC Plugin workspace
Turbopack loader for an unofficial
napi-rs
compiler that includes the StyleX SWC code transformation under the hood.
To install the package, run the following command:
npm install --save-dev @stylexswc/turbopack-plugin
Please install @stylexswc/rs-compiler if you haven't done so already:
npm install --save-dev @stylexswc/rs-compiler
[!IMPORTANT] Turbopack Limitation: Turbopack does not support webpack plugins (see Next.js docs). This loader only compiles StyleX code but does not extract CSS.
For CSS extraction, you must use the
@stylexswc/postcss-pluginin yourpostcss.config.js:// postcss.config.js module.exports = { plugins: { '@stylexswc/postcss-plugin': { include: [ 'app/**/*.{js,jsx,ts,tsx}', 'components/**/*.{js,jsx,ts,tsx}', ], rsOptions: { dev: process.env.NODE_ENV === 'development', }, }, autoprefixer: {}, }, };
Modify your next.config.ts to configure the loader for Turbopack:
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
dev: process.env.NODE_ENV !== 'production',
// ... other StyleX options
},
},
},
},
},
},
};
export default nextConfig;
rsOptionsPartial<StyleXOptions>[!NOTE] New Features: The
includeandexcludeoptions are exclusive to this NAPI-RS compiler implementation and are not available in the official StyleX Babel plugin.
rsOptions.include(string | RegExp)[]rsOptions.exclude(string | RegExp)[]include pattern. Patterns are matched against paths relative to the current
working directory.stylexImportsArray<string | { as: string, from: string }>['stylex', '@stylexjs/stylex']useCSSLayersUseLayersTypefalsenextjsModebooleanfalseextractCSSbooleantruetransformCss(css: string, filePath: string | undefined) => string | Buffer | Promise<string | Buffer>import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
dev: process.env.NODE_ENV !== 'production',
// Include only specific directories
include: ['app/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
// Exclude test files and stories
exclude: ['**/*.test.*', '**/*.stories.*', '**/__tests__/**'],
},
stylexImports: ['@stylexjs/stylex'],
},
},
},
},
},
};
export default nextConfig;
Include only specific directories:
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
include: ['app/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
},
},
},
},
},
},
};
export default nextConfig;
Exclude test and build files:
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**'],
},
},
},
},
},
},
};
export default nextConfig;
Using regular expressions:
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
include: [/app\/.*\.tsx$/, /components\/.*\.tsx$/],
exclude: [/\.test\./, /\.stories\./],
},
},
},
},
},
},
};
export default nextConfig;
Combined include and exclude (exclude takes precedence):
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
turbo: {
rules: {
'*.tsx': {
loaders: ['@stylexswc/turbopack-plugin/loader'],
options: {
rsOptions: {
include: ['app/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
exclude: ['**/__tests__/**', '**/__mocks__/**'],
},
},
},
},
},
},
};
export default nextConfig;
This loader was inspired by
stylex-webpack.
MIT — see LICENSE
FAQs
StyleX turbopack loader with NAPI-RS compiler
The npm package @stylexswc/turbopack-plugin receives a total of 5,828 weekly downloads. As such, @stylexswc/turbopack-plugin popularity was classified as popular.
We found that @stylexswc/turbopack-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.