fix: add regenerate-unicode-properties to dynamicRequireTargets (#12819)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Huáng Jùnliàng 2021-02-20 14:05:12 -05:00 committed by GitHub
parent 3af936fc2b
commit 72961e4564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -237,6 +237,19 @@ function buildBabel(exclude) {
.pipe(gulp.dest(base)); .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 // If this build is part of a pull request, include the pull request number in
// the version number. // the version number.
let versionSuffix = ""; let versionSuffix = "";
@ -292,6 +305,15 @@ function buildRollup(packages, targetBrowsers) {
"packages/babel-compat-data/*.js", "packages/babel-compat-data/*.js",
"packages/*/src/**/*.cjs", "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({ rollupBabel({
envName: babelEnvName, envName: babelEnvName,

View File

@ -217,6 +217,13 @@
}), }),
).not.toThrow(); ).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();
});
}); });
}, },
); );