Skip to content

Having import.meta throws an exception #429

@roger-castaldo

Description

@roger-castaldo

Describe the bug
When including the property import.meta in a javascript file to be compressed it creates an error. However import.meta is a valid property supported within es2020

To Reproduce
Currently I have a javascript file containing the following line:
const hosturl = new URL((document===undefined ? (import.meta===undefined ? '' : import.meta.url) : (document.currentScript===null||document.currentScript===undefined ? import.meta.url : document.currentScript.src)));
When running Uglfiy.Js() against that file it causes an error

Minified output or stack trace
When minifying some javascript with this in it, I end up receiving a set of errors similar to:
Errors:
Expected "from": .:[4:56]
Expected string literal: .:[4:56]
Expected ';':[4:56]
Expected "from": .:[4:87]
Expected string literal: .:[4:87]
Expected ';':[4:87]
Expected "from": .:[4:175]
Expected string literal: .:[4:175]
Expected ';':[4:175]
Import statement must include module name: import:[4:50]
Import statement must include module name: import:[4:81]
Import statement must include module name: import:[4:169]

Excepted output code
it should simplye treat import.meta as a valid property and compress it as such. Not sure how this line would look compressed honestly.

If there is a desire for me to fork and bring about a PR with an attempt to fix this, I will gladly do so.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions