Skip to content

Cannot compile import.meta #3834

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

Open
AshleyScirra opened this issue Jun 16, 2021 · 1 comment
Open

Cannot compile import.meta #3834

AshleyScirra opened this issue Jun 16, 2021 · 1 comment
Assignees
Labels
triage-done Has been reviewed by someone on triage rotation.

Comments

@AshleyScirra
Copy link

AshleyScirra commented Jun 16, 2021

This comment appears to indicate pass-through for import.meta is supported, but it still doesn't seem to work in v20210601.

Input test.js: console.log(import.meta.url);

Command line: java -jar ./closure-compiler.jar --compilation_level SIMPLE --language_in ECMASCRIPT_2020 --language_out ECMASCRIPT_2020 --allow_dynamic_import --js test.js --js_output_file out.js

Output:

test.js:1:12: ERROR - [JSC_CANNOT_CONVERT] This code cannot be converted from ES6. import.meta
  1| console.log(import.meta.url);
                 ^^^^^^^^^^^

1 error(s), 0 warning(s)

We previously used document.currentScript.src, which Closure accepts fine (and our code knows about how Closure can transform and combine files, and handles it accordingly). However the lack of Closure support for import.meta blocks us switching from classic scripts to modules. It should have the same kind of pass-through support as was added for dynamic import.

@rishipal
Copy link
Contributor

I can repro this with v20210601.

@ChadKillingsworth , looks like import.meta is not supported in code here -

t.report(n, Es6ToEs3Util.CANNOT_CONVERT, "import.meta");
?

@rishipal rishipal added the triage-done Has been reviewed by someone on triage rotation. label Jun 18, 2021
@ChadKillingsworth ChadKillingsworth self-assigned this Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

3 participants