From 72961e45642f55e686c99091d8a6e7fbd0da2d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Sat, 20 Feb 2021 14:05:12 -0500 Subject: [PATCH] fix: add regenerate-unicode-properties to dynamicRequireTargets (#12819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nicolò Ribaudo --- Gulpfile.mjs | 22 ++++++++++++++++++++++ packages/babel-standalone/test/babel.js | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index 8cddaf0f479a..152ac8017ec6 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -237,6 +237,19 @@ function buildBabel(exclude) { .pipe(gulp.dest(base)); } +/** + * Resolve a nested dependency starting from the given file + */ +function resolveChain(baseUrl, ...packages) { + const require = createRequire(baseUrl); + + return packages.reduce( + (base, pkg) => + require.resolve(pkg + "/package.json", { 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 = ""; @@ -292,6 +305,15 @@ 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 + resolveChain( + import.meta.url, + "./packages/babel-helper-create-regexp-features-plugin", + "regexpu-core", + "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(); + }); }); }, );