-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
third_party/
code must not be treated as closure code
#21828
Comments
/cc @erwinmombay @dvoytenko @choumx @cramforce for visibility and for ideas. |
|
@cramforce yes, |
I'd just keep the number of chars the same for source maps :)
…On Thu, Apr 11, 2019 at 1:57 PM Dima Voytenko ***@***.***> wrote:
@cramforce <https://github.com/cramforce> yes, /** -> /* removes the
problem.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21828 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAV4TZAJ6MLENWJTDAOYJ3PP6QZZANCNFSM4HFLHCDA>
.
|
I hit this during the last CC upgrade, which started failing on missing type paths. So this might've been an issue even before Raghu's PR. If this regex is still being used, we should just update it to catch this instance. amphtml/third_party/subscriptions-project/README.amp Lines 8 to 10 in 71339c2
Add a
|
In #21830, I tried what at first seemed like an elegant solution to replace
I'll pick this up tomorrow. I'm still in search of a good way to replace the contents of source files before passing them to closure compiler. (I believe multi-pass |
@rsimha , you might need to write the swg files into build folder (transformed), and change the paths. this trick might not work for singlepass though, ill check |
I think @jridgewell has looked into modifying source files pre-compile to fix source maps due to version string replacement and license minification, though IIRC there isn't a good way yet. |
Yah, I looked into the source code of the Switching to Closure's official gulp plugin might work. It looks like they take the modifications buffer and apply it before running the compiler. |
Crap, it seems like there's no way to get closure's official gulp plugin to use our custom /cc @erwinmombay |
should be possible, see https://github.com/ampproject/amphtml/blob/master/build-system/single-pass.js#L61 |
Update: A mechanism for removing JSDoc from third party code is now available in #21878. We now need a strategy for fixing type errors in extensions code that uses third party code. See #21878 (comment) |
(I work on JS within Google and have investigated this problem in depth; Googlers can read go/tpl-js .) In general you cannot compile arbitrary third-party JS in Closure because the code may use patterns that the optimizer eats. If you are ok with this and only care about errors, I believe the Using |
@evmar thanks a lot! @rsimha Do you recollect what were the kind of errors we saw with @evmar Generally, our goals are:
|
@dvoytenko I tried @evmar's suggestion and added
The latest code is available at #21878. |
@rsimha what happens if we keep the annotations and set the |
See item 2 in #21828 (comment). |
@rsimha , yes, but i was wondering if you had the log from before. There are no longer errors because we compensated on the SwG's side by changing it at the source. In other words, it's likely to happen again. |
The only logs I have are at #21878 (comment), but I'm not sure if that's what you're looking for. Maybe you can roll back |
After discussing offline with @dvoytenko, there's no pressing need to do something as drastic as removing all type annotations from Part of the reason behind this discussion was #21827 (review), which turned out to be a red herring due to an unnecessary global find-replace I did while upgrading closure compiler. For now, we are fine with unknown types in amphtml/build-system/compile/compile.js Lines 92 to 95 in 2b9201c
This issue can be closed until we face other problems due to types in third party code. |
AMP components like
extensions/amp-subscriptions/
include third party code that is checked in to our repo underthird_party/
. When we run the type checker viagulp check-types
or minify code viagulp dist
, closure compiler treats the code inthird_party/
as if it were closure code.third_party/
may interfere with compilation optimizations around inlining, devirtualization, minification, etc.@dvoytenko recently discovered this due to following events:
v20190301
(✨🏗 Upgrade closure compiler to v20190301 #21618)goog.requireType
or TSimport type
google/closure-compiler#3041)third_party/subscriptions-project/swg.js
contains such an annotationTo fix this, we must no longer treat code in
third_party/
as closure code.This issue is meant to discuss and track a fix.
The text was updated successfully, but these errors were encountered: