Compiling with SWC

I've been trying to compile my code with SWC and it is finding errors in a couple of my files that were created using the CLI. Those files are src/commands/General/Ping.ts and src/listeners/ready.ts These are the errors that are presented:
> rimraf dist && swc ./src -d dist


× Expression expected
╭─[src/listeners/ready.ts:4:1]
4 │
5 │ const dev = process.env.NODE_ENV !== 'production';
6 │
7 │ @ApplyOptions<Listener.Options>({ once: true })
· ─
8 │ export class UserEvent extends Listener {
9 │ private readonly style = dev ? yellow : blue;
╰────


Caused by:
Syntax Error

× Expression expected
╭─[src/commands/General/Ping.ts:2:1]
2 │ import { isMessageInstance } from '@sapphire/discord.js-utilities';
3 │ import { Command } from '@sapphire/framework';
4 │
5 │ @ApplyOptions<Command.Options>({
· ─
6 │ description: 'Returns the round trip and heartbeat'
7 │ })
8 │ export class UserCommand extends Command {
╰────


Caused by:
Syntax Error
Successfully compiled: 11 files with swc (23.51ms)
Failed to compile 2 files with swc.
Error: Failed to compile:
src/listeners/ready.ts
src/commands/General/Ping.ts
at initialCompilation (/home/demonicpagan/development/nodejs/discordBots/discord-trakt/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:163:19)
at async dir (/home/demonicpagan/development/nodejs/discordBots/discord-trakt/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:228:5)
 ELIFECYCLE  Command failed with exit code 1.
> rimraf dist && swc ./src -d dist


× Expression expected
╭─[src/listeners/ready.ts:4:1]
4 │
5 │ const dev = process.env.NODE_ENV !== 'production';
6 │
7 │ @ApplyOptions<Listener.Options>({ once: true })
· ─
8 │ export class UserEvent extends Listener {
9 │ private readonly style = dev ? yellow : blue;
╰────


Caused by:
Syntax Error

× Expression expected
╭─[src/commands/General/Ping.ts:2:1]
2 │ import { isMessageInstance } from '@sapphire/discord.js-utilities';
3 │ import { Command } from '@sapphire/framework';
4 │
5 │ @ApplyOptions<Command.Options>({
· ─
6 │ description: 'Returns the round trip and heartbeat'
7 │ })
8 │ export class UserCommand extends Command {
╰────


Caused by:
Syntax Error
Successfully compiled: 11 files with swc (23.51ms)
Failed to compile 2 files with swc.
Error: Failed to compile:
src/listeners/ready.ts
src/commands/General/Ping.ts
at initialCompilation (/home/demonicpagan/development/nodejs/discordBots/discord-trakt/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:163:19)
at async dir (/home/demonicpagan/development/nodejs/discordBots/discord-trakt/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@swc/cli/lib/swc/dir.js:228:5)
 ELIFECYCLE  Command failed with exit code 1.
This is my config for SWC, .swcrc
{
"env": {
"target": {
"node": 20
}
},
"jsc": {
"parser": {
"syntax": "typescript"
}
},
"module": {
"type": "commonjs"
},
"sourceMaps": "inline"
}
{
"env": {
"target": {
"node": 20
}
},
"jsc": {
"parser": {
"syntax": "typescript"
}
},
"module": {
"type": "commonjs"
},
"sourceMaps": "inline"
}
Solution:
Compilation – SWC
SWC is an extensible Rust-based platform for the next generation of fast developer tools. It's used by tools like Next.js, Parcel, and Deno, as well as companies like Vercel, ByteDance, Tencent, Shopify, and more.
Jump to solution
1 Reply
Solution
Sawako
Sawako13mo ago
Compilation – SWC
SWC is an extensible Rust-based platform for the next generation of fast developer tools. It's used by tools like Next.js, Parcel, and Deno, as well as companies like Vercel, ByteDance, Tencent, Shopify, and more.
Want results from more Discord servers?
Add your server