google / google/closure-compiler
Support passthrough dynamic import, or basic code doesn't work
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Please at least support a basic passthrough for dynamic import for Closure Compiler. In the current version, any presence of dynamic import at all causes a compilation failure. This causes even basic use cases of dynamic import to cause the entire compilation to fail.
Example in.js:
```js
(async () =>
{
await import("https://cdn.example.com/library.js");
externalLibrary.someFunc();
})();
```
Command line:
`java -jar ./closure-compiler.jar --js in.js --js_output_file out.js --compilation_level SIMPLE --formatting PRETTY_PRINT --language_in ECMASCRIPT_2020 --language_out ECMASCRIPT_2020`
Observed result:
```
in.js:4:7: WARNING - [JSC_PARSE_ERROR] Parse error. This language feature is not currently supported by the compiler: Dynamic module import
4| await import("https://cdn.example.com/library.js");
^
ERROR - [JSC_FEATURES_NOT_SUPPORTED_BY_PASS] Attempted to run pass "markUntranspilableFeaturesAsRemoved" on input with features it does not support. Running pass anyway.
Unsupported features: [Dynamic module import]
1 error(s), 1 warning(s)
```
No output file is generated.
Expected result:
Just output the file with all transforms, but passthrough `import(XYZ)` -> `import(XYZ)`
This is blocking us using JavaScript modules at all in our code. We want to insert a dynamic import, but then Closure Compiler will refuse to process any of our code at all.
Contributor guide
Assessment
This issue has not been assessed yet.