Skip to content

Commit

Permalink
Merge pull request #1115 from angular/main
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Aug 20, 2024
2 parents 05300c4 + 212034b commit c17a1d4
Show file tree
Hide file tree
Showing 8 changed files with 500 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: 'Upload to code-scanning'
uses: github/codeql-action/upload-sarif@29d86d22a34ea372b1bbf3b2dced2e25ca6b3384 # v3.26.1
uses: github/codeql-action/upload-sarif@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
with:
sarif_file: results.sarif
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ yarn_install(

http_archive(
name = "aspect_bazel_lib",
sha256 = "c780120ab99a4ca9daac69911eb06434b297214743ee7e0a1f1298353ef686db",
strip_prefix = "bazel-lib-2.7.9",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.9/bazel-lib-v2.7.9.tar.gz",
sha256 = "cea19e6d8322fb212f155acb58d1590f632e53abde7f1be5f0a086a93cf4c9f4",
strip_prefix = "bazel-lib-2.8.0",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.8.0/bazel-lib-v2.8.0.tar.gz",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
"critters": "0.0.24",
"css-loader": "7.1.2",
"debug": "^4.1.1",
"esbuild": "0.23.0",
"esbuild-wasm": "0.23.0",
"esbuild": "0.23.1",
"esbuild-wasm": "0.23.1",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-header": "3.1.1",
Expand Down Expand Up @@ -181,7 +181,7 @@
"puppeteer": "18.2.1",
"quicktype-core": "23.0.170",
"resolve-url-loader": "5.0.0",
"rollup": "4.20.0",
"rollup": "4.21.0",
"rollup-plugin-sourcemaps": "^0.6.0",
"rxjs": "7.8.1",
"sass": "1.77.8",
Expand All @@ -201,7 +201,7 @@
"undici": "6.19.7",
"verdaccio": "5.32.1",
"verdaccio-auth-memory": "^10.0.0",
"vite": "5.4.0",
"vite": "5.4.1",
"watchpack": "2.4.2",
"webpack": "5.93.0",
"webpack-dev-middleware": "7.3.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@vitejs/plugin-basic-ssl": "1.1.0",
"browserslist": "^4.23.0",
"critters": "0.0.24",
"esbuild": "0.23.0",
"esbuild": "0.23.1",
"fast-glob": "3.3.2",
"https-proxy-agent": "7.0.5",
"listr2": "8.2.4",
Expand All @@ -38,10 +38,10 @@
"parse5-html-rewriting-stream": "7.0.0",
"picomatch": "4.0.2",
"piscina": "4.6.1",
"rollup": "4.20.0",
"rollup": "4.21.0",
"sass": "1.77.8",
"semver": "7.6.3",
"vite": "5.4.0",
"vite": "5.4.1",
"watchpack": "2.4.2"
},
"peerDependencies": {
Expand Down
57 changes: 37 additions & 20 deletions packages/angular/build/src/utils/server-rendering/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ export async function prerenderPages(
}

// Get routes to prerender
const { routes: allRoutes, warnings: routesWarnings } = await getAllRoutes(
const {
routes: allRoutes,
warnings: routesWarnings,
errors: routesErrors,
} = await getAllRoutes(
workspaceRoot,
outputFilesForWorker,
assetsReversed,
Expand All @@ -92,11 +96,15 @@ export async function prerenderPages(
verbose,
);

if (routesErrors?.length) {
errors.push(...routesErrors);
}

if (routesWarnings?.length) {
warnings.push(...routesWarnings);
}

if (allRoutes.size < 1) {
if (allRoutes.size < 1 || errors.length > 0) {
return {
errors,
warnings,
Expand Down Expand Up @@ -190,22 +198,27 @@ async function renderPages(
const isAppShellRoute = appShellRoute === route;
const serverContext: ServerContext = isAppShellRoute ? 'app-shell' : 'ssg';
const render: Promise<RenderResult> = renderWorker.run({ route, serverContext });
const renderResult: Promise<void> = render.then(({ content, warnings, errors }) => {
if (content !== undefined) {
const outPath = isAppShellRoute
? 'index.html'
: posix.join(removeLeadingSlash(route), 'index.html');
output[outPath] = content;
}

if (warnings) {
warnings.push(...warnings);
}

if (errors) {
errors.push(...errors);
}
});
const renderResult: Promise<void> = render
.then(({ content, warnings, errors }) => {
if (content !== undefined) {
const outPath = isAppShellRoute
? 'index.html'
: posix.join(removeLeadingSlash(route), 'index.html');
output[outPath] = content;
}

if (warnings) {
warnings.push(...warnings);
}

if (errors) {
errors.push(...errors);
}
})
.catch((err) => {
errors.push(`An error occurred while prerendering route '${route}'.\n\n${err.stack}`);
void renderWorker.destroy();
});

renderingPromises.push(renderResult);
}
Expand All @@ -231,7 +244,7 @@ async function getAllRoutes(
prerenderOptions: PrerenderOptions,
sourcemap: boolean,
verbose: boolean,
): Promise<{ routes: Set<string>; warnings?: string[] }> {
): Promise<{ routes: Set<string>; warnings?: string[]; errors?: string[] }> {
const { routesFile, discoverRoutes } = prerenderOptions;
const routes = new RoutesSet();
const { route: appShellRoute } = appShellOptions;
Expand Down Expand Up @@ -275,8 +288,12 @@ async function getAllRoutes(
recordTiming: false,
});

const errors: string[] = [];
const { routes: extractedRoutes, warnings }: RoutersExtractorWorkerResult = await renderWorker
.run({})
.catch((err) => {
errors.push(`An error occurred while extracting routes.\n\n${err.stack}`);
})
.finally(() => {
void renderWorker.destroy();
});
Expand All @@ -285,7 +302,7 @@ async function getAllRoutes(
routes.add(route);
}

return { routes, warnings };
return { routes, warnings, errors };
}

function addLeadingSlash(value: string): string {
Expand Down
6 changes: 3 additions & 3 deletions packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"copy-webpack-plugin": "12.0.2",
"critters": "0.0.24",
"css-loader": "7.1.2",
"esbuild-wasm": "0.23.0",
"esbuild-wasm": "0.23.1",
"fast-glob": "3.3.2",
"http-proxy-middleware": "3.0.0",
"https-proxy-agent": "7.0.5",
Expand Down Expand Up @@ -61,7 +61,7 @@
"terser": "5.31.6",
"tree-kill": "1.2.2",
"tslib": "2.6.3",
"vite": "5.4.0",
"vite": "5.4.1",
"watchpack": "2.4.2",
"webpack": "5.93.0",
"webpack-dev-middleware": "7.3.0",
Expand All @@ -70,7 +70,7 @@
"webpack-subresource-integrity": "5.1.0"
},
"optionalDependencies": {
"esbuild": "0.23.0"
"esbuild": "0.23.1"
},
"devDependencies": {
"undici": "6.19.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ describeBuilder(execute, SERVER_BUILDER_INFO, (harness) => {
it('emits errors', async () => {
harness.useTarget('server', {
...BASE_OPTIONS,
watch: true,
});

// Generate an error
await harness.appendToFile('src/main.server.ts', `const foo: = 'abc';`);

const { result, logs } = await harness.executeOnce();
const { result, logs } = await harness.executeOnce({
outputLogsOnFailure: false,
});

expect(result?.success).toBeFalse();
expect(logs).toContain(
Expand Down
Loading

0 comments on commit c17a1d4

Please sign in to comment.