From 9062ea942bde6788f352f87ecdec60d48dc5b62c Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Mon, 13 Jun 2022 15:49:29 -0700 Subject: [PATCH] [dev-tool] also check for rollup warning match using "/" (#22222) Check for rollup warning match using "/". It turns out that even on Windows, the rollup warnings still uses "/", not `path.sep` --- .../dev-tool/src/config/rollup.base.config.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/tools/dev-tool/src/config/rollup.base.config.ts b/common/tools/dev-tool/src/config/rollup.base.config.ts index e57ca695cc89..4ddf5347e875 100644 --- a/common/tools/dev-tool/src/config/rollup.base.config.ts +++ b/common/tools/dev-tool/src/config/rollup.base.config.ts @@ -68,33 +68,37 @@ export function sourcemapsExtra() { */ export type WarningInhibitor = (warning: RollupWarning) => boolean; +function matchesPathSegments(str: string | undefined, segments: string[]): boolean { + // Reported warnings use "/" + return str?.includes(segments.join("/")) ?? false; +} + function ignoreNiseSinonEval(warning: RollupWarning): boolean { return ( warning.code === "EVAL" && - (warning.id?.includes(["node_modules", "nise"].join(path.sep)) || - warning.id?.includes(["node_modules", "sinon"].join(path.sep))) === true + (matchesPathSegments(warning.id, ["node_modules", "nise"]) || + matchesPathSegments(warning.id, ["node_modules", "sinon"])) ); } function ignoreChaiCircularDependency(warning: RollupWarning): boolean { return ( warning.code === "CIRCULAR_DEPENDENCY" && - warning.importer?.includes(["node_modules", "chai"].join(path.sep)) === true + matchesPathSegments(warning.importer, ["node_modules", "chai"]) ); } - function ignoreRheaPromiseCircularDependency(warning: RollupWarning): boolean { return ( warning.code === "CIRCULAR_DEPENDENCY" && - warning.importer?.includes(["node_modules", "rhea-promise"].join(path.sep)) === true + matchesPathSegments(warning.importer, ["node_modules", "rhea-promise"]) ); } function ignoreOpenTelemetryThisIsUndefined(warning: RollupWarning): boolean { return ( warning.code === "THIS_IS_UNDEFINED" && - warning.id?.includes(["node_modules", "@opentelemetry", "api"].join(path.sep)) === true + matchesPathSegments(warning.id, ["node_modules", "@opentelemetry", "api"]) ); }