Opted out of SWC feedback #30174
Replies: 797 comments 342 replies
-
Hey! Here's the babel config we are using: const getPresets = (options = {}) => ({
presets: options.presets || ['next/babel'],
plugins: [['styled-components', { ssr: true }], ...(options.plugins || [])],
})
module.exports = {
env: {
production: getPresets({
plugins: [
['react-remove-properties', { properties: ['data-test-id'] }],
'transform-remove-console',
],
}),
development: getPresets({
presets: [
[
'next/babel',
{
'preset-react': {
importSource: '@welldone-software/why-did-you-render',
},
},
],
],
}),
test: getPresets({
plugins: [
'transform-react-remove-prop-types',
'transform-dynamic-import',
'require-context-hook',
],
presets: [['next/babel']],
}),
},
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
],
],
} |
Beta Was this translation helpful? Give feedback.
-
I've got Babel configured to optionally add code coverage if an environment variable is enabled: // babel.config.js
module.exports = function (api) {
api.cache(true);
const plugins = [];
if (process.env.INSTRUMENT_COVERAGE === 'true') {
console.log('Instrumenting Next client for code coverage...');
plugins.push('babel-plugin-istanbul');
}
return {
presets: ['next/babel'],
plugins
};
}; |
Beta Was this translation helpful? Give feedback.
-
Here's ours:
module.exports = {
presets: ["next/babel"],
plugins: [
[
"babel-plugin-module-resolver",
{
root: ["."],
alias: {
"@app": "./app",
},
},
],
"babel-plugin-macros",
"superjson-next",
["@babel/plugin-proposal-decorators", { legacy: true }],
],
}; |
Beta Was this translation helpful? Give feedback.
-
Do I need the canary version to opt into SWC? I can't find any documentation on this. I currently use the
|
Beta Was this translation helpful? Give feedback.
-
Another very important plugin for me is |
Beta Was this translation helpful? Give feedback.
-
We are using the following configuration in the Dutch corona dashboard front-end application: // babel.config.js
module.exports = function (api) {
return {
presets: ['next/babel'],
plugins: [
'lodash',
'date-fns',
[
'babel-plugin-styled-components',
{
ssr: true,
pure: true,
displayName: api.env('development'),
},
],
],
};
}; https://github.com/minvws/nl-covid19-data-dashboard/blob/develop/packages/app/babel.config.js |
Beta Was this translation helpful? Give feedback.
-
This is my babel config, one of the most important plugins I would like to see ported is babel-plugin-macros which I use for tailwind class macros. {
"presets": [
"next/babel"
],
"plugins": [
"babel-plugin-macros",
"babel-plugin-polished",
"@vanilla-extract/babel-plugin"
]
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
module.exports = api => {
api.cache(true);
return {
presets: [
[
'next/babel',
{
'preset-react': {
runtime: 'automatic',
importSource: '@emotion/react'
}
}
]
],
env: {
production: {
plugins: [
[
'@emotion',
{
sourceMap: true,
autoLabel: 'never',
labelFormat: true,
cssPropOptimization: true
}
]
]
},
development: {
plugins: [
[
'@emotion',
{
sourceMap: true,
autoLabel: 'always',
labelFormat: '[local]--[filename]',
cssPropOptimization: false
}
]
]
}
}
};
}; |
Beta Was this translation helpful? Give feedback.
-
This is ours: {
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "@emotion/react"
}
}
]
],
"plugins": [
["./libs/governance/getFileClaimBabelPlugin.js", {}],
["@emotion/babel-plugin", {}],
"lodash"
],
"env": {
"test": {
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic"
}
}
]
]
}
}
} Would be great if we also have custom plugin support going forward! |
Beta Was this translation helpful? Give feedback.
-
This is ours: module.exports = {
presets: [
[
'next/babel',
{
'preset-react': {
runtime: 'automatic',
importSource: '@emotion/react',
},
},
],
],
plugins: ['@emotion/babel-plugin'],
}; |
Beta Was this translation helpful? Give feedback.
-
// .babelrc
{
"presets": ["next/babel"],
"plugins": [
[
"formatjs",
{
"ast": true,
"idInterpolationPattern": "[sha512:contenthash:base64:6]"
}
]
]
} |
Beta Was this translation helpful? Give feedback.
-
The main thing that we use babel for is using {
"presets": [
[
"next/babel",
{
"preset-env": {
"targets": "> 0.25%, not dead"
},
"styled-jsx": {
"plugins": ["@styled-jsx/plugin-sass"]
}
}
]
],
"plugins": [
"@babel/plugin-proposal-logical-assignment-operators",
[
"module-resolver",
{
"alias": {
"@icons": "./icons",
"@components": "./components",
"@utils": "./utils",
"@config": "./config"
}
}
]
]
}
|
Beta Was this translation helpful? Give feedback.
-
Styled components for us, willing to drop istanbul ;)
/cc @mejackreed |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Looking for a plugin supporting something like this: It would be helpful to have something like this:
This makes react errors show up better |
Beta Was this translation helpful? Give feedback.
-
Here is our babelrc, coming from .next Version 11 { |
Beta Was this translation helpful? Give feedback.
-
SWC loader currently doesn't play well with transforming private properties and methods, I've whipped up a quick webpack config snippet to show how we can integrate this. config.module.rules.push({
test: /\.(?:js|ts)$/,
use: [
{
loader: "babel-loader",
options: {
presets: ["next/babel"],
plugins: [
"@babel/plugin-transform-private-property-in-object",
"@babel/plugin-transform-private-methods",
],
},
},
],
}); If SWC supports |
Beta Was this translation helpful? Give feedback.
-
It uses a subset of Emotion's features so that it is a zero-runtime CSS-in-JS solution. If you're working on Emotion and Styled-Components already, it makes sense to support this too, particularly since it fits the mold of being performance-first. |
Beta Was this translation helpful? Give feedback.
-
the official react compiler (which tries to replace useMemo) is written in babel only: @kdy1 do you know if any plans to port react compiler to swc too? |
Beta Was this translation helpful? Give feedback.
-
could we please have plugins to transpile code for older browsers? namely things like react-query which now uses private fields.
well, NextJS could still give support to target ES6 but that's another story... |
Beta Was this translation helpful? Give feedback.
-
We are using flow type in our codebase and babel provides a plugin for it - "@babel/plugin-transform-flow-strip-types". We did a POC to switch to SWC as it will have significant improvement on performance. But SWC doesn't support flow type, hence we are not able to migrate to SWC. I found an issue which was raised by someone in SWC repo(swc-project/swc#256), but it has been closed. Can we expect support for ignoring flow types similar to what "@babel/plugin-transform-flow-strip-types" does? Here's the .babelrc {
"presets": ["next/babel"],
"plugins": [
[
"babel-plugin-styled-components",
{
"ssr": true,
"displayName": false
}
],
[
"module-resolver",
{
"root": ["./"],
"alias": {
"components": "./app/components",
"lib": "./app/lib",
"constants": "./app/constants",
"utils": "./app/utils",
"global": "./app/global"
}
}
],
"@babel/plugin-transform-flow-strip-types"
]
} Looking forward for a reply. Thanks. |
Beta Was this translation helpful? Give feedback.
-
.babelrc {
"presets": ["next/babel"],
"plugins": [
["@babel/plugin-proposal-decorators", { "version": "2023-05" }],
]
} We use MobX 6 as the global state manager. |
Beta Was this translation helpful? Give feedback.
-
Hey here is the babel config we are using module.exports = {
presets: ['next/babel'],
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-transform-named-capturing-groups-regex',
'@babel/plugin-transform-class-properties',
'@babel/plugin-proposal-private-methods',
[
'styled-components',
{
ssr: true,
displayName: process.env.NODE_ENV === 'development',
preprocess: false,
},
],
],
}; |
Beta Was this translation helpful? Give feedback.
-
hey folks, here is our .babelrc
We use Mobx 4 and these are (except last one) specifically for that. https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I'm using StyleX which happens to also not work very well with Next 15 due to swc I suspect: const path = require('path');
module.exports = {
presets: ['next/babel'],
plugins: [
[
'@stylexjs/babel-plugin',
{
dev: process.env.NODE_ENV !== 'production',
runtimeInjection: false,
genConditionalClasses: true,
treeshakeCompensation: true,
aliases: {
'@styles/*': [path.join(__dirname, 'styles/*')],
'@components/*': [path.join(__dirname, 'components/*')],
},
useCSSLayers: false,
unstable_moduleResolution: {
type: 'commonJS',
rootDir: __dirname,
},
},
],
],
}; |
Beta Was this translation helpful? Give feedback.
-
Can we also support Stylus? I am working on an old project and having a hard time dealing with Stylus CSS integration
|
Beta Was this translation helpful? Give feedback.
-
This is a feedback thread for when your application opted out from usage of SWC because there is a
.babelrc
. The main goal of this thread is to collect what transformations people are adding that we might want to port to Rust/SWC.What you can expect in the near future:
Note: this list will expand based on feedback collected.
The implemented transforms documentation has been moved to the Next.js documentation: https://nextjs.org/docs/advanced-features/compiler
Comments
When posting on this thread please make sure you include your
.babelrc
contents.Beta Was this translation helpful? Give feedback.
All reactions