From 6f2dd166cd1c2ac47f92ef0d56356ca381534000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 18 Feb 2021 12:08:39 -0500 Subject: [PATCH 1/4] fix: add regenerate-unicode-properties to dynamicRequireTargets --- Gulpfile.mjs | 4 ++++ packages/babel-standalone/test/babel.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index 8cddaf0f479a..bdae41565d42 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -292,6 +292,10 @@ function buildRollup(packages, targetBrowsers) { "packages/babel-compat-data/*.js", "packages/*/src/**/*.cjs", ], + dynamicRequireTargets: [ + // https://github.com/mathiasbynens/regexpu-core/blob/ffd8fff2e31f4597f6fdfee75d5ac1c5c8111ec3/rewrite-pattern.js#L48 + "node_modules/regenerate-unicode-properties/**", + ], }), rollupBabel({ envName: babelEnvName, diff --git a/packages/babel-standalone/test/babel.js b/packages/babel-standalone/test/babel.js index 1afeb7baabf3..3858571e3963 100644 --- a/packages/babel-standalone/test/babel.js +++ b/packages/babel-standalone/test/babel.js @@ -217,6 +217,13 @@ }), ).not.toThrow(); }); + it("#12815 - unicode property letter short alias should be transformed", () => { + expect(() => + Babel.transform("/\\p{L}/u", { + plugins: ["proposal-unicode-property-regex"], + }), + ).not.toThrow(); + }); }); }, ); From 5f8a3a035dc8c3dfabd10f960e0e6df0485f106c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 18 Feb 2021 14:15:00 -0500 Subject: [PATCH 2/4] use resolveChain instead of hardcoding n_m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Nicolò Ribaudo --- Gulpfile.mjs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index bdae41565d42..dfcaf5b7cd60 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -237,6 +237,18 @@ function buildBabel(exclude) { .pipe(gulp.dest(base)); } +/** + * Resolve a nested dependency starting from the given file + */ +export default function resolveChain(baseUrl, ...packages) { + const require = createRequire(baseUrl); + + return packages.reduce( + (base, pkg) => require.resolve(pkg, { paths: [path.dirname(base)] }), + fileURLToPath(baseUrl) + ); +} + // If this build is part of a pull request, include the pull request number in // the version number. let versionSuffix = ""; @@ -294,7 +306,12 @@ function buildRollup(packages, targetBrowsers) { ], dynamicRequireTargets: [ // https://github.com/mathiasbynens/regexpu-core/blob/ffd8fff2e31f4597f6fdfee75d5ac1c5c8111ec3/rewrite-pattern.js#L48 - "node_modules/regenerate-unicode-properties/**", + resolveChain( + import.meta.url, + "./packages/babel-helper-create-regexp-features-plugin", + "regexpu-core", + "regenerate-unicode-properties/package.json" + ) + "/../**", ], }), rollupBabel({ From c63db140197120b210fabd1c1d56d3c0e6738e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 18 Feb 2021 14:22:17 -0500 Subject: [PATCH 3/4] Build-rollup should not depend on build-babel --- Gulpfile.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index dfcaf5b7cd60..8492e6166da5 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -244,7 +244,8 @@ export default function resolveChain(baseUrl, ...packages) { const require = createRequire(baseUrl); return packages.reduce( - (base, pkg) => require.resolve(pkg, { paths: [path.dirname(base)] }), + (base, pkg) => + require.resolve(pkg + "/package.json", { paths: [path.dirname(base)] }), fileURLToPath(baseUrl) ); } @@ -310,7 +311,7 @@ function buildRollup(packages, targetBrowsers) { import.meta.url, "./packages/babel-helper-create-regexp-features-plugin", "regexpu-core", - "regenerate-unicode-properties/package.json" + "regenerate-unicode-properties" ) + "/../**", ], }), From eb907f02ee3a8d8ba5293f82c0030c8cc16b9110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 19 Feb 2021 14:01:45 -0500 Subject: [PATCH 4/4] Update Gulpfile.mjs --- Gulpfile.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index 8492e6166da5..152ac8017ec6 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -240,7 +240,7 @@ function buildBabel(exclude) { /** * Resolve a nested dependency starting from the given file */ -export default function resolveChain(baseUrl, ...packages) { +function resolveChain(baseUrl, ...packages) { const require = createRequire(baseUrl); return packages.reduce(