google / google/closure-compiler

ES6 circular dependencies

Open
#1,883 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

I have the following files

```js
//test1.js
import {Test2} from 'test2';
export class Test1 {
constructor() {
console.log(new Test2());
}
}

//test2.js
import {Test1} from 'test1';
export class Test2 {
constructor() {
console.log(new Test1());
}
}

//main.js
import {Test1} from 'test1';
console.log(new Test1());
```

on compiling in Advanced mode I get this error:

> test2.js:1: ERROR - required "module$test1" namespace not provided yet
> import {Test1} from 'test1';

Is this a bug or am I doing something wrong? If I comment the import line in test2.js it compiles but not with the result I want:

```js
function a() {
console.log(new Test1); // !!!! who is Test1 ????
}
;console.log(new function() {
console.log(new a);
});
```

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.