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

Invalid or unexpected token #9943

Open
LukeTOBrien opened this issue Sep 6, 2024 · 1 comment
Open

Invalid or unexpected token #9943

LukeTOBrien opened this issue Sep 6, 2024 · 1 comment

Comments

@LukeTOBrien
Copy link

LukeTOBrien commented Sep 6, 2024

🐛 bug report

I am getting the following:

Uncaught SyntaxError: Invalid or unexpected token 

The line in question:

var th=basePropertyOf({À:"A",�:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a"...

These are unicode and I don't know why they are being produced.

🎛 Configuration (.babelrc, package.json, cli command)

Parcelrc

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
  }
}

terser (Reserved Jquery $ and Leaflet L)

{
    "compress": {
        "hoist_props": false
    },
    "mangle" : {
        "reserved" : [ "$", "L" ],
        "keep_fnames": true
    }
}

Package:

"dependencies": {
        "@interactjs/interactjs": "^1.10.11",
        "@popperjs/core": "^2.10.1",
        "@svgdotjs/svg.js": "^3.2.4",
        "@swc/helpers": "^0.4.12",
        "@types/toastr": "^2.1.38",
        "bind-decorator": "^1.0.11",
        "hammerjs": "^2.0.8",
        "jquery": "^3.5.1",
        "lit": "^3.2.0",
        "tippy.js": "^6.2.7",
        "vanilla-tilt": "^1.8.1",
        "vexflow": "^4.2.5"
    },
    "devDependencies": {
        "@parcel/optimizer-data-url": "^2.12.0",
        "@parcel/transformer-inline-string": "^2.12.0",
        "@parcel/transformer-less": "^2.12.0",
        "@parcel/transformer-typescript-tsc": "^2.12.0",
        "@types/bingmaps": "0.0.1",
        "@types/chart.js": "^2.9.37",
        "@types/google.maps": "^3.57.0",
        "@types/hammerjs": "^2.0.36",
        "@types/jquery": "^3.5.14",
        "@types/leaflet": "^1.9.12",
        "autoprefixer": "^9.8.6",
        "copyfiles": "^2.4.1",
        "less": "^3.12.2",
        "parcel": "^2.12.0",

tsconfig:

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": false,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true,
        "esModuleInterop": true,
        "target": "ES2020",
        "experimentalDecorators": true,
        "useDefineForClassFields": false
    }
}

🤔 Expected Behavior

Just work.

🌍 Your Environment

Software Version(s)
Parcel 2.12
Node 22.8
npm 10.8.2
Operating System Window 11
@LukeTOBrien
Copy link
Author

Hello,

I found this post on the Terser repo: terser/terser#1005
I then added the following to my .terserrc and it seems to have solved the issue:
(It is still really strange)

"format": {
        "ascii_only": true
    }

I must say that I am confused around the area of minification.
Your documentation says:

Parcel uses SWC to minify JavaScript

But then it says:

you can configure these tools using a .terserrc

So is Parcel using SWC or Terser?
The sentence says SWC but we are using terser configuration?

I think the documentation can be improved by explaining more and making it clearer.

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

No branches or pull requests

1 participant