From 686abe4832d9c7b23a0ff758b90ad4cf17dd10a3 Mon Sep 17 00:00:00 2001 From: Raghu Simha Date: Mon, 5 Feb 2018 23:09:16 -0500 Subject: [PATCH] Make sure polyfills.js is imported before anything else (#13277) --- 3p/ampcontext-lib.js | 5 ++++- 3p/iframe-transport-client-lib.js | 5 ++++- 3p/integration.js | 4 +++- build-system/tasks/presubmit-checks.js | 1 + src/amp-shadow.js | 4 +++- src/amp.js | 4 +++- src/service.js | 5 +++-- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/3p/ampcontext-lib.js b/3p/ampcontext-lib.js index d1588c8bc01a..e1b63dfbb4ed 100644 --- a/3p/ampcontext-lib.js +++ b/3p/ampcontext-lib.js @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './polyfills'; + +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {AmpContext} from './ampcontext.js'; import {initLogConstructor, setReportError} from '../src/log'; diff --git a/3p/iframe-transport-client-lib.js b/3p/iframe-transport-client-lib.js index 504c072f2a0f..7a635e4a717b 100644 --- a/3p/iframe-transport-client-lib.js +++ b/3p/iframe-transport-client-lib.js @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './polyfills'; + +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {IframeTransportClient} from './iframe-transport-client.js'; import {initLogConstructor, setReportError} from '../src/log'; diff --git a/3p/integration.js b/3p/integration.js index 24788c29ed0e..e09338ecec91 100644 --- a/3p/integration.js +++ b/3p/integration.js @@ -22,7 +22,9 @@ * https://3p.ampproject.net/$version/f.js */ -import './polyfills'; +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {AmpEvents} from '../src/amp-events'; import { IntegrationAmpContext, diff --git a/build-system/tasks/presubmit-checks.js b/build-system/tasks/presubmit-checks.js index e71b8e94b305..ab756776f00d 100644 --- a/build-system/tasks/presubmit-checks.js +++ b/build-system/tasks/presubmit-checks.js @@ -622,6 +622,7 @@ const forbiddenTerms = { message: 'Use a line-level "no-unused-vars" rule instead.', whitelist: [ 'viewer-api/swipe-api.js', + 'dist.3p/current/integration.js', ], }, }; diff --git a/src/amp-shadow.js b/src/amp-shadow.js index 5434ea80fb16..1bb2fed1d77c 100644 --- a/src/amp-shadow.js +++ b/src/amp-shadow.js @@ -19,7 +19,9 @@ * multiple AMP Docs in Shadow DOM. */ -import './polyfills'; +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {Services} from './services'; import { adoptShadowMode, diff --git a/src/amp.js b/src/amp.js index 73de81e7e683..46e61dad2e66 100644 --- a/src/amp.js +++ b/src/amp.js @@ -18,7 +18,9 @@ * The entry point for AMP Runtime (v0.js) when AMP Runtime = AMP Doc. */ -import './polyfills'; +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {Services} from './services'; import {adopt, installAmpdocServices, installBuiltins, installRuntimeServices} from './runtime'; import {cssText} from '../build/css'; diff --git a/src/service.js b/src/service.js index ffd6f57805d7..a2ccd632277e 100644 --- a/src/service.js +++ b/src/service.js @@ -20,8 +20,9 @@ * Invariant: Service getters never return null for registered services. */ -// Requires polyfills in immediate side effect. -import './polyfills'; +// src/polyfills.js must be the first import. +import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6 + import {dev} from './log'; import {toWin} from './types';