TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.84k stars 535 forks source link

The latest version of @swc/core has made a break change, resulting in ts-node reporting an error. #2059

Closed atorber closed 1 year ago

atorber commented 1 year ago

"ts-node": "^10.9.1"

"@swc/core": "^1.3.78" is ok,but subsequent versions will report errors.

The peerDependencies declaration in the ts node/package.json file will cause the installation of the latest dependent package instead of the specified one.

"peerDependencies": { "@swc/core": ">=1.2.50", "@swc/wasm": ">=1.2.50", "@types/node": "*", "typescript": ">=4.2" }

atorber commented 1 year ago

An example of running an error message : https://github.com/choogoo/chatflow/issues/40

MuTsunTsai commented 1 year ago

I think this is the same as #2056.

thetutlage commented 1 year ago
node:internal/process/esm_loader:46
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: @swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Failed to deserialize buffer as swc::config::Options
JSON: {"sourceMaps":true,"module":{"noInterop":false,"type":"commonjs","strictMode":true,"ignoreDynamic":false},"swcrc":false,"jsc":{"parser":{"syntax":"typescript","tsx":false,"decorators":true,"dynamicImport":true,"importAssertions":true},"target":"es2022","transform":{"decoratorMetadata":true,"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false}},"keepClassNames":true,"experimental":{"keepImportAssertions":true}}}

Caused by:
    unknown field `keepImportAssertions`, expected one of `plugins`, `keepImportAttributes`, `emitAssertForImportAttributes`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 438
    at createVariant (/Users/virk/app/node_modules/ts-node/src/transpilers/swc.ts:262:13)
    at createSwcOptions (/Users/virk/app/node_modules/ts-node/src/transpilers/swc.ts:211:25)
    at create (/Users/virk/app/node_modules/ts-node/src/transpilers/swc.ts:56:41)
    at createTranspiler (/Users/virk/app/node_modules/ts-node/src/index.ts:784:16)
    at createTranspileOnlyGetOutputFunction (/Users/virk/app/node_modules/ts-node/src/index.ts:1341:28)
    at createFromPreloadedConfig (/Users/virk/app/node_modules/ts-node/src/index.ts:1404:34)
    at create (/Users/virk/app/node_modules/ts-node/src/index.ts:624:10)
    at register (/Users/virk/app/node_modules/ts-node/src/index.ts:591:15)
    at Object.registerAndCreateEsmHooks (/Users/virk/app/node_modules/ts-node/src/esm.ts:116:34)
    at file:///Users/virk/app/node_modules/ts-node/esm.mjs:8:7

Here's the error

SalvatorePreviti commented 9 months ago

Is there any release date planned soon? SWC new version is 1.3.100 and I had to lock the version to 1.3.82 because this is not still released

MuTsunTsai commented 9 months ago

@SalvatorePreviti Somewhere around SWC 1.3.96 the issue was gone for me, and I no longer need to lock to 1.3.82.

SalvatorePreviti commented 9 months ago

@SalvatorePreviti Somewhere around SWC 1.3.96 the issue was gone for me, and I no longer need to lock to 1.3.82.

Thank you, you are right, it works