[Next] Is Turbopack supported? #242
|
Turbopack is slowly becoming the default, at least for dev. Does this plugin support Turbopack? |
Replies: 4 comments 1 reply
|
I will give it a try tomorrow and see what happens |
No happiness, getting a webpack error when attempting to run with turbopack, e.g. "dev": "next dev --turbopack", Here is the error on the browser: And in the console: Error: 'stylex.defineVars' should never be called at runtime. It should be compiled away by '@stylexjs/babel-plugin'
at [project]/src/app/page.tsx [app-rsc] (ecmascript) (src/app/page.tsx:4:0)
at [project]/src/app/page.tsx [app-rsc] (ecmascript, Next.js server component) (.next/server/chunks/ssr/_9921d5._.js:782:32)
at Object.<anonymous> (.next/server/app/page.js:15:26)
2 | import stylex from '@stylexjs/stylex';
3 | import styles from "./page.module.css";
> 4 | import { sizes } from '@stylexjs/open-props/lib/sizes.stylex';Also get the warning when running: Starting...
✓ Ready in 1039ms
⚠ Webpack is configured while Turbopack is not, which may cause problems.I created a fresh Next project, then added the stylexswc packages. It works with "dev": "next dev", but "next dev --turbopack" causes the error |
|
At the moment, the plugin does not support The last time I looked at |
|
Hi @sannajammeh, @derekjwilliams, Great news! Starting from version 0.13.0-rc.1, the Next.js plugin now supports Turbopack! The plugin now includes Turbopack configuration with CSS extraction using the PostCSS plugin. Quick StartFor Next.js with Turbopack, use the import withStylexTurbopack from '@stylexswc/nextjs-plugin/turbopack';
export default withStylexTurbopack({
rsOptions: {
dev: process.env.NODE_ENV === 'development',
},
})({
experimental: {
turbopack: {
// Additional Turbopack configuration if needed
},
},
});Important: You must also configure the PostCSS plugin for CSS extraction: // postcss.config.js
module.exports = {
plugins: {
'@stylexswc/postcss-plugin': {
rsOptions: {
dev: process.env.NODE_ENV === 'development',
},
},
autoprefixer: {},
},
};DocumentationFeel free to try it out and report any issues! |

Hi @sannajammeh, @derekjwilliams,
Great news! Starting from version 0.13.0-rc.1, the Next.js plugin now supports Turbopack!
The plugin now includes Turbopack configuration with CSS extraction using the PostCSS plugin.
Quick Start
For Next.js with Turbopack, use the
/turbopackexport:Important: You must also configure the PostCSS plugin for CSS extraction: