Skip to content

Commit

Permalink
fix: add regenerate-unicode-properties to dynamicRequireTargets (#12819)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
JLHwung and nicolo-ribaudo committed Feb 20, 2021
1 parent 3af936f commit 72961e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Gulpfile.mjs
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions packages/babel-standalone/test/babel.js
Expand Up @@ -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();
});
});
},
);

0 comments on commit 72961e4

Please sign in to comment.