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

Roll forward CC upgrade with fixes (#18552) #18609

Merged
merged 10 commits into from
Oct 10, 2018

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented Oct 8, 2018

See #18552.

New changes:

  • Remove node_modules/ path from js_module_root option. It caused silent bundling failure with imports leaving undefined Closure module path vars e.g. module$path$to$foo.
  • Document method for removing missing type paths in swg.js.
  • Fix react-dates issue [1] by injecting it post-compile instead of a JS import in amp-date-picker.js and removed obsolete "erwinmHack" export hack. :)
  • Fix a couple new type errors in amp-date-picker.js.

[1] CC v20171112 appears to DCE some of browserify's module loading boilerplate in third_party/react-dates/bundle.js. Specifically:

"moment": [function(require, module, exports) {
    //! moment.js
    (function(global, factory) {
        // This outer ternary is DCE'd by CC v20171112, but not in v20170409.
        typeof exports === 'object' && typeof module !== 'undefined' 
            ? module.exports = factory() 
            : typeof define === 'function' && define.amd 
                ? define(factory) 
                : global.moment = factory()
    }(this, (function() {
        'use strict'; ...

// checkVars: Demote "variable foo is undeclared" errors.
// moduleLoad: Demote "module not found" errors to ignore missing files
// in type declarations in the swg.js bundle.
jscomp_warning: ['checkVars', 'moduleLoad'],
Copy link
Member

@erwinmombay erwinmombay Oct 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we need this for both compile and check-type tasks? was wondering if we could make it conditional

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be consistent between both?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@choumx ideally. i just remembered the scenario you ran into originally with multi-pass, where the compilation worked but check-types failed. was that more an inconsistency with another option?

Copy link
Contributor

@kristoferbaxter kristoferbaxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments that likely are worth addressing in a followup.

The only item with a slightly higher concern is transpiling node_modules, but the number of items AMP uses from node_modules is small.

@dreamofabear
Copy link
Author

Thanks for the reviews!

@dreamofabear
Copy link
Author

Looks like the upgrade increased bundle size. :(

81.55KB -> 82.1KB

The original PR might not have exhibited this due to the node_modules/ bundling issue.

const newSource = [
wrapperOpen, reactDates, file.substr(firstLineBreak + 1),
].join('\n');
fs.writeFileSync(destFilePath, newSource, 'utf8');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwinmombay @cvializ FYI this is how I'm solving it for multi-pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@choumx did this actually work for single pass? i dont think single pass reaches this code path from the testing ive been doing on master. just double checking

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it. This technique is certainly part of the solution for single-pass. We still need to either (1) add externs or (2) change all invocations into react, moment, etc. in AMP code to either use bracket notation.

@dreamofabear
Copy link
Author

Tested the normal push build steps locally (full compile and test etc.) and everything looks good after some final fixes. Merging! 🤞

@dreamofabear dreamofabear merged commit ad9c05e into ampproject:master Oct 10, 2018
@dreamofabear dreamofabear deleted the cc-upgrade-remix branch October 10, 2018 04:06
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Oct 18, 2018
* Revert "Revert CC upgrade. (ampproject#18600)"

This reverts commit 6fd3044.

* Remove node_modules/ from js_module_root.

* Fix swg.js again.

* Increase bundle size cap to 82.2.

* Inject react-dates bundle post-compile instead of importing in code.

* Typecast react-dates imports in amp-date-picker.

* Bump bundle-size.

* Restore --js_module_root for 1-pass.

* Remove obsolete 'erwinmHack'.
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Revert "Revert CC upgrade. (ampproject#18600)"

This reverts commit 6fd3044.

* Remove node_modules/ from js_module_root.

* Fix swg.js again.

* Increase bundle size cap to 82.2.

* Inject react-dates bundle post-compile instead of importing in code.

* Typecast react-dates imports in amp-date-picker.

* Bump bundle-size.

* Restore --js_module_root for 1-pass.

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

Successfully merging this pull request may close these issues.

4 participants