Skip to content

♻️ Condense polyfills and lock down imports#34151

Merged
rcebulko merged 8 commits intoampproject:mainfrom
rcebulko:polfill-types
May 3, 2021
Merged

♻️ Condense polyfills and lock down imports#34151
rcebulko merged 8 commits intoampproject:mainfrom
rcebulko:polfill-types

Conversation

@rcebulko
Copy link
Copy Markdown
Contributor

Moves all polyfills into src/polyfills and adds a lint rule preventing imports outside of polyfills/core. In preparation for enabling/passing typechecking on src/polyfills

@rcebulko rcebulko requested a review from samouri April 30, 2021 19:33
// Some deferred polyfills.
scheduleInObUpgradeIfNeeded(global);
scheduleResObUpgradeIfNeeded(global);
const extensionsFor = Services.extensionsFor(global);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clever way to avoid Services for now ⭐

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah! I figure this barely is owned by polyfills themselves, and this is literally the only place those methods were used, so it seemed like an efficient way to untangle some AMP dependencies

@amp-owners-bot
Copy link
Copy Markdown

Hey @rsimha! These files were changed:

build-system/compile/compile.js

Copy link
Copy Markdown
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

Build changes 👍

*/

/** @fileoverview */
/** @fileoverview Installs polyfills depending on build environment. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like there are ~300 comments that read // src/polyfills.js must be the first import., that could do with an update. They mostly live in 3p code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep I've seen em all. I plan to update all of those in a separate PR so Justin or Kris can rubber-stamp without needing to look

@rcebulko rcebulko force-pushed the polfill-types branch 2 times, most recently from f673c0a to 1ae540e Compare April 30, 2021 21:15
@rcebulko rcebulko merged commit 6a9ada0 into ampproject:main May 3, 2021
@rcebulko rcebulko deleted the polfill-types branch May 3, 2021 18:11
rochapablo pushed a commit to rochapablo/amphtml that referenced this pull request Aug 30, 2021
* Remove src/polyfills dependency on Services

* Move get-bounding-client-rect polyfill into polyfills

* Move src/polyfills.js to src/polyfills/index.js

* Update dep-check config

* Lock down imports within src/polyfills

* Update references to polyfills.js

* Update stragglers

* Fix forbidden terms exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking issue for general code modernization efforts I2I: Restoring AMP’s Type Checking

5 participants