Next.js Discord

Discord Forum

Detecting/verifying that SWC is actively in use at runtime (instead of Babel)

Answered
Varied Thrush posted this in #help-forum
Open in Discord
Varied ThrushOP
Hello! What's the best/easiest/most reliable way to detect if a running NextJS instance is actually using SWC or not?

I'm trying to debug a standalone mode of NextJS with Yarn as the package manager inside a Docker image - I can't see any "SWC Failed to Load" error anywhere, but I also cannot see any SWC binaries existing on my Docker image. 🤔
Answered by joulev
pretty sure SWC is only used during the compilation process at build time
View full answer

15 Replies

Varied ThrushOP
Even without the Docker involved, there are no SWC binaries inside the standalone/node_modules folder 😞
... but no errors/warnings when I run it (server.js)
NextJS uses SWC by default not babel or anything else.

The only other thing it might be using is turbopack, but you need to manually enable it for that to happen.
Varied ThrushOP
How do I verify it?
How can it use SWC without the binaries?
pretty sure SWC is only used during the compilation process at build time
Answer
Yes its not required for a standalone app since its only used for bundling or compiling.
Varied ThrushOP
Hmmm. Interesting. So not even any SSR and/or React Server Components use it for anything in production on server side and SWC is strictly used only for dev server and pre-production compilation? 🤔
@Varied Thrush Hmmm. Interesting. So not even any SSR and/or React Server Components use it for anything in production on server side and SWC is strictly used only for dev server and pre-production compilation? 🤔
swc is used for compilation, so the step translating your code into bundle and chunk files

the prod server only needs those output bundle and chunk files, it doesn't need your source code (so doesn't need a way to translate your source code)
Varied ThrushOP
Super interesting. I'm just migrating from NPM to Yarn and when I used NPM I remember having these binaries in the standalone/node_modules and/or final Docker image. I thought that not having these binaries in runtime is some bug/issue with using Yarn 😅
well, if it works it works haha
as long as your app runs smoothly, you need not worry about the internals
Varied ThrushOP
Well, ten times faster performance is not something you want to miss out on just because of some misconfiguration 🙃
the performance improvement is only during the compilation step, don't worry
Varied ThrushOP
+ Docker images got smaller 🎉