google / google/closure-compiler
Cannot compile import.meta
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
[This comment](https://github.com/google/closure-compiler/issues/3707#issuecomment-834744655) 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.
Contributor guide
Assessment
This issue has not been assessed yet.