google / google/closure-compiler

Compiler crash for dynamic imports importing goog.module

Open
#3,841 4 comments 0 reactions 1 assignee Claimed by @ChadKillingsworth View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

a.js
```js
goog.module('a');
import('./b.js').then(out => {
console.log(out.b);
});
```
b.js
```js
goog.module('b');
/** @type {number} */
exports.b = 1;
```
compiler flags
```
--language_in=ECMASCRIPT_2020
--language_out=ECMASCRIPT_2020
--chunk_output_type=ES_MODULES
--emit_use_strict=false

--js=b.js
--chunk=b_out:1
--js=a.js
--chunk=a_out:1:b_out
```
Then the compiler crashes with a message to report it.

On a related note, I have a question: Is dynamic import supposed to work in goog.module? Or is it supposed to use some other Closure Library function to achieve on-demand loading of other goog.modules?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.