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

Source code could not be parsed (Unexpected UTF-8 character) #13468

Closed
kefniark opened this issue Jan 22, 2022 · 5 comments
Closed

Source code could not be parsed (Unexpected UTF-8 character) #13468

kefniark opened this issue Jan 22, 2022 · 5 comments
Assignees
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@kefniark
Copy link

Description

I have a language detection library tinyld which works in node (CJS) and browser (ESM) without trouble.

But I run into a strange issue when I try to use it in deno.

error: The module's source code could not be parsed: Unexpected character 'ำ'

The issue come from a big object where I store n-gram for different languages (as utf-8 strings)
I have thousands of other keys in there which do not cause any problem (japanese, chinese, arabic, ...)

 //...
 : 9,
 : 9,
 : 9,
 : 9,
  : 9,
 //...

But I don't now why, there is one specific thai character, which cause that Unexpected character error
If I remove that line, it works fine.

So my question, is there a reason why this specific utf-8 character cause trouble?

P.S. I noticed that the same problem seem to appear in VSCode.
It kinda feel like this character is detected as a single quote, maybe more a typescript issue than deno.

image

@kefniark kefniark changed the title Source code utf-8 issue Source code could not be parsed (Unexpected UTF-8 character) Jan 22, 2022
@andreubotella
Copy link
Contributor

This is not a bug with Deno's UTF-8 decoding, but an upstream bug with swc's parsing of JS/TS identifiers (variable names, etc., including non-string property names in object literals, as in this case). I filed swc-project/swc#3341.

@kefniark
Copy link
Author

Thanks for the quick feedback 👍

@kitsonk kitsonk added bug Something isn't working correctly swc related to swc (bundling/transpiling) labels Jan 22, 2022
@andreubotella
Copy link
Contributor

This is now fixed upstream: swc-project/swc#3867

@bartlomieju
Copy link
Member

@dsherret can we close this issue now?

@dsherret
Copy link
Member

dsherret commented Apr 27, 2022

Yes, it seems fixed in 1.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)
Projects
None yet
Development

No branches or pull requests

5 participants