Skip to content

stream did not contain valid UTF-8 #2154

Description

Describe the bug

$ swc index.js -o dist/swc.js
failed to load file

Caused by:
    stream did not contain valid UTF-8
Error: Failed to compile 1 file with swc.

Input code

const c = (<img alt="café" />).props.alt;

console.log(c);

Config

{
	"env": {
		"shippedProposals": true
	},
	"jsc": {
		"parser": {
			"syntax": "ecmascript",
			"jsx": true
		}
	}
}

Expected behavior
Like babel, run successfully: https://babeljs.io/repl/#?browsers=safari%2012&build=&builtIns=false&corejs=3.6&spec=false&loose=false&code_lz=MYewdgzgLgBMMF4YAoA8BLAtgcxgQwBsoEAiYPAMwEuSYB6APgEoA6ABwCcQ2IXCoA3ACghoSCAIBTFgRDZkwJsKA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=react&prettier=false&targets=&version=7.15.3&externalPlugins=&assumptions=%7B%7D

const c = /*#__PURE__*/React.createElement("img", {
  alt: "caf\uFFFD"
}).props.alt;
console.log(c);

Version
The version of @swc/core: 1.2.82

Additional context
Add any other context about the problem here.

Context
Somewhat related to parcel-bundler/parcel#6764

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions