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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-ASCII characters in identifiers result in invalid escape sequences #9632

Open
JavierGelatti opened this issue Apr 9, 2024 · 0 comments 路 May be fixed by #9574
Open

Non-ASCII characters in identifiers result in invalid escape sequences #9632

JavierGelatti opened this issue Apr 9, 2024 · 0 comments 路 May be fixed by #9574

Comments

@JavierGelatti
Copy link

馃摐 related issues I've found

馃悰 bug report

Non-ASCII characters in identifiers result in invalid escape sequences when the code is bundled/optimized. This is a problem not only when using greek letters (e.g. in a mathy domain: function p(碌, 蟽) {}), but also when programming in languages other than english (e.g. when using accents in spanish, like in m贸dulo).

This started happening in version 2.10.0 onwards, with 2.9.3 it doesn't do that.

馃帥 Configuration (.babelrc, package.json, cli command)

The babel configuration is the default one (no babel.config.json file or anything like that).

The package.json file contains:

{
  "scripts": {
    "start": "parcel index.html"
  },
  "devDependencies": {
    "parcel": "2.10.0"
  }
}

馃 Expected Behavior

With this HTML file as input (index.html):

<!doctype html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Mi documento</title>
    <script type="module">
        const m贸dulo = 123;
        console.log(m贸dulo);
    </script>
</head>
<body></body>
</html>

My expectations are:

  • When running npm start and browsing the localhost page, I should see 123 printed in the console.
  • When inspecting the generated JS code, a correct escape sequence is inserted in place of the in m贸dulo. For example:
    const m\u{0f3}dulo = 123;
    console.log(m\u{0f3}dulo);
    Alternatively, I should see the code without modifications:
    const m贸dulo = 123;
    console.log(m贸dulo);

馃槸 Current Behavior

  • I see an error in the console: Uncaught SyntaxError: invalid escape sequence in Firefox, Uncaught SyntaxError: Invalid or unexpected token in Chrome.
  • The generated JS code is invalid, as the escape sequence is invalid for an identifier:
    const m\xf3dulo = 123;
    console.log(m\xf3dulo);

馃拋 Possible Solution

馃敠 Context

I was trying to use parcel in a project which uses spanish as the language for the code (on variable names, etc.).

馃捇 Code Sample

See "Expected behavior"

馃實 My Environment

Software Version(s)
Parcel 2.10.0
Node 20.11.1
npm/Yarn 10.5.0
Operating System Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants