Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunks doesn't work with goog.requireType #9

Closed
koba04 opened this issue Mar 31, 2022 · 2 comments
Closed

chunks doesn't work with goog.requireType #9

koba04 opened this issue Mar 31, 2022 · 2 comments

Comments

@koba04
Copy link

koba04 commented Mar 31, 2022

This is transferred from google/closure-compiler#3931

Closure Compiler introduces closure-calculate-chunks as a tool to create an option to use chunks.

https://github.com/google/closure-compiler/wiki/Chunk-output-for-dynamic-loading#asking-closure-compiler-to-produce-chunks---the-easy-way

But it doesn't work well when we have a dependency referenced by goog.requireType because google-closure-deps doesn't list files referenced by goog.requireType as dependencies. closure-calculate-chunks accepts the deps.js generated by google-closure-deps so it means that closure-calculate-chunks cannot recognize the file because the file isn't in the deps.js.

  • myapp.js
goog.provide("myapp");

// mylib isn't listed as a dependency of `myapp.js`
goog.requireType("mylib");

myapp.foo = a => console.log(a);

// goog.addDependency('../../../../../src/myapp.js', ['myapp'], [], {'lang': 'es6'});

I think this is caused by the following problems

  • google-closure-deps doesn't list files referenced by goog.requireType (this is not a problem of Closure Compiler itself)
  • There is no way to specify files only referenced by goog.requireType as inputs of chunks
    • We could pass the files as --js options unless the dependencies don't include any circular dependency.

If Closure Compiler won't support the case of a circular dependency caused by dependencies of goog.requireType, this seems to be solved only by fixing google-closure-deps.

@ChadKillingsworth
Copy link
Owner

We should be able to fix this without changes to the deps file. It will just requiring parsing and traversing the AST for every closure-library file because we can't depend on the deps.js file to correctly list the inputs. It's not a big change, but it will likely be a hit to the speed of the tool.

@ChadKillingsworth
Copy link
Owner

The code to detect an add goog.requireType calls is currently present. I'll need a minimal reproduction case to debug this further.

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

No branches or pull requests

2 participants