/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/build/src/tools/esbuild/server-bundle-metadata-plugin.ts
36 строк
1 KB
Alan Agius
docs: replace `@note` with `@remarks`
05 ноя 2024, 17:00
05 ноя 2024, 17:00
daea0ab
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import type { Plugin } from 'esbuild'; /** * Generates an esbuild plugin that appends metadata to the output bundle, * marking it with server-side rendering (SSR) details for Angular SSR scenarios. * * @param options Optional configuration object. * - `ssrEntryBundle`: If `true`, marks the bundle as an SSR entry point. * * @remarks We can't rely on `platform: node` or `platform: neutral`, as the latter * is used for non-SSR-related code too (e.g., global scripts). * @returns An esbuild plugin that injects SSR metadata into the build result's metafile. */ export function createServerBundleMetadata(options?: { ssrEntryBundle?: boolean }): Plugin { return { name: 'angular-server-bundle-metadata', setup(build) { build.onEnd((result) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const metafile = result.metafile as any; if (metafile) { metafile['ng-ssr-entry-bundle'] = !!options?.ssrEntryBundle; metafile['ng-platform-server'] = true; } }); }, }; }