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
Consider migration to goog.module #2647
Comments
We still use AngularJS, please note the workaround to support AngularJS. https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide#googmodule-causes-problems-with-angular-injected-classes
|
Excellent. Thanks for pointing that out! |
@IsaacSNK suggested in #4423 (comment):
and in #4423 (comment):
Also, in #4016, @dulmandakh started the migration process, but ran into issues. In #4423 (comment), I suggested:
Furthermore, there are unique scripts that might need adjustment or replacement as part of the transition, namely build/generateExterns.js and build/generateTsDefs.py. If this complicates the process too much, they could be temporarily disabled, but this would need to be dealt with before a merge into main. Okay, I think this consolidates everything into one place. |
Hi! Next week, I plan to work full time on this. I'll be posting ideas and questions. I'd really appreciate any feedback or advice you can provide me. Thanks! |
Sharing some ideas I have about this:
Thoughts? Other questions/comments related to option B:
|
@joeyparrish Gents did fairly well converting the code to Typescript. There are several things to fix from the code that it generated. @nana22 is helping me to see how much we can do this week. We are in a company-wide hackathon... A few things that need conversion (manual or automated) after running gents:
The generated code can be seen here: https://github.com/IsaacSNK/shaka-player alongside each JS file, there it's corresponding .ts file To automate some tasks, we are using the Typescript Compiler API from a tool we wrote. |
goog.asserts.assert is just like console.assert, except that the compiler uses it to enhance type info, and it's stripped in a production build. For example, if you assert that a nullable variable is not null at a given point, the compiler will let you pass it where a non-nullable is required. You can just port the one in lib/debug/asserts.js, which does nothing in production and calls console.assert in a debug build. |
Hey @joeyparrish we were wondering what is google.ima.AdsManager. We see it in Shaka's code but it is not declared in package.json or anywhere else. Could you provide some guidance for this one? |
It's an "extern", which is an external interface to another library. In this case, it's the Google IMA SDK. |
And how is that resolved during build time? |
Nevermind, I just found it |
Quick update on this: We were able to convert most of Shaka code to TS. We modified the Gents tool to adjust better to our goals. For many of the compilation errors, we created a tool to add //@ts-ignores. I think this is the best way to avoid lots of code changes, and once the conversion to TS is merged, we can remove //@ts-ignores with more care. The process we followed to migrate was:
We will be doing manual checks of other compilation errors and see if we should add ts-ignore for now. Work is far from over, but we plan to keep investing a few hours every week. I'll be posting more questions/updates as we move forward. To keep track of parallel changes happening on the Shaka repo, we have a tool that calculate a hash of each .js and generates a file. Whenever we sync with Shaka latest changes, it will be easy to tell which files changed and need synching. |
I do not agree to migrate to TypeScript. Shaka Player currently works on devices with very low features (for example some SmartTVs), if it is migrated to TypeScript there will be a considerable loss of performance, and we would have the same problems that we had when moving from 2.5 to 3.X and which still causes problems at #4062 |
@avelad there are many things we can tune during transpilation. Also, once we bundle and minify the code, other optimizations could be done. Your concerns are definitely valid, but I think once we have this work done, we can run performance tests and then decide. Honestly, for me and @nana22 even if this migration never sees the light due to concerns like yours, it will be valuable anyway due to the learning experience and familiarity we are gaining with Shaka. |
@joeyparrish Closure is being sunset in 5 months. Is this ticket still relevant? https://github.com/google/closure-library/blob/master/README.md @avelad What performance losses are you referring to in regards to a TypeScript conversion? |
@littlespex The only problem was on WebOS 3.X, but my tests were 3 years ago, the results may have changed. These devices are 7 years old or older, I think it's reasonable to evolve, so I agree to use TypeScript. |
Since our plan is to migrate to TypeScript, @joeyparrish, are you okay if we close this issue? |
goog.module may be an intermediate stage of the solution, but I don't know that we need a separate tracking bug for it. |
goog.module is now preferred by the compiler over goog.provide. According to internal advice I've just received, goog.module will allow the compiler to check dependencies better, among other things.
We should consider migrating, especially if it does not introduce any compatibility issues. This will probably involve changes to our extern generator.
https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide
The text was updated successfully, but these errors were encountered: