Skip to content

Commit

Permalink
[dev-tool] also check for rollup warning match using "/" (Azure#22222)
Browse files Browse the repository at this point in the history
Check for rollup warning match using "/". It turns out that even on Windows, the rollup warnings still uses "/", not `path.sep`
  • Loading branch information
jeremymeng authored Jun 13, 2022
1 parent fb4c695 commit 9062ea9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions common/tools/dev-tool/src/config/rollup.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
);
}

Expand Down

0 comments on commit 9062ea9

Please sign in to comment.