Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Webpack and Gulp plugins don't read jsCode/externs file content #66

Closed
DIYgod opened this issue Jun 7, 2017 · 3 comments
Closed

Webpack and Gulp plugins don't read jsCode/externs file content #66

DIYgod opened this issue Jun 7, 2017 · 3 comments
Assignees

Comments

@DIYgod
Copy link

DIYgod commented Jun 7, 2017

There is my configurations and files, the flag externs works in gulp-closure-compiler, but doesn't work in closure-compiler-js.

gulp configuration:

https://github.com/DIYgod/demo/blob/master/bad-closure-compiler-js/gulpfile.js

externs file

https://github.com/DIYgod/demo/blob/master/bad-closure-compiler-js/externs.js

...
var DIYgod;

source file:

var DIYgod = 'cat';
console.log(DIYgod);

gulp-closure-compiler output:

var DIYgod="cat";console.log(DIYgod);

closure-compiler-js output:

console.log("cat");

There is a minimal demo project of this problem, you can also try it yourself, thanks!

@samthor
Copy link
Contributor

samthor commented Jun 13, 2017

Thanks for the bugreport and repro case. I do appreciate that Java and JS should do the same thing. It looks like the Gulp and Webpack plugins actually never read the specified externs. For now, you should pass them in as part of the source (annotated with @externs, as you're doing).

However I believe you're relying on undefined behavior. When I change the warning level to DEFAULT or VERBOSE on either JS/Java, I get an error. The DIYgod variable is a const extern—we don't expect it to be declared in your code at all.

Read this for more information: https://developers.google.com/closure/compiler/docs/api-tutorial3#no

@samthor samthor changed the title Flag externs doesn't work Webpack and Gulp plugins don't read jsCode/externs file content Jun 13, 2017
@samthor samthor self-assigned this Jun 13, 2017
@sunzhuoshi
Copy link

sunzhuoshi commented Jun 25, 2017

@DIYgod
I came across the same issue, and I fixed it by reading extern files by myself before passing 'options' to compiler, as it does in cmd.js of closure compiler.
you can check my gist https://gist.github.com/sunzhuoshi/86f2d5a7f3330e227762b0909372ca60

@ChadKillingsworth
Copy link
Contributor

This is fixed in the main distribution. Please switch to using it insead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants