Skip to content

Commit

Permalink
wp-babel-makepot: Use @babel/preset-env for default preset (#87258)
Browse files Browse the repository at this point in the history
* wp-babel-makepot: Use @babel/preset-env for default preset
  • Loading branch information
yuliyan authored Feb 12, 2024
1 parent 2bd4d44 commit c5ce8d7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/wp-babel-makepot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 1.2.0

- Add `@babel/preset-env` to the default preset.
- Remove deprecated `@babel/plugin-proposal-class-properties` plugin from the default preset.
3 changes: 1 addition & 2 deletions packages/wp-babel-makepot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/wp-babel-makepot",
"version": "1.1.1",
"version": "1.2.0",
"description": "A utility for extracting translatable strings from JavaScript source.",
"bugs": "https://github.com/Automattic/wp-calypso/issues",
"homepage": "https://github.com/Automattic/wp-calypso",
Expand Down Expand Up @@ -28,7 +28,6 @@
"@automattic/babel-plugin-i18n-calypso": "workspace:^",
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-react": "^7.23.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/wp-babel-makepot/presets/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: [ '@babel/preset-react', '@babel/preset-typescript' ],
plugins: [ '@babel/plugin-proposal-class-properties' ],
presets: [ '@babel/preset-react', '@babel/preset-typescript', '@babel/preset-env' ],
plugins: [],
};
34 changes: 28 additions & 6 deletions packages/wp-babel-makepot/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ exports[`makePot concatenated pot should match its snapshot 1`] = `
msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
#: test/examples/private-fields.js:2
msgid \\"Private property\\"
msgstr \\"\\"
#: test/examples/private-fields.js:4
msgid \\"Private method\\"
msgstr \\"\\"
#: test/examples/react-1.jsx:10
#: test/examples/react-2.jsx:5
msgid \\"Prop string\\"
Expand Down Expand Up @@ -110,6 +118,7 @@ msgstr[1] \\"\\"

exports[`makePot pot files should match their snapshots 1`] = `
Array [
"output/test-examples-private-fields.js.pot",
"output/test-examples-react-1.jsx.pot",
"output/test-examples-react-2.jsx.pot",
"output/test-examples-translate-1.js.pot",
Expand All @@ -124,6 +133,19 @@ exports[`makePot pot files should match their snapshots 2`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
#: test/examples/private-fields.js:2
msgid \\"Private property\\"
msgstr \\"\\"
#: test/examples/private-fields.js:4
msgid \\"Private method\\"
msgstr \\"\\""
`;

exports[`makePot pot files should match their snapshots 3`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
#: test/examples/react-1.jsx:10
msgid \\"Prop string\\"
msgstr \\"\\"
Expand All @@ -137,7 +159,7 @@ msgstr[0] \\"\\"
msgstr[1] \\"\\""
`;

exports[`makePot pot files should match their snapshots 3`] = `
exports[`makePot pot files should match their snapshots 4`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand All @@ -154,7 +176,7 @@ msgstr[0] \\"\\"
msgstr[1] \\"\\""
`;

exports[`makePot pot files should match their snapshots 4`] = `
exports[`makePot pot files should match their snapshots 5`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand Down Expand Up @@ -185,7 +207,7 @@ msgstr[0] \\"\\"
msgstr[1] \\"\\""
`;

exports[`makePot pot files should match their snapshots 5`] = `
exports[`makePot pot files should match their snapshots 6`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand Down Expand Up @@ -215,7 +237,7 @@ msgstr[0] \\"\\"
msgstr[1] \\"\\""
`;

exports[`makePot pot files should match their snapshots 6`] = `
exports[`makePot pot files should match their snapshots 7`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand All @@ -224,7 +246,7 @@ msgid \\"Decorator Preset\\"
msgstr \\"\\""
`;

exports[`makePot pot files should match their snapshots 7`] = `
exports[`makePot pot files should match their snapshots 8`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand All @@ -233,7 +255,7 @@ msgid \\"Typescript react component string\\"
msgstr \\"\\""
`;

exports[`makePot pot files should match their snapshots 8`] = `
exports[`makePot pot files should match their snapshots 9`] = `
"msgid \\"\\"
msgstr \\"Content-Type: text/plain; charset=utf-8\\\\n\\"
Expand Down
6 changes: 6 additions & 0 deletions packages/wp-babel-makepot/test/examples/private-fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class TestClass {
#prop = translate( 'Private property' );
#method() {
return translate( 'Private method' );
}
}
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,6 @@ __metadata:
"@automattic/calypso-typescript-config": "workspace:^"
"@babel/cli": "npm:^7.23.4"
"@babel/core": "npm:^7.23.7"
"@babel/plugin-proposal-class-properties": "npm:^7.18.6"
"@babel/plugin-proposal-decorators": "npm:^7.23.7"
"@babel/preset-env": "npm:^7.23.8"
"@babel/preset-react": "npm:^7.23.3"
Expand Down

0 comments on commit c5ce8d7

Please sign in to comment.