From 5d918a26b99ee5b1e3588939944a95717777c605 Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Wed, 5 Dec 2018 12:44:35 -0800 Subject: [PATCH 1/9] adding babel plugin for const transformation --- .../index.js | 43 +++++++++++++++++++ build-system/build.conf.js | 11 ++++- build-system/single-pass.js | 8 ++-- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js new file mode 100644 index 000000000000..31dab1febfc4 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js @@ -0,0 +1,43 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * Changes the values of IS_DEV to false and IS_MINIFIED to true. + * The above said variables are in src/mode.js file. + */ +module.exports = function({types: t}) { + return { + visitor: { + VariableDeclarator(path) { + let {node} = path; + const {id, init} = node; + if (id.name == "IS_DEV" + && init.type === "BooleanLiteral" + && init.value === true) { + init.value = !t.booleanLiteral(true); + return; + } + if (id.name == "IS_MINIFIED" + && init.type === "BooleanLiteral" + && init.value === false) { + init.value = t.booleanLiteral(true); + return; + } + return; + } + } + } +} \ No newline at end of file diff --git a/build-system/build.conf.js b/build-system/build.conf.js index 41d34a56486d..de4d94d4c3b2 100644 --- a/build-system/build.conf.js +++ b/build-system/build.conf.js @@ -22,7 +22,11 @@ const defaultPlugins = [ ]; module.exports = { - plugins: (isEsmBuild, isCommonJsModule) => { + plugins: ({ + isEsmBuild, + isCommonJsModule, + isForTesting, + }) => { let pluginsToApply = defaultPlugins; if (isEsmBuild) { pluginsToApply = pluginsToApply.concat([ @@ -44,6 +48,11 @@ module.exports = { [require.resolve('babel-plugin-transform-commonjs-es2015-modules')], ]); } + if (isForTesting) { + pluginsToApply = pluginsToApply.concat([ + [require.resolve('./babel-plugins/babel-plugin-amp-constant-transformer')], + ]); + } return pluginsToApply; }, }; diff --git a/build-system/single-pass.js b/build-system/single-pass.js index c7ef763fbd81..8c463d232204 100644 --- a/build-system/single-pass.js +++ b/build-system/single-pass.js @@ -431,9 +431,11 @@ function transformPathsToTempDir(graph, config) { fs.copySync(f, `${graph.tmp}/${f}`); } else { const {code} = babel.transformFileSync(f, { - plugins: conf.plugins( - /* isEsmBuild */ config.define.indexOf['ESM_BUILD=true'] !== -1, - /* isCommonJsModule */ isCommonJsModule(f)), + plugins: conf.plugins({ + isEsmBuild: config.define.indexOf('ESM_BUILD=true') !== -1, + isCommonJsModule: isCommonJsModule(f), + isForTesting: config.define.indexOf('FORTESTING=true') !== -1, + }), retainLines: true, }); fs.outputFileSync(`${graph.tmp}/${f}`, code); From 094f8bd77f645cab80e2cb0d873a034725010dbd Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 10:26:52 -0800 Subject: [PATCH 2/9] adding test for transformer --- .../both-transform/input.js | 2 ++ .../both-transform/options.json | 3 +++ .../both-transform/output.js | 2 ++ .../isdev-transform/input.js | 2 ++ .../isdev-transform/options.json | 3 +++ .../isdev-transform/output.js | 2 ++ .../isminified-transform/input.js | 2 ++ .../isminified-transform/options.json | 3 +++ .../isminified-transform/output.js | 2 ++ .../no-transform/input.js | 2 ++ .../no-transform/options.json | 3 +++ .../no-transform/output.js | 2 ++ .../test/index.js | 19 +++++++++++++++++++ 13 files changed, 47 insertions(+) create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js create mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js new file mode 100644 index 000000000000..71c3f0ad2fbc --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js @@ -0,0 +1,2 @@ +const IS_DEV = true; +const IS_MINIFIED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json new file mode 100644 index 000000000000..6c8aee41734e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js new file mode 100644 index 000000000000..0519b60d982c --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js @@ -0,0 +1,2 @@ +const IS_DEV = false; +const IS_MINIFIED = true; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js new file mode 100644 index 000000000000..747e8b39ef39 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js @@ -0,0 +1,2 @@ +const IS_DEV = true; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json new file mode 100644 index 000000000000..6c8aee41734e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js new file mode 100644 index 000000000000..35c0dbfdfbd8 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js @@ -0,0 +1,2 @@ +const IS_DEV = false; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js new file mode 100644 index 000000000000..2e960f84eb57 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_MINIFIED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json new file mode 100644 index 000000000000..6c8aee41734e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js new file mode 100644 index 000000000000..4791faa5209e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_MINIFIED = true; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js new file mode 100644 index 000000000000..6ea990e9cfb7 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json new file mode 100644 index 000000000000..6c8aee41734e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js new file mode 100644 index 000000000000..6ea990e9cfb7 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js new file mode 100644 index 000000000000..ca0145cf873b --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js @@ -0,0 +1,19 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const runner = require('@babel/helper-plugin-test-runner').default; + +runner(__dirname); \ No newline at end of file From cca061768acc149314ae56509dd17f3e0314332d Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 11:03:55 -0800 Subject: [PATCH 3/9] fixing the is fortesting condition --- build-system/build.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/build.conf.js b/build-system/build.conf.js index de4d94d4c3b2..871e9906694c 100644 --- a/build-system/build.conf.js +++ b/build-system/build.conf.js @@ -48,7 +48,7 @@ module.exports = { [require.resolve('babel-plugin-transform-commonjs-es2015-modules')], ]); } - if (isForTesting) { + if (!isForTesting) { pluginsToApply = pluginsToApply.concat([ [require.resolve('./babel-plugins/babel-plugin-amp-constant-transformer')], ]); From 387cd22b9c1e0601b6f7801c3369b9743d3cf26f Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 11:07:48 -0800 Subject: [PATCH 4/9] fixing lints --- .../index.js | 20 +++++++++---------- .../test/index.js | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js index 31dab1febfc4..565ce18c5662 100644 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js @@ -14,7 +14,7 @@ * limitations under the License. */ - /** +/** * Changes the values of IS_DEV to false and IS_MINIFIED to true. * The above said variables are in src/mode.js file. */ @@ -22,22 +22,22 @@ module.exports = function({types: t}) { return { visitor: { VariableDeclarator(path) { - let {node} = path; + const {node} = path; const {id, init} = node; - if (id.name == "IS_DEV" - && init.type === "BooleanLiteral" + if (id.name == 'IS_DEV' + && init.type === 'BooleanLiteral' && init.value === true) { init.value = !t.booleanLiteral(true); return; } - if (id.name == "IS_MINIFIED" - && init.type === "BooleanLiteral" + if (id.name == 'IS_MINIFIED' + && init.type === 'BooleanLiteral' && init.value === false) { init.value = t.booleanLiteral(true); return; } return; - } - } - } -} \ No newline at end of file + }, + }, + }; +}; diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js index ca0145cf873b..7b6d7376a749 100644 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js @@ -16,4 +16,4 @@ const runner = require('@babel/helper-plugin-test-runner').default; -runner(__dirname); \ No newline at end of file +runner(__dirname); From 2b4c0e9314a44c53de55ced6e8d702da4f7c7f79 Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 11:23:59 -0800 Subject: [PATCH 5/9] fixing lints --- .../babel-plugin-amp-constant-transformer/index.js | 4 +++- build-system/build.conf.js | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js index 565ce18c5662..5c8381ea7b2c 100644 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js @@ -17,8 +17,10 @@ /** * Changes the values of IS_DEV to false and IS_MINIFIED to true. * The above said variables are in src/mode.js file. + * @param {Object} babelTypes */ -module.exports = function({types: t}) { +module.exports = function(babelTypes) { + const {types: t} = babelTypes; return { visitor: { VariableDeclarator(path) { diff --git a/build-system/build.conf.js b/build-system/build.conf.js index 871e9906694c..e0659727e6dc 100644 --- a/build-system/build.conf.js +++ b/build-system/build.conf.js @@ -50,7 +50,11 @@ module.exports = { } if (!isForTesting) { pluginsToApply = pluginsToApply.concat([ - [require.resolve('./babel-plugins/babel-plugin-amp-constant-transformer')], + [ + require.resolve( + './babel-plugins/babel-plugin-amp-constant-transformer' + ), + ], ]); } return pluginsToApply; From 159fbc27f974ccebb682adbdebaff9ce9cccb8b0 Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 11:36:05 -0800 Subject: [PATCH 6/9] fixing `is_minified` always true condition --- .../both-transform/input.js | 2 - .../both-transform/options.json | 3 -- .../both-transform/output.js | 2 - .../isdev-transform/options.json | 3 -- .../isminified-transform/options.json | 3 -- .../no-transform/options.json | 3 -- .../index.js | 39 +++++++++++++++++++ .../isdev-transform/input.js | 0 .../isdev-transform/options.json | 3 ++ .../isdev-transform/output.js | 0 .../no-transform/input.js | 0 .../no-transform/options.json | 3 ++ .../no-transform/output.js | 0 .../test/index.js | 0 .../index.js | 6 --- .../isminified-transform/input.js | 0 .../isminified-transform/options.json | 3 ++ .../isminified-transform/output.js | 0 .../no-transform/input.js | 2 + .../no-transform/options.json | 3 ++ .../no-transform/output.js | 2 + .../test/index.js | 19 +++++++++ build-system/build.conf.js | 4 +- 23 files changed, 77 insertions(+), 23 deletions(-) delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json delete mode 100644 build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_dev-constant-transformer}/test/fixtures/transform-assertions/isdev-transform/input.js (100%) create mode 100644 build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_dev-constant-transformer}/test/fixtures/transform-assertions/isdev-transform/output.js (100%) rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_dev-constant-transformer}/test/fixtures/transform-assertions/no-transform/input.js (100%) create mode 100644 build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_dev-constant-transformer}/test/fixtures/transform-assertions/no-transform/output.js (100%) rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_dev-constant-transformer}/test/index.js (100%) rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_minified-constant-transformer}/index.js (86%) rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_minified-constant-transformer}/test/fixtures/transform-assertions/isminified-transform/input.js (100%) create mode 100644 build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json rename build-system/babel-plugins/{babel-plugin-amp-constant-transformer => babel-plugin-is_minified-constant-transformer}/test/fixtures/transform-assertions/isminified-transform/output.js (100%) create mode 100644 build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js create mode 100644 build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json create mode 100644 build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js create mode 100644 build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/index.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js deleted file mode 100644 index 71c3f0ad2fbc..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/input.js +++ /dev/null @@ -1,2 +0,0 @@ -const IS_DEV = true; -const IS_MINIFIED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json deleted file mode 100644 index 6c8aee41734e..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] -} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js deleted file mode 100644 index 0519b60d982c..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/both-transform/output.js +++ /dev/null @@ -1,2 +0,0 @@ -const IS_DEV = false; -const IS_MINIFIED = true; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json deleted file mode 100644 index 6c8aee41734e..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] -} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json deleted file mode 100644 index 6c8aee41734e..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] -} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json b/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json deleted file mode 100644 index 6c8aee41734e..000000000000 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["../../../../../babel-plugin-amp-constant-transformer"] -} diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js new file mode 100644 index 000000000000..f4d3f3865d90 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js @@ -0,0 +1,39 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Changes the values of IS_DEV to false and IS_MINIFIED to true. + * The above said variables are in src/mode.js file. + * @param {Object} babelTypes + */ +module.exports = function(babelTypes) { + const {types: t} = babelTypes; + return { + visitor: { + VariableDeclarator(path) { + const {node} = path; + const {id, init} = node; + if (id.name == 'IS_DEV' + && init.type === 'BooleanLiteral' + && init.value === true) { + init.value = !t.booleanLiteral(true); + return; + } + return; + }, + }, + }; +}; diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js rename to build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json new file mode 100644 index 000000000000..13f0fa59df0e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-is_dev-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js rename to build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js rename to build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json new file mode 100644 index 000000000000..13f0fa59df0e --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-is_dev-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js rename to build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/index.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/index.js rename to build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/index.js diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js similarity index 86% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js rename to build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js index 5c8381ea7b2c..0f2f5ba98511 100644 --- a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js @@ -26,12 +26,6 @@ module.exports = function(babelTypes) { VariableDeclarator(path) { const {node} = path; const {id, init} = node; - if (id.name == 'IS_DEV' - && init.type === 'BooleanLiteral' - && init.value === true) { - init.value = !t.booleanLiteral(true); - return; - } if (id.name == 'IS_MINIFIED' && init.type === 'BooleanLiteral' && init.value === false) { diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js rename to build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json new file mode 100644 index 000000000000..be67ebac87b6 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-is_minified-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js similarity index 100% rename from build-system/babel-plugins/babel-plugin-amp-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js rename to build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js new file mode 100644 index 000000000000..6ea990e9cfb7 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json new file mode 100644 index 000000000000..be67ebac87b6 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["../../../../../babel-plugin-is_minified-constant-transformer"] +} diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js new file mode 100644 index 000000000000..6ea990e9cfb7 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js @@ -0,0 +1,2 @@ +const IS_DEVELOPMENT = false; +const IS_EXPANDED = false; \ No newline at end of file diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/index.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/index.js new file mode 100644 index 000000000000..7b6d7376a749 --- /dev/null +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/index.js @@ -0,0 +1,19 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const runner = require('@babel/helper-plugin-test-runner').default; + +runner(__dirname); diff --git a/build-system/build.conf.js b/build-system/build.conf.js index e0659727e6dc..01d74c213cc8 100644 --- a/build-system/build.conf.js +++ b/build-system/build.conf.js @@ -19,6 +19,8 @@ const defaultPlugins = [ './babel-plugins/babel-plugin-transform-amp-asserts'), require.resolve( './babel-plugins/babel-plugin-transform-parenthesize-expression'), + require.resolve( + './babel-plugins/babel-plugin-is_minified-constant-transformer'), ]; module.exports = { @@ -52,7 +54,7 @@ module.exports = { pluginsToApply = pluginsToApply.concat([ [ require.resolve( - './babel-plugins/babel-plugin-amp-constant-transformer' + './babel-plugins/babel-plugin-is_dev-constant-transformer' ), ], ]); From ca3db0dba12d71c7e6e5a07993db6ef3767b7464 Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 6 Dec 2018 16:03:40 -0800 Subject: [PATCH 7/9] lint fixes --- .../index.js | 17 +++++++++-------- .../index.js | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js index f4d3f3865d90..4d790a86874c 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js @@ -24,15 +24,16 @@ module.exports = function(babelTypes) { return { visitor: { VariableDeclarator(path) { - const {node} = path; - const {id, init} = node; - if (id.name == 'IS_DEV' - && init.type === 'BooleanLiteral' - && init.value === true) { - init.value = !t.booleanLiteral(true); - return; + const {id, init} = path.node; + if (t.isIdentifier(id, {name: 'IS_DEV'}) + && t.isBooleanLiteral(init, {value: true})) { + path.replaceWith( + t.variableDeclarator( + t.identifier('IS_DEV'), + t.booleanLiteral(false) + ) + ); } - return; }, }, }; diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js index 0f2f5ba98511..3d9f8daa5157 100644 --- a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/index.js @@ -24,15 +24,16 @@ module.exports = function(babelTypes) { return { visitor: { VariableDeclarator(path) { - const {node} = path; - const {id, init} = node; - if (id.name == 'IS_MINIFIED' - && init.type === 'BooleanLiteral' - && init.value === false) { - init.value = t.booleanLiteral(true); - return; + const {id, init} = path.node; + if (t.isIdentifier(id, {name: 'IS_MINIFIED'}) + && t.isBooleanLiteral(init, {value: false})) { + path.replaceWith( + t.variableDeclarator( + t.identifier('IS_MINIFIED'), + t.booleanLiteral(true) + ) + ); } - return; }, }, }; From b3798044473837f122b342edf95b8d5f66cabb2d Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Tue, 11 Dec 2018 20:18:15 -0800 Subject: [PATCH 8/9] fixing babel transformer --- .../index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js index 4d790a86874c..c27d1c33feeb 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/index.js @@ -19,20 +19,15 @@ * The above said variables are in src/mode.js file. * @param {Object} babelTypes */ -module.exports = function(babelTypes) { - const {types: t} = babelTypes; +module.exports = function({types: t}) { return { visitor: { VariableDeclarator(path) { - const {id, init} = path.node; + const {node} = path; + const {id, init} = node; if (t.isIdentifier(id, {name: 'IS_DEV'}) && t.isBooleanLiteral(init, {value: true})) { - path.replaceWith( - t.variableDeclarator( - t.identifier('IS_DEV'), - t.booleanLiteral(false) - ) - ); + node.init = t.booleanLiteral(false); } }, }, From 4294b229e3047cd013555db616b3a0db999c036f Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Thu, 13 Dec 2018 18:53:52 -0800 Subject: [PATCH 9/9] fixes copyrights --- .../isdev-transform/input.js | 19 +++++++++++++++++- .../isdev-transform/output.js | 17 +++++++++++++++- .../no-transform/input.js | 20 ++++++++++++++++++- .../no-transform/output.js | 17 +++++++++++++++- .../isminified-transform/input.js | 19 +++++++++++++++++- .../isminified-transform/output.js | 17 +++++++++++++++- .../no-transform/input.js | 19 +++++++++++++++++- .../no-transform/output.js | 17 +++++++++++++++- 8 files changed, 137 insertions(+), 8 deletions(-) diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js index 747e8b39ef39..21f1ed57dc77 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/input.js @@ -1,2 +1,19 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + const IS_DEV = true; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js index 35c0dbfdfbd8..9319a005fcae 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/isdev-transform/output.js @@ -1,2 +1,17 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ const IS_DEV = false; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js index 6ea990e9cfb7..88371a1445c7 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js @@ -1,2 +1,20 @@ + +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + const IS_DEVELOPMENT = false; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js index 6ea990e9cfb7..bf4c3530b6af 100644 --- a/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js +++ b/build-system/babel-plugins/babel-plugin-is_dev-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js @@ -1,2 +1,17 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ const IS_DEVELOPMENT = false; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js index 2e960f84eb57..ff730f6e824f 100644 --- a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/input.js @@ -1,2 +1,19 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + const IS_DEVELOPMENT = false; -const IS_MINIFIED = false; \ No newline at end of file +const IS_MINIFIED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js index 4791faa5209e..7ac0ff36819f 100644 --- a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/isminified-transform/output.js @@ -1,2 +1,17 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ const IS_DEVELOPMENT = false; -const IS_MINIFIED = true; \ No newline at end of file +const IS_MINIFIED = true; diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js index 6ea990e9cfb7..b42410f328d2 100644 --- a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/input.js @@ -1,2 +1,19 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + const IS_DEVELOPMENT = false; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false; diff --git a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js index 6ea990e9cfb7..bf4c3530b6af 100644 --- a/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js +++ b/build-system/babel-plugins/babel-plugin-is_minified-constant-transformer/test/fixtures/transform-assertions/no-transform/output.js @@ -1,2 +1,17 @@ +/** + * Copyright 2018 The AMP HTML Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ const IS_DEVELOPMENT = false; -const IS_EXPANDED = false; \ No newline at end of file +const IS_EXPANDED = false;