swc-project / swc-project/swc-node

Version "1.10.9" gives error "Failed to deserialize buffer as swc::config::Options"

Open
#829 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
95
Avg merge
14d 11h
Merged PRs (30d)
1

Description

With Node v20.15.1, "@swc-node/register" worked fine with v1.9.1, but gives the following error on 1.10.9:

...i/node_modules/.pnpm/@swc+core@1.3.41/node_modules/@swc/core/index.js:241
return bindings.transformSync(isModule ? JSON.stringify(src) : src, isModule, toBuffer(newOptions));
Error: Failed to deserialize buffer as swc::config::Options

If it helps, here's our .swcrc:

[
	{
		"$schema": "https://json.schemastore.org/swcrc",
		"env": {
			"targets": {
				"node": "20.15.1"
			}
		},
		"test": ".*.(ts|js)$",
		"jsc": {
			"target": "es2021",
			"externalHelpers": false,
			"parser": {
				"syntax": "typescript",
				"decorators": true,
				"dynamicImport": true
			},
			"keepClassNames": true,
			"loose": true,
			"transform": {
				"legacyDecorator": false,
				"decoratorMetadata": true
			}
		},
		"module": {
			"type": "commonjs"
		},
		"sourceMaps": "inline"
	},
	{
		"test": ".*.json$",
		"jsc": {
			"transform": {
				"optimizer": {
					"jsonify": {
						"minCost": 0
					}
				}
			}
		}
	}
]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with Node v20.15.1 and the supplied .swcrc, starting at @swc/core/index.js line 241 and comparing @swc-node/register versions 1.9.1 and 1.10.9. Trace which configuration causes deserialization to fail, then verify the issue is resolved without breaking the shown TypeScript, decorator, CommonJS, and JSON cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.