swc: [WRONG] `jsc.experimental.keepImportAssertions` is `experimental`, explicitly

Describe the bug

The bug is described here: https://github.com/TypeStrong/ts-node/issues/2056

With version 1.3.83, swc renames the experimental configuration option jsc.experimental.keepImportAssertions to jsc.experimental.keepImportAttributes as per https://github.com/swc-project/swc/pull/7914

Suggestion to keep other libraries working without so much failure:

  • Adding jsc.experimental wrong or non-supported keys shouldn’t throw an error ( maybe warning )
  • Alias renamed keys to the new keys to it still backward compatible

The error during running ts-node:

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,"dynamicImport":true,"importAssertions":true},"target":"es2015","transform":{"legacyDecorator":true,"react":{"throwIfNamespace":false,"useBuiltins":false}},"keepClassNames":false,"experimental":{"keepImportAssertions":true}}}

Caused by:
    unknown field `keepImportAssertions`, expected one of `plugins`, `keepImportAttributes`, `emitAssertForImportAttributes`, `cacheRoot`, `disableBuiltinTransformsForInternalTesting` at line 1 column 396

Input code

No response

Config

No response

Playground link

No response

SWC Info output

No response

Expected behavior

The build should be working normally

Actual behavior

No response

Version

1.3.83

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 7
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

My previously-working ts-node installation is now broken after installing the latest @swc/core version. Reverting to @swc/core@1.3.82 explicitly fixes the issue.

@kdy1 I understand your explanation regarding the option being experimental, yet it appears that ts-node, for some reason, chose to make use of this configuration option. By changing this in swc in a minor patch you are breaking any user of ts-node + swc. Users do not have control over a fix until ts-node merges this PR: https://github.com/TypeStrong/ts-node/pull/2057/files

I’ve been advertising for this approach on my blog and expect it is quite commonly used. I don’t know how long it will take for ts-node to publish a new release, but it would be great if you could revert this change until ts-node has published an update to their project.

ts-node already has the necessary fixes on the main branch, we just need a new release.

@josser The fix is already published as v1.3.84.

https://github.com/swc-project/swc/blob/f66da772202a6f065488fbabb7e0a9d9a2d7089d/CHANGELOG.md#1384---2023-09-11

I won’t add an alias to the deprecated experimental option, though.

Honestly, I’m really against such PR, but I don’t want to think/debate about it