Skip to content

Commit cf5b49e

Browse files
committed
fix(@angular-devkit/build-angular): fix app-shell route format and
improve package resolution - In the `app-shell` builder, ensure the route URL has a leading slash. - In webpack helpers, use `createRequire` in `isPackageInstalled` to improve package resolution robustness.
1 parent 9d0e656 commit cf5b49e

File tree

2 files changed

+5
-2
lines changed
  • packages/angular_devkit/build_angular/src

2 files changed

+5
-2
lines changed

packages/angular_devkit/build_angular/src/builders/app-shell/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ async function _renderUniversal(
8686
localeDirectory,
8787
);
8888

89+
const route = options.route;
8990
let html: string = await renderWorker.run({
9091
serverBundlePath,
9192
document: indexHtml,
92-
url: options.route,
93+
url: route?.[0] === '/' ? route : '/' + route,
9394
});
9495

9596
// Overwrite the client index file.

packages/angular_devkit/build_angular/src/tools/webpack/utils/helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import type { ObjectPattern } from 'copy-webpack-plugin';
1010
import { createHash } from 'node:crypto';
11+
import { createRequire } from 'node:module';
1112
import * as path from 'node:path';
1213
import { globSync } from 'tinyglobby';
1314
import type { Configuration, WebpackOptionsNormalized } from 'webpack';
@@ -314,7 +315,8 @@ export function getStatsOptions(verbose = false): WebpackStatsOptions {
314315
*/
315316
export function isPackageInstalled(root: string, name: string): boolean {
316317
try {
317-
require.resolve(name, { paths: [root] });
318+
const resolve = createRequire(root + '/').resolve;
319+
resolve(name);
318320

319321
return true;
320322
} catch {

0 commit comments

Comments
 (0)