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] 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({