For question about SWC (Speedy Web Compiler), a Rust-based JavaScript compiler.
Questions tagged [swc-compiler]
70 questions
1
vote
1 answer
How to create a Vec with data type ExprOrSpread for an SWC plugin?
I am developing an SWC plugin in Rust.
[dependencies]
swc_core = "0.75.*"
swc_ecma_parser = "0.133.8"
I need to replace the argument in console.log("hello") with console.log("world")
fn visit_mut_call_expr(&mut self, n: &mut CallExpr) {
n.args…

Roman
- 175
- 2
- 3
- 15
1
vote
2 answers
React Context doesn't compile on Vite
I am trying to implement a small context store for my React project. I copied most of this code from a previous (working) project and changed the variable names - the biggest difference was I changed to Vite+SWC.
This is the code.
import {…

XeonFusion
- 13
- 4
1
vote
0 answers
What is swc (Rust based platform)? Swc vs babel
I am working on the Nextjs project and found that they have now used swc instead of babel. I am still confusing all the terminologies about what they do to make the compiling and bundling faster than 20x. Also, I am still wondering about the impact…

anne.script
- 41
- 6
1
vote
2 answers
How to properly configure NextJS 12.2 w/ SWC, Jest, Eslint, and Typescript?
Using VSCode and can't resolve error that next/babel with Jest files. Any Suggestions?
I am using NextJS with SWC and have "extends": "next" in my .eslintrc file.
Parsing error: Cannot find module 'next/babel'
This below is from my package.json…

HXavS
- 119
- 7
1
vote
1 answer
How do I pass a JS function expression for creating an swc plugin in rust?
I am trying to follow this SWC documentation for developing a plugin that can compile to wasm. The visit_mut_callee function has a conditional statement
if let Callee::Expr(expr) = callee {
Callee::Expr(expr) accepts a Box as per…

Shujath
- 846
- 1
- 8
- 22
1
vote
2 answers
SWC's bundler compiles to ES6 import instead of require
Is it possible to have SWC bundle TypeScript files whilst transforming ES6 imports to commonjs require()? Not sure if I can not get it to work due to my limited understanding, or whether I am missing a certain option.
Basically, I have an entry TS…

Sebastian
- 259
- 3
- 10
1
vote
0 answers
Performance decrease after switching to SWC
I switched my NextJS app to SWC (I removed Babel`s config, and enabled the emotion plugin).
Now, I see that build time has increased from 80 s to ~200 s.
Does anyone have a similar experience?
My next.config.js:
// @ts-check
const path =…

Bart Krakowski
- 1,655
- 2
- 8
- 25
1
vote
1 answer
How to enable SWC Aliased imports in Next JS?
Upgrading from babel to SWC. I deleted the .babelrc file but now the path aliases are no longer recognized in my project. Tried to restore this with a .swrc
.swrc
{
"jsc": {
"target": "ES2017",
"baseUrl": ".",
"paths":…

BillPull
- 6,853
- 15
- 60
- 99
1
vote
1 answer
Compile tailwindcss + typescript
I have a very simple app with some html, css, and ts files. I use swc to compile the typescript and copy over the html/css/assets. Now, I'm looking to add tailwind to my project, but I'm not sure how it will fit in to the build process.
Currently,…

Simon Berens
- 554
- 4
- 11
1
vote
0 answers
Migrating from Babel to SWC with Rollup
I'm planning to Migrate from Babel to SWC, but I can't find the way how to use @babel/plugin-transform-runtime in SWC. To avoid polluting the global scope, I want to create a sandboxed environment for my code.
build.js(Babel)
const buildBundle =…

Figger
- 11
- 1
1
vote
0 answers
Is it possible to split one javascript file to multiple files by swc?
I have a javascript file like this
// file demo.js
export function a(){
// TODO
}
export function b(){
// TODO
}
I want to get two files by swc
// a.js
export function a(){
// TODO
}
// b.js
export function b(){
// TODO
}

devil
- 11
- 1
1
vote
1 answer
Webpack - Module build failed when bundling `swc-loader`
I am working on a Webpack tool that can build itself. I am able to build the tool the first time but when I try to rebuild it a second time I get the error Cannot find module: swc-loader. The same issue exists when swapping swc-loader with…

woodpav
- 1,917
- 2
- 13
- 26
0
votes
0 answers
NestJs v10 Error: Cannot find module 'src/app.module'
I just install NestJs v10 and have an error when start
> nest start --watch
> SWC Running...
Successfully compiled: 4 files with swc (14.34ms)
Watching for file changes.
Error: Cannot find module 'src/app.module'
Require stack:
-…

Ducnb
- 3
- 3
0
votes
0 answers
expect(jest.fn()).toHaveBeenCalledWith(...expected), SWC/jest error
This is the import statement that I used:
import * as mixpanelTest from '../../../../utils/mixpanel';
This is the mock function I used:
jest.mock('../../../../utils/mixpanel', () => {
const actualModule = jest.requireActual(
…
0
votes
0 answers
Combining Babel Library in SWC Next.js: Integrate external Babel-dependent package while preserving SWC compilation
In my Next.js project, the primary compiler is SWC. However, I have a component that relies on an external library compiled with Babel. Is it feasible to configure Next.js to use Babel exclusively for this particular component while continuing to…

Rodolfo Campos
- 199
- 1
- 8