From c5ce8d7e4fd946857d40e6ffd118f0e1b77a999f Mon Sep 17 00:00:00 2001 From: Yuliyan Slavchev Date: Mon, 12 Feb 2024 11:41:26 +0200 Subject: [PATCH] wp-babel-makepot: Use @babel/preset-env for default preset (#87258) * wp-babel-makepot: Use @babel/preset-env for default preset --- packages/wp-babel-makepot/CHANGELOG.md | 6 ++++ packages/wp-babel-makepot/package.json | 3 +- packages/wp-babel-makepot/presets/default.js | 4 +-- .../test/__snapshots__/index.js.snap | 34 +++++++++++++++---- .../test/examples/private-fields.js | 6 ++++ yarn.lock | 1 - 6 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 packages/wp-babel-makepot/CHANGELOG.md create mode 100644 packages/wp-babel-makepot/test/examples/private-fields.js diff --git a/packages/wp-babel-makepot/CHANGELOG.md b/packages/wp-babel-makepot/CHANGELOG.md new file mode 100644 index 00000000000000..719aff218811d9 --- /dev/null +++ b/packages/wp-babel-makepot/CHANGELOG.md @@ -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. diff --git a/packages/wp-babel-makepot/package.json b/packages/wp-babel-makepot/package.json index fde45498f434ab..a668cf66d5603c 100644 --- a/packages/wp-babel-makepot/package.json +++ b/packages/wp-babel-makepot/package.json @@ -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", @@ -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", diff --git a/packages/wp-babel-makepot/presets/default.js b/packages/wp-babel-makepot/presets/default.js index 26c407684c5af7..1cc995f1bb3151 100644 --- a/packages/wp-babel-makepot/presets/default.js +++ b/packages/wp-babel-makepot/presets/default.js @@ -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: [], }; diff --git a/packages/wp-babel-makepot/test/__snapshots__/index.js.snap b/packages/wp-babel-makepot/test/__snapshots__/index.js.snap index e1bb0fa60c8425..88dcb6e4118446 100644 --- a/packages/wp-babel-makepot/test/__snapshots__/index.js.snap +++ b/packages/wp-babel-makepot/test/__snapshots__/index.js.snap @@ -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\\" @@ -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", @@ -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 \\"\\" @@ -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\\" @@ -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\\" @@ -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\\" @@ -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\\" @@ -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\\" @@ -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\\" diff --git a/packages/wp-babel-makepot/test/examples/private-fields.js b/packages/wp-babel-makepot/test/examples/private-fields.js new file mode 100644 index 00000000000000..de8361dec9ba97 --- /dev/null +++ b/packages/wp-babel-makepot/test/examples/private-fields.js @@ -0,0 +1,6 @@ +class TestClass { + #prop = translate( 'Private property' ); + #method() { + return translate( 'Private method' ); + } +} diff --git a/yarn.lock b/yarn.lock index f0527f44f636e2..71a08ccc33b1e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"