Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting emitAssertForImportAttributes no longer works in Node.js 22 with latest swc #2117

Open
KidkArolis opened this issue May 3, 2024 · 0 comments

Comments

@KidkArolis
Copy link

KidkArolis commented May 3, 2024

Expected Behavior

Running this with ts-node should work when swc: true is set:

import pkg from './package.json' with { type: 'json' }
console.log(pkg)

Actual Behavior

import pkg from './package.json' assert {
                                 ^^^^^^

SyntaxError: Unexpected identifier 'assert'

Specifications

  • ts-node version: 10.9.2
  • node version: 22.1.0
  • TypeScript version: 5.3.3
  • @swc/core 1.4.17

Note

Node.js 22 removed import asserts and now only has import attributes. Setting emitAssertForImportAttributes to false in dist/transpilers/swc.js fixes the issue, but ofc, this would break the existing users, so not sure how to approach this!? A config option..? A breaking change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant