Skip to content

Commit

Permalink
Minify-replace does not work when the vars are declared.
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Jul 8, 2021
1 parent 98f3ac2 commit 0bdfafc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ module.exports = {
...getExperimentGlobals(),
'IS_ESM': 'readonly',
'IS_SXG': 'readonly',
'IS_MINIFIED': 'readonly',
'IS_FORTESTING': 'readonly',
'AMP': 'readonly',
'context': 'readonly',
'global': 'readonly',
Expand Down
2 changes: 0 additions & 2 deletions build-system/test-configs/forbidden-terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ const forbiddenTermsGlobal = {
},
'(?:var|let|const) +IS_FORTESTING +=': {
message: 'IS_FORTESTING local var only allowed in mode.js.',
allowlist: ['src/core/mode/for-testing.js'],
},
'(?:var|let|const) +IS_MINIFIED +=': {
message: 'IS_MINIFIED local var only allowed in core/mode/minified.js',
allowlist: ['src/core/mode/minified.js'],
},
'\\.prefetch\\(': {
message: 'Do not use preconnect.prefetch, use preconnect.preload instead.',
Expand Down
11 changes: 4 additions & 7 deletions src/core/mode/for-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
* limitations under the License.
*/

// Magic constant that is replaced by babel.
// IS_FORTESTING is only replaced when `amp dist` is called without the
// --fortesting flag.
const IS_FORTESTING = true;

/**
* Returns true whenever closure compiler is used with --fortesting. Calls are
* DCE'd when compiled.
* Returns true whenever --fortesting is used.
* This is a magic constant replaced by babel.
*
* Calls are DCE'd when compiled.
* @return {boolean}
*/
export function isFortesting() {
Expand Down
6 changes: 2 additions & 4 deletions src/core/mode/minified.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* limitations under the License.
*/

// Magic constant that is replaced by babel.
// IS_MINIFIED is always replaced with true when closure compiler is used
const IS_MINIFIED = false;

/**
* Returns true whenever closure compiler is used.
* This is a magic constant that is replaced by babel.
*
* @return {boolean}
*/
export function isMinified() {
Expand Down

0 comments on commit 0bdfafc

Please sign in to comment.