swc-node
swc-node copied to clipboard
Syntax error after updating to 1.6.8
After upgrading from 1.6.7 to 1.6.8, I get following error:
[api]
[api] node:internal/process/esm_loader:48
[api] internalBinding('errors').triggerUncaughtException(
[api] ^
[api] [Error:
[api] x Expected ',', got '{'
[api] ,-[file:///home/foxpro/craft/sferadel/dev/api/main.mts:2:1]
[api] 2 | import * as path from "node:path"
[api] 3 | import { availableParallelism } from "node:os"
[api] 4 | import * as fs from "node:fs/promises"
[api] 5 | import type { Worker } from "node:cluster"
[api] : ^
[api] 6 | import cluster from "node:cluster"
[api] 7 | import { match } from "ts-pattern"
[api] 8 | import { createYoga } from "graphql-yoga"
[api] `----
[api]
[api]
[api] Caused by:
[api] Syntax Error] {
[api] code: 'GenericFailure'
[api] }
[api]
[api] Node.js v20.6.1
[api] [[Command exited with 1]]
My .swcrc:
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"baseUrl": ".",
"parser": {
"syntax": "typescript"
},
"target": "esnext",
"loose": true,
"paths": {
"#/*": ["./*"],
"#eql": ["./eql/index.mts"],
"#eql/types": ["./eql/types.d.ts"]
}
},
"module": {
"type": "es6"
}
}
My tsconfig.json
{
"compilerOptions": {
"strict": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": ".",
// "sourceMap": true, // mandatory for SWC
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
// "resolvePackageJsonImports": true,
// https://github.com/swc-project/swc-node/pull/723
"paths": {
"#/*": ["./*"],
"#eql": ["./eql/index.mts"],
"#eql/types": ["./eql/types.d.ts"]
},
"noEmit": true,
"isolatedModules": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true
},
"exclude": ["**/node_modules", "**/.*/"]
}
I tried with "@swc/core": "^1.3.86" and "@swc/core": "^1.3.90", no difference.
Also got error on importing: Error [ERR_MODULE_NOT_FOUND]: Cannot find module for path alias in tsconfig's paths, but works perfectly fine with v1.6.7.
I authored the PR #727 and I suspect that the PR broke something. I'm going to figure it out.
I got the following message from v1.6.8, but not from v1.6.7. This is using esm and the npm package mysql2,
const [tableNames] = await mysqlPool().query<RowDataPacket[]>(·
^···
SyntaxError: Unexpected token ']'·
same issue here!
@cm-ayf any luck with this?
#754 should fix this. please test and feedback
Looks good. Can be closed.
Last release fixed the issue for me