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

Unable to use JSON modules with @swc-node/register #774

Closed
maxburs opened this issue May 15, 2024 · 0 comments · Fixed by #777
Closed

Unable to use JSON modules with @swc-node/register #774

maxburs opened this issue May 15, 2024 · 0 comments · Fixed by #777

Comments

@maxburs
Copy link

maxburs commented May 15, 2024

I've tried:
node --import @swc-node/register/esm-register script.ts
SWCRC=true node --import @swc-node/register/esm-register script.ts
SWC_NODE_PROJECT=null node --import @swc-node/register/esm-register script.ts

with no luck

If I set jsc.experimental.keepImportAssertions then I can get the cli to produce output that works.

image

Node v20.13.1
macOS 14.4.1 (23E224)
Yarn 4.2.2 (node_modules linker)

tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "lib": ["es2023"],
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "target": "esnext",
    "resolveJsonModule": true
  }
}

.swcrc

{
  "$schema": "https://swc.rs/schema.json",
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "importMeta": true
    },
    "target": "es2022",
    "experimental": {
      "keepImportAssertions": true
    }
  },
  "isModule": true
}

Reproduction: https://github.com/maxburs/swc-node

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

Successfully merging a pull request may close this issue.

1 participant