swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.69k stars 69 forks source link

Syntax error after updating to 1.6.8 #734

Closed MrFoxPro closed 3 months ago

MrFoxPro commented 9 months ago

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 ```jsonc { "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.

dmythro commented 9 months ago

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.

cm-ayf commented 9 months ago

I authored the PR #727 and I suspect that the PR broke something. I'm going to figure it out.

EffectivelyEfficient commented 8 months ago

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 ']'·
HashemKhalifa commented 8 months ago

same issue here!

FlorinAsavoaie commented 5 months ago

@cm-ayf any luck with this?

yeliex commented 4 months ago

754 should fix this. please test and feedback

FlorinAsavoaie commented 3 months ago

Looks good. Can be closed.

AmauryD commented 3 months ago

Last release fixed the issue for me