Questions tagged [swc-compiler]

For question about SWC (Speedy Web Compiler), a Rust-based JavaScript compiler.

70 questions
49
votes
21 answers

Next failed to load SWC binary

When trying to run the command using nextjs npm run dev shows error - failed to load SWC binary see more info here: https://nextjs.org/docs/messages/failed-loading-swc. I've tried uninstalling node and reinstalling it again with version 16.13 but…
12
votes
1 answer

How to configure Why Did You Render with NextJS 12

Next.JS uses babel to configure the Why Did You Render. module.exports = function (api) { const isServer = api.caller((caller) => caller?.isServer) const isCallerDevelopment = api.caller((caller) => caller?.isDev) const presets = [ …
francis
  • 3,852
  • 1
  • 28
  • 30
9
votes
3 answers

Failed to load SWC binary

When trying to run the command using Next.js npm run dev shows error - failed to load SWC binary see more info here: https://nextjs.org/docs/messages/failed-loading-swc. PS D:\web-development\new-project\explore> npm run dev > dev > next…
MONIRA MONI
  • 151
  • 1
  • 1
  • 7
9
votes
2 answers

Migrating from Babel to SWC with React

TL;DR How to translate a node script like this: "test": "NODE_ENV=test riteway -r @babel/register 'src/**/*.test.js' | tap-nirvana", to use SWC instead of Babel? Context We recently upgraded our Next.js version. Next.js now supports SWC instead of…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
8
votes
1 answer

How to generating TypeScript code with SWC

I'm hoping to use SWC in Rust to generate some TypeScript code. Unfortunately, it seems the emitter can only print JavaScript. Is this correct, or is there a way to print TypeScript? For instance, let's say we're crafting the following AST. use…
6
votes
1 answer

swc not resolving import path aliases

I have a typescript project which I'm transpiling with swc. I'm having trouble getting swc to resolve path aliases defined in either tsconfig.json or .swcrc. The module aliases are resolved properly by eslint and when running ts-node when swc is not…
minnow
  • 183
  • 8
6
votes
0 answers

Jest/Webpack/SWC: Cannot find module (a relative file)

when trying to spin up a server using Jest, I keep getting the error: Cannot find module 'services/middleware'. In this case, services/middleware is located in src/services/middleware. I have set the moduleNameMapper option in the jest config, so…
bbenson09
  • 123
  • 1
  • 6
5
votes
0 answers

How to modularize imports from a barrel file that exports from multiple directories in Next.js

I would like to use the modularizeImports option of the Next.js compiler on a library that its barrel file exports from multiple directories within the library package. What I mean is the index.ts file for the library looks something like…
5
votes
0 answers

How to setup SWC compiler

I'm using SWC for the first time and I'm not able to compile my ts files into normal js files. When I run my command : npx swc ./src -d dist I got the error : failed to process js file Caused by: 0: failed to read swcrc file (src/index.ts) …
4
votes
1 answer

Next.js how to use SWC compiler with Material UI and swc-plugin-transform-import

I've been struggling with transforming imports with Next.js using SWC complier. I'm trying to make use of swc-plugin-transform-import as a replacement of babel-plugin-transform-imports for shorting on Material UI imports. As documented, I've tried…
ΔO 'delta zero'
  • 3,506
  • 1
  • 19
  • 31
4
votes
1 answer

Getting build time error using webpack 5 and next js 12

This is our next.config.js file const webpack = require('webpack'); // Initialize doteenv library require('dotenv').config(); module.exports = { swcMinify: true, devIndicators: { autoPrerender: false, }, compiler: { …
Athfan
  • 125
  • 8
4
votes
0 answers

How to ignore files with @swc/cli?

I am using swc to transpile my Typescript code on a side project and am struggling ignoring the tests files from the final output using the cli --ignore option. lib versions: @swc/cli: ^0.1.57 @swc/core: ^1.2.173 command: swc ./src --out-dir dist…
rguerin
  • 2,068
  • 14
  • 29
4
votes
2 answers

Can I Get Next.Js to exclude .babelrc during build?

I'd like to not include .babelrc during build since SWC is disabled as a replacement for Babel. I only need .babelrc for a plugin for dev testing purposes that is not supported by SWC yet. I am told to check the doc about ignored compiler options…
Eden Chan
  • 111
  • 1
  • 6
3
votes
0 answers

SWC won't compile jsx content for ".js" files extension

tl;dr How to make SWC compile .js (not .jsx) files which contains React jsx for mocha tests? I'm setting up Mocha + SWC (replacing a current Mocha + Babel setup), and am facing an issue where SWC won't compile jsx content inside .js files. It will…
vsync
  • 118,978
  • 58
  • 307
  • 400
3
votes
0 answers

The current way to 'export default' using decorators in NextJS

I have a NextJS app that I'm upgrading to the latest version to take advantage of SWC (compared to older versions that used Babel). As it turns out NextJS's implementation isn't exactly the same since Babel was supporting the legacy decorator…
geoboy
  • 1,172
  • 1
  • 11
  • 25
1
2 3 4 5