Skip to content

babel errors when using stylex and tanstack-query #489

Answered by nmn
Ryong-E asked this question in Q&A
Discussion options

You must be logged in to vote

You have to pass @babel/plugin-transform-private-methods to the babelConfig.plugins key to stylex plugin to make this work.

So, the next.config.js file would need the following change:

const path = require('path');
const stylexPlugin = require('@stylexjs/nextjs-plugin');
const babelrc = require('./.babelrc.js');
const plugins = babelrc.plugins;
const [_name, options] = plugins.find(
  (plugin) => Array.isArray(plugin) && plugin[0] === '@stylexjs/babel-plugin',
);
const rootDir = options.unstable_moduleResolution.rootDir ?? __dirname;
const aliases = options.aliases ?? undefined;
const useCSSLayers = options.useCSSLayers ?? undefined;

module.exports = stylexPlugin({ 
  rootDir,
  aliases,

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@Ryong-E
Comment options

Answer selected by Ryong-E
Comment options

You must be logged in to vote
5 replies
@Ryong-E
Comment options

@Ryong-E
Comment options

@nmn
Comment options

nmn Mar 12, 2024
Collaborator

@Ryong-E
Comment options

@nmn
Comment options

nmn Mar 15, 2024
Collaborator

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants