Skip to content

Commit a8dba52

Browse files
authored
fix: support Angular CLI 21.2.x findUpSync rename (#571)
In Angular CLI 21.2, the synchronous findUp utility was renamed to findUpSync, making the old findUp async. Importing findUp statically then passing its return value (now a Promise) as a file path caused: "The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Promise." Replace the static import with a runtime require that prefers findUpSync (21.2+) and falls back to findUp (≤21.1), keeping compatibility across both CLI ranges without breaking existing behaviour.
1 parent f6338cb commit a8dba52

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • libs/single-spa-community-angular/webpack

libs/single-spa-community-angular/webpack/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as fs from 'fs';
2-
import { findUp } from '@angular/cli/src/utilities/find-up';
2+
3+
// Angular CLI 21.2+ renamed the sync variant to `findUpSync`; ≤21.1 only exports `findUp` (sync).
4+
// We load both at runtime and prefer `findUpSync` so the code works across both ranges.
5+
// eslint-disable-next-line @typescript-eslint/no-var-requires
6+
const { findUpSync: _findUpSync, findUp: _findUp } = require('@angular/cli/src/utilities/find-up');
7+
const findUp: (names: string | string[], from: string) => string | null = _findUpSync ?? _findUp;
38

49
import { externals } from './externals';
510
import { removeMiniCssExtractRules } from './webpack-5/remove-mini-css-extract';

0 commit comments

Comments
 (0)