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 #3931

Closed
koba04 opened this issue Mar 28, 2022 · 5 comments
Closed

chunks doesn't work with goog.requireType #3931

koba04 opened this issue Mar 28, 2022 · 5 comments

Comments

@koba04
Copy link

koba04 commented Mar 28, 2022

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.

@frost-cy
Copy link

@ChadKillingsworth Do you know anything about this?
Should I move it to closure-calculate-chunks ?

@ChadKillingsworth
Copy link
Collaborator

We can definitely solve it in closure-calculate-chunks. I need to get up to speed on the future of deps files in general.

@blickly
Copy link
Contributor

blickly commented Mar 30, 2022

I thought there was a way to "transfer" an issue from one repository to another, but I wasn't able to get it to work. @koba04, could you refile this in https://github.com/ChadKillingsworth/closure-calculate-chunks/issues which is I think the right repo to track it in?

@blickly blickly closed this as completed Mar 30, 2022
@blickly blickly reopened this Mar 30, 2022
@ChadKillingsworth
Copy link
Collaborator

We can't transfer the issue because the destination is in a different GitHub org.

@koba04
Copy link
Author

koba04 commented Mar 31, 2022

@blickly @ChadKillingsworth Thank you, I'll close this and create a new one in closure-calculate-chunks.

I guess this would have to involve multiple repositories.

  • Adding goog.requireType support in google-closure-deps (google/closure-library)
  • Adding goog.requireType support as a new command-line option in google-closure-compiler (google/closure-compiler)
  • Parsing deps.js including goog.requireType support and generating a result to pass it to google-closure-compiler (ChadKillingsworth/closure-calculate-chunks)

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

4 participants