google / google/closure-compiler

Re-export goog.provide modules stop working since 20190325.0.0

Open
#3,425 5 comments 0 reactions 0 assignees View on GitHub
internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

I use to re-export closure-library modules to use in ES6 modules. Can't compile our project since version 20190325.0.0. Is it intended behavior and is there a way to make such re-exports work?

Simple example to reproduce the error:
```javascript
// main.js
import { bar } from './foo.js';
console.log(bar());
```

```javascript
// foo.js
const { bar } = goog.require('module.foo');
export { bar };
```

```javascript
// closure-provide.js
goog.provide('module.foo');
module.foo.bar = function() {
return 'baz';
}
```

```
npx google-closure-compiler --js=main.js --js=foo.js --js=closure-provide.js --entry_point=main.js --compilation_level=ADVANCED

main.js:3: ERROR - [JSC_UNDEFINED_VARIABLE] variable bar$$module$foo is undeclared
console.log(bar());
^^^

1 error(s), 0 warning(s)
```

```
npx google-closure-compiler@20190301.0.0 --js=main.js --js=foo.js --js=closure-provide.js --entry_point=main.js --compilation_level=ADVANCED

console.log("baz");
```

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.