Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Change const to let VariableDeclarations for ESM Output #26727

Merged
merged 20 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cfc797f
Move from media 'not-blocking' to 'print'
kristoferbaxter Jun 24, 2019
7c9902e
latest master
kristoferbaxter Jul 16, 2019
e1eb02c
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Aug 6, 2019
3a5465a
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Aug 15, 2019
870b22f
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Aug 16, 2019
e81a2d1
font stylesheet changes
kristoferbaxter Aug 16, 2019
e073300
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Aug 21, 2019
03935f4
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Sep 17, 2019
1c78f0d
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Sep 25, 2019
ce266db
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Sep 27, 2019
2073a5b
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Oct 2, 2019
78062ac
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Oct 16, 2019
09127e7
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Nov 26, 2019
a24ae5c
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Nov 27, 2019
9a10297
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Nov 27, 2019
100832e
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Jan 31, 2020
420e0e6
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Feb 4, 2020
97c2032
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Feb 10, 2020
e03d86f
Merge branch 'master' of github.com:ampproject/amphtml
kristoferbaxter Feb 11, 2020
3102f39
Babel plugin for const -> let
kristoferbaxter Feb 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions build-system/babel-plugins/babel-plugin-const-transformer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2020 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
* The above said variables are in src/mode.js file.
* @param {Object} babelTypes
* @return {!Object}
*/
module.exports = function({types: t}) {
return {
visitor: {
VariableDeclaration(path) {
if (path.node.kind !== 'const') {
return;
}

path.replaceWith(t.variableDeclaration('let', path.node.declarations));
},
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright 2020 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.
*/

let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];

function thing() {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}

thing: {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["../../../../../babel-plugin-const-transformer"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2020 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.
*/
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];

function thing() {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}

thing: {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright 2020 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.
*/

var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];

function thing() {
var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];
}

thing: {
var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["../../../../../babel-plugin-const-transformer"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2020 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.
*/
var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];

function thing() {
var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];
}

thing: {
var foo = true;
var bar = 1;
var baz = NaN;
var yep = 'hello';
var another = {};
var array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright 2020 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 foo = true;
const bar = 1;
const baz = NaN;
const yep = 'hello';
const another = {};
const array = [];

function thing() {
const foo = true;
const bar = 1;
const baz = NaN;
const yep = 'hello';
const another = {};
const array = [];
}

thing: {
const foo = true;
const bar = 1;
const baz = NaN;
const yep = 'hello';
const another = {};
const array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["../../../../../babel-plugin-const-transformer"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2020 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.
*/
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];

function thing() {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}

thing: {
let foo = true;
let bar = 1;
let baz = NaN;
let yep = 'hello';
let another = {};
let array = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2020 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);