Skip to content

Commit

Permalink
remove IS_AMP_ALT (#31493)
Browse files Browse the repository at this point in the history
* remove IS_AMP_ALT

This flag was only needed for single pass which is abandoned

* remove rule from rc file
  • Loading branch information
erwinmombay committed Feb 26, 2021
1 parent 0fd955b commit b194ebb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 108 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Expand Up @@ -147,7 +147,6 @@ module.exports = {
'local/no-import-meta': 2,
'local/no-import-rename': 2,
'local/no-invalid-this': 2,
'local/no-is-amp-alt': 2,
'local/no-log-array': 2,
'local/no-mixed-interpolation': 2,
'local/no-mixed-operators': 2,
Expand Down
28 changes: 0 additions & 28 deletions build-system/eslint-rules/no-is-amp-alt.js

This file was deleted.

3 changes: 0 additions & 3 deletions build-system/externs/amp.extern.js
Expand Up @@ -154,9 +154,6 @@ var process = {};
process.env;
process.env.NODE_ENV;

/** @type {boolean|undefined} */
window.IS_AMP_ALT;

// Exposed to ads.
// Preserve these filedNames so they can be accessed by 3p code.
window.context = {};
Expand Down
139 changes: 63 additions & 76 deletions src/amp.js
Expand Up @@ -52,15 +52,6 @@ import {preconnectToOrigin} from './preconnect';
import {startupChunk} from './chunk';
import {stubElementsForDoc} from './service/custom-element-registry';

/**
* self.IS_AMP_ALT (is AMP alternative binary) is undefined by default in the
* main v0.js since it is the "main" js.
* This global boolean is set by alternative binaries like amp-inabox and
* amp-shadow which has their own bootstrapping sequence.
* @type {boolean|undefined}
*/
const shouldMainBootstrapRun = !self.IS_AMP_ALT;

/**
* Execute the bootstrap
* @param {!./service/ampdoc-impl.AmpDoc} ampdoc
Expand Down Expand Up @@ -109,77 +100,73 @@ function bootstrap(ampdoc, perf) {
});
}

if (shouldMainBootstrapRun) {
// Store the originalHash as early as possible. Trying to debug:
// https://github.com/ampproject/amphtml/issues/6070
if (self.location) {
self.location.originalHash = self.location.hash;
}
// Store the originalHash as early as possible. Trying to debug:
// https://github.com/ampproject/amphtml/issues/6070
if (self.location) {
self.location.originalHash = self.location.hash;
}

/** @type {!./service/ampdoc-impl.AmpDocService} */
let ampdocService;
// We must under all circumstances call makeBodyVisible.
// It is much better to have AMP tags not rendered than having
// a completely blank page.
try {
// Should happen first.
installErrorReporting(self); // Also calls makeBodyVisibleRecovery on errors.
/** @type {!./service/ampdoc-impl.AmpDocService} */
let ampdocService;
// We must under all circumstances call makeBodyVisible.
// It is much better to have AMP tags not rendered than having
// a completely blank page.
try {
// Should happen first.
installErrorReporting(self); // Also calls makeBodyVisibleRecovery on errors.

// Declare that this runtime will support a single root doc. Should happen
// as early as possible.
installDocService(self, /* isSingleDoc */ true);
ampdocService = Services.ampdocServiceFor(self);
} catch (e) {
// In case of an error call this.
makeBodyVisibleRecovery(self.document);
throw e;
// Declare that this runtime will support a single root doc. Should happen
// as early as possible.
installDocService(self, /* isSingleDoc */ true);
ampdocService = Services.ampdocServiceFor(self);
} catch (e) {
// In case of an error call this.
makeBodyVisibleRecovery(self.document);
throw e;
}
startupChunk(self.document, function initial() {
/** @const {!./service/ampdoc-impl.AmpDoc} */
const ampdoc = ampdocService.getAmpDoc(self.document);
installPlatformService(self);
installPerformanceService(self);
/** @const {!./service/performance-impl.Performance} */
const perf = Services.performanceFor(self);
if (self.document.documentElement.hasAttribute('i-amphtml-no-boilerplate')) {
perf.addEnabledExperiment('no-boilerplate');
}
startupChunk(self.document, function initial() {
/** @const {!./service/ampdoc-impl.AmpDoc} */
const ampdoc = ampdocService.getAmpDoc(self.document);
installPlatformService(self);
installPerformanceService(self);
/** @const {!./service/performance-impl.Performance} */
const perf = Services.performanceFor(self);
if (
self.document.documentElement.hasAttribute('i-amphtml-no-boilerplate')
) {
perf.addEnabledExperiment('no-boilerplate');
}
if (IS_ESM) {
perf.addEnabledExperiment('esm');
}
fontStylesheetTimeout(self);
perf.tick(TickLabel.INSTALL_STYLES);
if (IS_ESM) {
bootstrap(ampdoc, perf);
} else {
installStylesForDoc(
ampdoc,
ampDocCss + ampSharedCss,
() => bootstrap(ampdoc, perf),
/* opt_isRuntimeCss */ true,
/* opt_ext */ 'amp-runtime'
);
}
});

// Output a message to the console and add an attribute to the <html>
// tag to give some information that can be used in error reports.
// (At least by sophisticated users).
if (self.console) {
(console.info || console.log).call(
console,
`Powered by AMP ⚡ HTML – Version ${internalRuntimeVersion()}`,
self.location.href
);
if (IS_ESM) {
perf.addEnabledExperiment('esm');
}
// This code is eleminated in prod build through a babel transformer.
if (getMode().localDev) {
self.document.documentElement.setAttribute('esm', IS_ESM ? 1 : 0);
fontStylesheetTimeout(self);
perf.tick(TickLabel.INSTALL_STYLES);
if (IS_ESM) {
bootstrap(ampdoc, perf);
} else {
installStylesForDoc(
ampdoc,
ampDocCss + ampSharedCss,
() => bootstrap(ampdoc, perf),
/* opt_isRuntimeCss */ true,
/* opt_ext */ 'amp-runtime'
);
}
self.document.documentElement.setAttribute(
'amp-version',
internalRuntimeVersion()
});

// Output a message to the console and add an attribute to the <html>
// tag to give some information that can be used in error reports.
// (At least by sophisticated users).
if (self.console) {
(console.info || console.log).call(
console,
`Powered by AMP ⚡ HTML – Version ${internalRuntimeVersion()}`,
self.location.href
);
}
// This code is eleminated in prod build through a babel transformer.
if (getMode().localDev) {
self.document.documentElement.setAttribute('esm', IS_ESM ? 1 : 0);
}
self.document.documentElement.setAttribute(
'amp-version',
internalRuntimeVersion()
);

0 comments on commit b194ebb

Please sign in to comment.