Primeiro commit do projeto Angular
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010-2026 Google LLC. https://angular.dev/license
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
# Angular Build System for Applications and Libraries
|
||||
|
||||
The sources for this package are in the [Angular CLI](https://github.com/angular/angular-cli) repository. Please file issues and pull requests against that repository.
|
||||
|
||||
Usage information and reference details can be found in repository [README](https://github.com/angular/angular-cli/blob/main/README.md) file.
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"builders": {
|
||||
"application": {
|
||||
"implementation": "./src/builders/application/index",
|
||||
"schema": "./src/builders/application/schema.json",
|
||||
"description": "Build an application."
|
||||
},
|
||||
"dev-server": {
|
||||
"implementation": "./src/builders/dev-server/index",
|
||||
"schema": "./src/builders/dev-server/schema.json",
|
||||
"description": "Execute a development server for an application."
|
||||
},
|
||||
"extract-i18n": {
|
||||
"implementation": "./src/builders/extract-i18n/index",
|
||||
"schema": "./src/builders/extract-i18n/schema.json",
|
||||
"description": "Extract i18n messages from an application."
|
||||
},
|
||||
"karma": {
|
||||
"implementation": "./src/builders/karma",
|
||||
"schema": "./src/builders/karma/schema.json",
|
||||
"description": "Run Karma unit tests."
|
||||
},
|
||||
"ng-packagr": {
|
||||
"implementation": "./src/builders/ng-packagr/index",
|
||||
"schema": "./src/builders/ng-packagr/schema.json",
|
||||
"description": "Build a library with ng-packagr."
|
||||
},
|
||||
"unit-test": {
|
||||
"implementation": "./src/builders/unit-test",
|
||||
"schema": "./src/builders/unit-test/schema.json",
|
||||
"description": "[EXPERIMENTAL] Run application unit tests."
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
export * from './src/index';
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./src/index"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,8CAA4B"}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"name": "@angular/build",
|
||||
"version": "21.2.1",
|
||||
"description": "Official build system for Angular",
|
||||
"keywords": [
|
||||
"Angular CLI",
|
||||
"Angular DevKit",
|
||||
"angular",
|
||||
"angular-cli",
|
||||
"devkit",
|
||||
"sdk"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.d.ts",
|
||||
"default": "./src/index.js"
|
||||
},
|
||||
"./private": {
|
||||
"default": "./src/private.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"builders": "builders.json",
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "2.3.0",
|
||||
"@angular-devkit/architect": "0.2102.1",
|
||||
"@babel/core": "7.29.0",
|
||||
"@babel/helper-annotate-as-pure": "7.27.3",
|
||||
"@babel/helper-split-export-declaration": "7.24.7",
|
||||
"@inquirer/confirm": "5.1.21",
|
||||
"@vitejs/plugin-basic-ssl": "2.1.4",
|
||||
"beasties": "0.4.1",
|
||||
"browserslist": "^4.26.0",
|
||||
"esbuild": "0.27.3",
|
||||
"https-proxy-agent": "7.0.6",
|
||||
"istanbul-lib-instrument": "6.0.3",
|
||||
"jsonc-parser": "3.3.1",
|
||||
"listr2": "9.0.5",
|
||||
"magic-string": "0.30.21",
|
||||
"mrmime": "2.0.1",
|
||||
"parse5-html-rewriting-stream": "8.0.0",
|
||||
"picomatch": "4.0.3",
|
||||
"piscina": "5.1.4",
|
||||
"rolldown": "1.0.0-rc.4",
|
||||
"sass": "1.97.3",
|
||||
"semver": "7.7.4",
|
||||
"source-map-support": "0.5.21",
|
||||
"tinyglobby": "0.2.15",
|
||||
"undici": "7.22.0",
|
||||
"vite": "7.3.1",
|
||||
"watchpack": "2.5.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"lmdb": "3.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/compiler": "^21.0.0",
|
||||
"@angular/compiler-cli": "^21.0.0",
|
||||
"@angular/core": "^21.0.0",
|
||||
"@angular/localize": "^21.0.0",
|
||||
"@angular/platform-browser": "^21.0.0",
|
||||
"@angular/platform-server": "^21.0.0",
|
||||
"@angular/service-worker": "^21.0.0",
|
||||
"@angular/ssr": "^21.2.1",
|
||||
"karma": "^6.4.0",
|
||||
"less": "^4.2.0",
|
||||
"ng-packagr": "^21.0.0",
|
||||
"postcss": "^8.4.0",
|
||||
"tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
||||
"tslib": "^2.3.0",
|
||||
"typescript": ">=5.9 <6.0",
|
||||
"vitest": "^4.0.8"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@angular/core": {
|
||||
"optional": true
|
||||
},
|
||||
"@angular/localize": {
|
||||
"optional": true
|
||||
},
|
||||
"@angular/platform-browser": {
|
||||
"optional": true
|
||||
},
|
||||
"@angular/platform-server": {
|
||||
"optional": true
|
||||
},
|
||||
"@angular/service-worker": {
|
||||
"optional": true
|
||||
},
|
||||
"@angular/ssr": {
|
||||
"optional": true
|
||||
},
|
||||
"karma": {
|
||||
"optional": true
|
||||
},
|
||||
"less": {
|
||||
"optional": true
|
||||
},
|
||||
"ng-packagr": {
|
||||
"optional": true
|
||||
},
|
||||
"postcss": {
|
||||
"optional": true
|
||||
},
|
||||
"tailwindcss": {
|
||||
"optional": true
|
||||
},
|
||||
"vitest": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/angular-cli.git"
|
||||
},
|
||||
"packageManager": "pnpm@10.30.3",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
||||
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
|
||||
"yarn": ">= 1.13.0"
|
||||
},
|
||||
"author": "Angular Authors",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/angular/angular-cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/angular/angular-cli"
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
export * from '../src/private';
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("../src/private"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,iDAA+B"}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
||||
import { NormalizedCachedOptions } from '../../utils/normalize-cache';
|
||||
import { NormalizedOutputOptions } from './options';
|
||||
import { Result } from './results';
|
||||
export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildState) => Promise<ExecutionResult>, options: {
|
||||
workspaceRoot: string;
|
||||
projectRoot: string;
|
||||
outputOptions: NormalizedOutputOptions;
|
||||
logger: BuilderContext['logger'];
|
||||
cacheOptions: NormalizedCachedOptions;
|
||||
watch?: boolean;
|
||||
verbose?: boolean;
|
||||
progress?: boolean;
|
||||
poll?: number;
|
||||
signal?: AbortSignal;
|
||||
preserveSymlinks?: boolean;
|
||||
clearScreen?: boolean;
|
||||
colors?: boolean;
|
||||
jsonLogs?: boolean;
|
||||
incrementalResults?: boolean;
|
||||
}): AsyncIterable<Result>;
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runEsBuildBuildAction = runEsBuildBuildAction;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const path_1 = require("../../utils/path");
|
||||
const results_1 = require("./results");
|
||||
// Watch workspace for package manager changes
|
||||
const packageWatchFiles = [
|
||||
// manifest can affect module resolution
|
||||
'package.json',
|
||||
// npm lock file
|
||||
'package-lock.json',
|
||||
// pnpm lock file
|
||||
'pnpm-lock.yaml',
|
||||
// yarn lock file including Yarn PnP manifest files (https://yarnpkg.com/advanced/pnp-spec/)
|
||||
'yarn.lock',
|
||||
'.pnp.cjs',
|
||||
'.pnp.data.json',
|
||||
];
|
||||
async function* runEsBuildBuildAction(action, options) {
|
||||
const { watch, poll, clearScreen, logger, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, colors, jsonLogs, incrementalResults, } = options;
|
||||
const withProgress = progress ? utils_1.withSpinner : utils_1.withNoProgress;
|
||||
// Initial build
|
||||
let result;
|
||||
try {
|
||||
// Perform the build action
|
||||
result = await withProgress('Building...', () => action());
|
||||
// Log all diagnostic (error/warning/logs) messages
|
||||
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
||||
}
|
||||
finally {
|
||||
// Ensure Sass workers are shutdown if not watching
|
||||
if (!watch) {
|
||||
(0, sass_language_1.shutdownSassWorkerPool)();
|
||||
}
|
||||
}
|
||||
// Setup watcher if watch mode enabled
|
||||
let watcher;
|
||||
if (watch) {
|
||||
if (progress) {
|
||||
logger.info('Watch mode enabled. Watching for file changes...');
|
||||
}
|
||||
const ignored = [
|
||||
// Ignore the output and cache paths to avoid infinite rebuild cycles
|
||||
outputOptions.base,
|
||||
cacheOptions.basePath,
|
||||
`${(0, path_1.toPosixPath)(workspaceRoot)}/**/.*/**`,
|
||||
];
|
||||
// Setup a watcher
|
||||
const { createWatcher } = await Promise.resolve().then(() => __importStar(require('../../tools/esbuild/watcher')));
|
||||
watcher = createWatcher({
|
||||
polling: typeof poll === 'number',
|
||||
interval: poll,
|
||||
followSymlinks: preserveSymlinks,
|
||||
ignored,
|
||||
});
|
||||
// Setup abort support
|
||||
options.signal?.addEventListener('abort', () => void watcher?.close());
|
||||
// Watch the entire project root if 'NG_BUILD_WATCH_ROOT' environment variable is set
|
||||
if (environment_options_1.shouldWatchRoot) {
|
||||
if (!preserveSymlinks) {
|
||||
// Ignore all node modules directories to avoid excessive file watchers.
|
||||
// Package changes are handled below by watching manifest and lock files.
|
||||
// NOTE: this is not enable when preserveSymlinks is true as this would break `npm link` usages.
|
||||
ignored.push('**/node_modules/**');
|
||||
watcher.add(packageWatchFiles
|
||||
.map((file) => node_path_1.default.join(workspaceRoot, file))
|
||||
.filter((file) => (0, node_fs_1.existsSync)(file)));
|
||||
}
|
||||
watcher.add(projectRoot);
|
||||
}
|
||||
// Watch locations provided by the initial build result
|
||||
watcher.add(result.watchFiles);
|
||||
}
|
||||
// Output the first build results after setting up the watcher to ensure that any code executed
|
||||
// higher in the iterator call stack will trigger the watcher. This is particularly relevant for
|
||||
// unit tests which execute the builder and modify the file system programmatically.
|
||||
yield* emitOutputResults(result, outputOptions);
|
||||
// Finish if watch mode is not enabled
|
||||
if (!watcher) {
|
||||
return;
|
||||
}
|
||||
// Used to force a full result on next rebuild if there were initial errors.
|
||||
// This ensures at least one full result is emitted.
|
||||
let hasInitialErrors = result.errors.length > 0;
|
||||
// Wait for changes and rebuild as needed
|
||||
const currentWatchFiles = new Set(result.watchFiles);
|
||||
try {
|
||||
for await (const changes of watcher) {
|
||||
if (options.signal?.aborted) {
|
||||
break;
|
||||
}
|
||||
if (clearScreen) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.clear();
|
||||
}
|
||||
if (verbose) {
|
||||
logger.info(changes.toDebugString());
|
||||
}
|
||||
// Clear removed files from current watch files
|
||||
changes.removed.forEach((removedPath) => currentWatchFiles.delete(removedPath));
|
||||
const rebuildState = result.createRebuildState(changes);
|
||||
result = await withProgress('Changes detected. Rebuilding...', () => action(rebuildState));
|
||||
// Log all diagnostic (error/warning/logs) messages
|
||||
await (0, utils_1.logMessages)(logger, result, colors, jsonLogs);
|
||||
// Update watched locations provided by the new build result.
|
||||
// Keep watching all previous files if there are any errors; otherwise consider all
|
||||
// files stale until confirmed present in the new result's watch files.
|
||||
const staleWatchFiles = result.errors.length > 0 ? undefined : new Set(currentWatchFiles);
|
||||
for (const watchFile of result.watchFiles) {
|
||||
if (!currentWatchFiles.has(watchFile)) {
|
||||
// Add new watch location
|
||||
watcher.add(watchFile);
|
||||
currentWatchFiles.add(watchFile);
|
||||
}
|
||||
// Present so remove from stale locations
|
||||
staleWatchFiles?.delete(watchFile);
|
||||
}
|
||||
// Remove any stale locations if the build was successful
|
||||
if (staleWatchFiles?.size) {
|
||||
watcher.remove([...staleWatchFiles]);
|
||||
}
|
||||
for (const outputResult of emitOutputResults(result, outputOptions, changes, incrementalResults && !hasInitialErrors ? rebuildState : undefined)) {
|
||||
yield outputResult;
|
||||
}
|
||||
// Clear initial build errors flag if no errors are now present
|
||||
hasInitialErrors &&= result.errors.length > 0;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// Stop the watcher and cleanup incremental rebuild state
|
||||
await Promise.allSettled([watcher.close(), result.dispose()]);
|
||||
(0, sass_language_1.shutdownSassWorkerPool)();
|
||||
}
|
||||
}
|
||||
function* emitOutputResults({ outputFiles, assetFiles, errors, warnings, externalMetadata, htmlIndexPath, htmlBaseHref, templateUpdates, }, outputOptions, changes, rebuildState) {
|
||||
if (errors.length > 0) {
|
||||
yield {
|
||||
kind: results_1.ResultKind.Failure,
|
||||
errors: errors,
|
||||
warnings: warnings,
|
||||
detail: {
|
||||
outputOptions,
|
||||
},
|
||||
};
|
||||
return;
|
||||
}
|
||||
// Use a full result if there is no rebuild state (no prior build result)
|
||||
if (!rebuildState || !changes) {
|
||||
const result = {
|
||||
kind: results_1.ResultKind.Full,
|
||||
warnings: warnings,
|
||||
files: {},
|
||||
detail: {
|
||||
externalMetadata,
|
||||
htmlIndexPath,
|
||||
htmlBaseHref,
|
||||
outputOptions,
|
||||
},
|
||||
};
|
||||
for (const file of assetFiles) {
|
||||
result.files[file.destination] = {
|
||||
type: bundler_context_1.BuildOutputFileType.Browser,
|
||||
inputPath: file.source,
|
||||
origin: 'disk',
|
||||
};
|
||||
}
|
||||
for (const file of outputFiles) {
|
||||
result.files[file.path] = {
|
||||
type: file.type,
|
||||
contents: file.contents,
|
||||
origin: 'memory',
|
||||
hash: file.hash,
|
||||
};
|
||||
}
|
||||
yield result;
|
||||
return;
|
||||
}
|
||||
// Template updates only exist if no other JS changes have occurred.
|
||||
// A full page reload may be required based on the following incremental output change analysis.
|
||||
const hasTemplateUpdates = !!templateUpdates?.size;
|
||||
// Use an incremental result if previous output information is available
|
||||
const { previousAssetsInfo, previousOutputInfo } = rebuildState;
|
||||
const incrementalResult = {
|
||||
kind: results_1.ResultKind.Incremental,
|
||||
warnings: warnings,
|
||||
// Initially attempt to use a background update of files to support component updates.
|
||||
background: hasTemplateUpdates,
|
||||
added: [],
|
||||
removed: [],
|
||||
modified: [],
|
||||
files: {},
|
||||
detail: {
|
||||
externalMetadata,
|
||||
htmlIndexPath,
|
||||
htmlBaseHref,
|
||||
outputOptions,
|
||||
},
|
||||
};
|
||||
let hasCssUpdates = false;
|
||||
// Initially assume all previous output files have been removed
|
||||
const removedOutputFiles = new Map(previousOutputInfo);
|
||||
for (const file of outputFiles) {
|
||||
removedOutputFiles.delete(file.path);
|
||||
const previousHash = previousOutputInfo.get(file.path)?.hash;
|
||||
let needFile = false;
|
||||
if (previousHash === undefined) {
|
||||
needFile = true;
|
||||
incrementalResult.added.push(file.path);
|
||||
}
|
||||
else if (previousHash !== file.hash) {
|
||||
needFile = true;
|
||||
incrementalResult.modified.push(file.path);
|
||||
}
|
||||
if (needFile) {
|
||||
if (file.path.endsWith('.css')) {
|
||||
hasCssUpdates = true;
|
||||
}
|
||||
else if (!canBackgroundUpdate(file)) {
|
||||
incrementalResult.background = false;
|
||||
}
|
||||
incrementalResult.files[file.path] = {
|
||||
type: file.type,
|
||||
contents: file.contents,
|
||||
origin: 'memory',
|
||||
hash: file.hash,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Initially assume all previous assets files have been removed
|
||||
const removedAssetFiles = new Map(previousAssetsInfo);
|
||||
for (const { source, destination } of assetFiles) {
|
||||
removedAssetFiles.delete(source);
|
||||
if (!previousAssetsInfo.has(source)) {
|
||||
incrementalResult.added.push(destination);
|
||||
incrementalResult.background = false;
|
||||
}
|
||||
else if (changes.modified.has(source)) {
|
||||
incrementalResult.modified.push(destination);
|
||||
incrementalResult.background = false;
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
hasCssUpdates ||= destination.endsWith('.css');
|
||||
incrementalResult.files[destination] = {
|
||||
type: bundler_context_1.BuildOutputFileType.Browser,
|
||||
inputPath: source,
|
||||
origin: 'disk',
|
||||
};
|
||||
}
|
||||
// Do not remove stale files yet if there are template updates.
|
||||
// Component chunk files may still be referenced in running browser code.
|
||||
// Module evaluation time component updates will update any of these files.
|
||||
// This typically occurs when a lazy component is changed that has not yet
|
||||
// been accessed at runtime.
|
||||
if (hasTemplateUpdates && incrementalResult.background) {
|
||||
removedOutputFiles.clear();
|
||||
}
|
||||
// Include the removed output and asset files
|
||||
incrementalResult.removed.push(...Array.from(removedOutputFiles, ([file, { type }]) => ({
|
||||
path: file,
|
||||
type,
|
||||
})), ...Array.from(removedAssetFiles.values(), (file) => ({
|
||||
path: file,
|
||||
type: bundler_context_1.BuildOutputFileType.Browser,
|
||||
})));
|
||||
yield incrementalResult;
|
||||
// If there are template updates and the incremental update was background only, a component
|
||||
// update is possible.
|
||||
if (hasTemplateUpdates && incrementalResult.background) {
|
||||
// Template changes may be accompanied by stylesheet changes and these should also be updated hot when possible.
|
||||
if (hasCssUpdates) {
|
||||
const styleResult = {
|
||||
kind: results_1.ResultKind.Incremental,
|
||||
added: incrementalResult.added.filter(isCssFilePath),
|
||||
removed: incrementalResult.removed.filter(({ path }) => isCssFilePath(path)),
|
||||
modified: incrementalResult.modified.filter(isCssFilePath),
|
||||
files: Object.fromEntries(Object.entries(incrementalResult.files).filter(([path]) => isCssFilePath(path))),
|
||||
};
|
||||
yield styleResult;
|
||||
}
|
||||
const updateResult = {
|
||||
kind: results_1.ResultKind.ComponentUpdate,
|
||||
updates: Array.from(templateUpdates, ([id, content]) => ({
|
||||
type: 'template',
|
||||
id,
|
||||
content,
|
||||
})),
|
||||
};
|
||||
yield updateResult;
|
||||
}
|
||||
}
|
||||
function isCssFilePath(filePath) {
|
||||
return /\.css(?:\.map)?$/i.test(filePath);
|
||||
}
|
||||
function canBackgroundUpdate(file) {
|
||||
// Files in the output root are not served and do not affect the
|
||||
// application available with the development server.
|
||||
if (file.type === bundler_context_1.BuildOutputFileType.Root) {
|
||||
return true;
|
||||
}
|
||||
// Updates to non-JS files must signal an update with the dev server
|
||||
// except the service worker configuration which is special cased.
|
||||
return /(?:\.m?js|\.map)$/.test(file.path) || file.path === 'ngsw.json';
|
||||
}
|
||||
//# sourceMappingURL=build-action.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @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 { BundleContextResult } from '../../tools/esbuild/bundler-context';
|
||||
/**
|
||||
* Optimizes the chunks of a build result using rolldown.
|
||||
*
|
||||
* This function takes the output of an esbuild build, identifies the main browser entry point,
|
||||
* and uses rolldown to bundle and optimize the JavaScript chunks. The optimized chunks
|
||||
* replace the original ones in the build result, and the metafile is updated to reflect
|
||||
* the changes.
|
||||
*
|
||||
* @param original The original build result from esbuild.
|
||||
* @param sourcemap A boolean or 'hidden' to control sourcemap generation.
|
||||
* @returns A promise that resolves to the updated build result with optimized chunks.
|
||||
*/
|
||||
export declare function optimizeChunks(original: BundleContextResult, sourcemap: boolean | 'hidden'): Promise<BundleContextResult>;
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.optimizeChunks = optimizeChunks;
|
||||
const node_assert_1 = __importDefault(require("node:assert"));
|
||||
const rolldown_1 = require("rolldown");
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
const error_1 = require("../../utils/error");
|
||||
/**
|
||||
* Converts the output of a rolldown build into an esbuild-compatible metafile.
|
||||
* @param rolldownOutput The output of a rolldown build.
|
||||
* @param originalMetafile The original esbuild metafile from the build.
|
||||
* @returns An esbuild-compatible metafile.
|
||||
*/
|
||||
function rolldownToEsbuildMetafile(rolldownOutput, originalMetafile) {
|
||||
const newMetafile = {
|
||||
inputs: originalMetafile.inputs,
|
||||
outputs: {},
|
||||
};
|
||||
const intermediateChunkSizes = {};
|
||||
for (const [path, output] of Object.entries(originalMetafile.outputs)) {
|
||||
intermediateChunkSizes[path] = Object.values(output.inputs).reduce((s, i) => s + i.bytesInOutput, 0);
|
||||
}
|
||||
for (const chunk of rolldownOutput) {
|
||||
if (chunk.type === 'asset') {
|
||||
newMetafile.outputs[chunk.fileName] = {
|
||||
bytes: typeof chunk.source === 'string'
|
||||
? Buffer.byteLength(chunk.source, 'utf8')
|
||||
: chunk.source.length,
|
||||
inputs: {},
|
||||
imports: [],
|
||||
exports: [],
|
||||
};
|
||||
continue;
|
||||
}
|
||||
const newOutputInputs = {};
|
||||
if (chunk.modules) {
|
||||
for (const [moduleId, renderedModule] of Object.entries(chunk.modules)) {
|
||||
const originalOutputEntry = originalMetafile.outputs[moduleId];
|
||||
if (!originalOutputEntry?.inputs) {
|
||||
continue;
|
||||
}
|
||||
const totalOriginalBytesInModule = intermediateChunkSizes[moduleId];
|
||||
if (totalOriginalBytesInModule === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const [originalInputPath, originalInputInfo] of Object.entries(originalOutputEntry.inputs)) {
|
||||
const proportion = originalInputInfo.bytesInOutput / totalOriginalBytesInModule;
|
||||
const newBytesInOutput = Math.floor(renderedModule.renderedLength * proportion);
|
||||
const existing = newOutputInputs[originalInputPath];
|
||||
if (existing) {
|
||||
existing.bytesInOutput += newBytesInOutput;
|
||||
}
|
||||
else {
|
||||
newOutputInputs[originalInputPath] = { bytesInOutput: newBytesInOutput };
|
||||
}
|
||||
if (!newMetafile.inputs[originalInputPath]) {
|
||||
newMetafile.inputs[originalInputPath] = originalMetafile.inputs[originalInputPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const imports = [
|
||||
...chunk.imports.map((path) => ({ path, kind: 'import-statement' })),
|
||||
...(chunk.dynamicImports?.map((path) => ({ path, kind: 'dynamic-import' })) ?? []),
|
||||
];
|
||||
newMetafile.outputs[chunk.fileName] = {
|
||||
bytes: Buffer.byteLength(chunk.code, 'utf8'),
|
||||
inputs: newOutputInputs,
|
||||
imports,
|
||||
exports: chunk.exports ?? [],
|
||||
entryPoint: chunk.isEntry && chunk.facadeModuleId
|
||||
? originalMetafile.outputs[chunk.facadeModuleId]?.entryPoint
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
return newMetafile;
|
||||
}
|
||||
/**
|
||||
* Creates an InitialFileRecord object with a specified depth.
|
||||
* @param depth The depth of the file in the dependency graph.
|
||||
* @returns An InitialFileRecord object.
|
||||
*/
|
||||
function createInitialFileRecord(depth) {
|
||||
return {
|
||||
type: 'script',
|
||||
entrypoint: false,
|
||||
external: false,
|
||||
serverFile: false,
|
||||
depth,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates an esbuild message object for a chunk optimization failure.
|
||||
* @param message The error message detailing the cause of the failure.
|
||||
* @returns A partial esbuild message object.
|
||||
*/
|
||||
function createChunkOptimizationFailureMessage(message) {
|
||||
// Most of these fields are not actually needed for printing the error
|
||||
return {
|
||||
id: '',
|
||||
text: 'Chunk optimization failed',
|
||||
detail: undefined,
|
||||
pluginName: '',
|
||||
location: null,
|
||||
notes: [
|
||||
{
|
||||
text: message,
|
||||
location: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Optimizes the chunks of a build result using rolldown.
|
||||
*
|
||||
* This function takes the output of an esbuild build, identifies the main browser entry point,
|
||||
* and uses rolldown to bundle and optimize the JavaScript chunks. The optimized chunks
|
||||
* replace the original ones in the build result, and the metafile is updated to reflect
|
||||
* the changes.
|
||||
*
|
||||
* @param original The original build result from esbuild.
|
||||
* @param sourcemap A boolean or 'hidden' to control sourcemap generation.
|
||||
* @returns A promise that resolves to the updated build result with optimized chunks.
|
||||
*/
|
||||
async function optimizeChunks(original, sourcemap) {
|
||||
// Failed builds cannot be optimized
|
||||
if (original.errors) {
|
||||
return original;
|
||||
}
|
||||
// Find the main browser entrypoint
|
||||
let mainFile;
|
||||
for (const [file, record] of original.initialFiles) {
|
||||
if (record.name === 'main' &&
|
||||
record.entrypoint &&
|
||||
!record.serverFile &&
|
||||
record.type === 'script') {
|
||||
mainFile = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// No action required if no browser main entrypoint or metafile for stats
|
||||
if (!mainFile || !original.metafile) {
|
||||
return original;
|
||||
}
|
||||
const chunks = {};
|
||||
const maps = {};
|
||||
for (const originalFile of original.outputFiles) {
|
||||
if (originalFile.type !== bundler_context_1.BuildOutputFileType.Browser) {
|
||||
continue;
|
||||
}
|
||||
if (originalFile.path.endsWith('.js')) {
|
||||
chunks[originalFile.path] = originalFile;
|
||||
}
|
||||
else if (originalFile.path.endsWith('.js.map')) {
|
||||
// Create mapping of JS file to sourcemap content
|
||||
maps[originalFile.path.slice(0, -4)] = originalFile;
|
||||
}
|
||||
}
|
||||
const usedChunks = new Set();
|
||||
let bundle;
|
||||
let optimizedOutput;
|
||||
try {
|
||||
bundle = await (0, rolldown_1.rolldown)({
|
||||
input: mainFile,
|
||||
plugins: [
|
||||
{
|
||||
name: 'angular-bundle',
|
||||
resolveId(source) {
|
||||
// Remove leading `./` if present
|
||||
const file = source[0] === '.' && source[1] === '/' ? source.slice(2) : source;
|
||||
if (chunks[file]) {
|
||||
return file;
|
||||
}
|
||||
// All other identifiers are considered external to maintain behavior
|
||||
return { id: source, external: true };
|
||||
},
|
||||
load(id) {
|
||||
(0, node_assert_1.default)(chunks[id], `Angular chunk content should always be present in chunk optimizer [${id}].`);
|
||||
usedChunks.add(id);
|
||||
const result = {
|
||||
code: chunks[id].text,
|
||||
map: maps[id]?.text,
|
||||
};
|
||||
return result;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const result = await bundle.generate({
|
||||
minify: { mangle: false, compress: false },
|
||||
sourcemap,
|
||||
chunkFileNames: (chunkInfo) => `${chunkInfo.name.replace(/-[a-zA-Z0-9]{8}$/, '')}-[hash].js`,
|
||||
});
|
||||
optimizedOutput = result.output;
|
||||
}
|
||||
catch (e) {
|
||||
(0, error_1.assertIsError)(e);
|
||||
return {
|
||||
errors: [createChunkOptimizationFailureMessage(e.message)],
|
||||
warnings: original.warnings,
|
||||
};
|
||||
}
|
||||
finally {
|
||||
await bundle?.close();
|
||||
}
|
||||
// Update metafile
|
||||
const newMetafile = rolldownToEsbuildMetafile(optimizedOutput, original.metafile);
|
||||
// Add back the outputs that were not part of the optimization
|
||||
for (const [path, output] of Object.entries(original.metafile.outputs)) {
|
||||
if (usedChunks.has(path)) {
|
||||
continue;
|
||||
}
|
||||
newMetafile.outputs[path] = output;
|
||||
for (const inputPath of Object.keys(output.inputs)) {
|
||||
if (!newMetafile.inputs[inputPath]) {
|
||||
newMetafile.inputs[inputPath] = original.metafile.inputs[inputPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
original.metafile = newMetafile;
|
||||
// Remove used chunks and associated sourcemaps from the original result
|
||||
original.outputFiles = original.outputFiles.filter((file) => !usedChunks.has(file.path) &&
|
||||
!(file.path.endsWith('.map') && usedChunks.has(file.path.slice(0, -4))));
|
||||
// Add new optimized chunks
|
||||
const importsPerFile = {};
|
||||
for (const optimizedFile of optimizedOutput) {
|
||||
if (optimizedFile.type !== 'chunk') {
|
||||
continue;
|
||||
}
|
||||
importsPerFile[optimizedFile.fileName] = optimizedFile.imports;
|
||||
original.outputFiles.push((0, utils_1.createOutputFile)(optimizedFile.fileName, optimizedFile.code, bundler_context_1.BuildOutputFileType.Browser));
|
||||
if (optimizedFile.map && optimizedFile.sourcemapFileName) {
|
||||
original.outputFiles.push((0, utils_1.createOutputFile)(optimizedFile.sourcemapFileName, optimizedFile.map.toString(), bundler_context_1.BuildOutputFileType.Browser));
|
||||
}
|
||||
}
|
||||
// Update initial files to reflect optimized chunks
|
||||
const entriesToAnalyze = [];
|
||||
for (const usedFile of usedChunks) {
|
||||
// Leave the main file since its information did not change
|
||||
if (usedFile === mainFile) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
entriesToAnalyze.push([mainFile, original.initialFiles.get(mainFile)]);
|
||||
continue;
|
||||
}
|
||||
// Remove all other used chunks
|
||||
original.initialFiles.delete(usedFile);
|
||||
}
|
||||
// Analyze for transitive initial files
|
||||
let currentEntry;
|
||||
while ((currentEntry = entriesToAnalyze.pop())) {
|
||||
const [entryPath, entryRecord] = currentEntry;
|
||||
for (const importPath of importsPerFile[entryPath]) {
|
||||
const existingRecord = original.initialFiles.get(importPath);
|
||||
if (existingRecord) {
|
||||
// Store the smallest value depth
|
||||
if (existingRecord.depth > entryRecord.depth + 1) {
|
||||
existingRecord.depth = entryRecord.depth + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const record = createInitialFileRecord(entryRecord.depth + 1);
|
||||
entriesToAnalyze.push([importPath, record]);
|
||||
}
|
||||
}
|
||||
return original;
|
||||
}
|
||||
//# sourceMappingURL=chunk-optimizer.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
|
||||
import { NormalizedApplicationBuildOptions } from './options';
|
||||
export declare function executeBuild(options: NormalizedApplicationBuildOptions, context: BuilderContext, rebuildState?: RebuildState): Promise<ExecutionResult>;
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.executeBuild = executeBuild;
|
||||
const compilation_1 = require("../../tools/angular/compilation");
|
||||
const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
|
||||
const budget_stats_1 = require("../../tools/esbuild/budget-stats");
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const bundler_execution_result_1 = require("../../tools/esbuild/bundler-execution-result");
|
||||
const commonjs_checker_1 = require("../../tools/esbuild/commonjs-checker");
|
||||
const license_extractor_1 = require("../../tools/esbuild/license-extractor");
|
||||
const profiling_1 = require("../../tools/esbuild/profiling");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
const bundle_calculator_1 = require("../../utils/bundle-calculator");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const resolve_assets_1 = require("../../utils/resolve-assets");
|
||||
const manifest_1 = require("../../utils/server-rendering/manifest");
|
||||
const supported_browsers_1 = require("../../utils/supported-browsers");
|
||||
const execute_post_bundle_1 = require("./execute-post-bundle");
|
||||
const i18n_1 = require("./i18n");
|
||||
const setup_bundling_1 = require("./setup-bundling");
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
async function executeBuild(options, context, rebuildState) {
|
||||
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, serverEntryPoint, baseHref, ssrOptions, verbose, colors, jsonLogs, security, } = options;
|
||||
// TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
|
||||
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
|
||||
// Load active translations if inlining
|
||||
// TODO: Integrate into watch mode and only load changed translations
|
||||
if (i18nOptions.shouldInline) {
|
||||
await (0, i18n_1.loadActiveTranslations)(context, i18nOptions);
|
||||
}
|
||||
// Reuse rebuild state or create new bundle contexts for code and global stylesheets
|
||||
let bundlerContexts;
|
||||
let componentStyleBundler;
|
||||
let codeBundleCache;
|
||||
let bundlingResult;
|
||||
let templateUpdates;
|
||||
if (rebuildState) {
|
||||
bundlerContexts = rebuildState.rebuildContexts;
|
||||
componentStyleBundler = rebuildState.componentStyleBundler;
|
||||
codeBundleCache = rebuildState.codeBundleCache;
|
||||
templateUpdates = rebuildState.templateUpdates;
|
||||
// Reset template updates for new rebuild
|
||||
templateUpdates?.clear();
|
||||
const allFileChanges = rebuildState.fileChanges.all;
|
||||
// Bundle all contexts that do not require TypeScript changed file checks.
|
||||
// These will automatically use cached results based on the changed files.
|
||||
bundlingResult = await bundler_context_1.BundlerContext.bundleAll(bundlerContexts.otherContexts, allFileChanges);
|
||||
// Check the TypeScript code bundling cache for changes. If invalid, force a rebundle of
|
||||
// all TypeScript related contexts.
|
||||
const forceTypeScriptRebuild = codeBundleCache?.invalidate(allFileChanges);
|
||||
const typescriptResults = [];
|
||||
for (const typescriptContext of bundlerContexts.typescriptContexts) {
|
||||
typescriptContext.invalidate(allFileChanges);
|
||||
const result = await typescriptContext.bundle(forceTypeScriptRebuild);
|
||||
typescriptResults.push(result);
|
||||
}
|
||||
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...typescriptResults]);
|
||||
}
|
||||
else {
|
||||
const target = (0, utils_1.transformSupportedBrowsersToTargets)(browsers);
|
||||
codeBundleCache = new source_file_cache_1.SourceFileCache(cacheOptions.enabled ? cacheOptions.path : undefined);
|
||||
componentStyleBundler = (0, setup_bundling_1.createComponentStyleBundler)(options, target);
|
||||
if (options.templateUpdates) {
|
||||
templateUpdates = new Map();
|
||||
}
|
||||
bundlerContexts = (0, setup_bundling_1.setupBundlerContexts)(options, target, codeBundleCache, componentStyleBundler,
|
||||
// Create new reusable compilation for the appropriate mode based on the `jit` plugin option
|
||||
await (0, compilation_1.createAngularCompilation)(!!options.jit, !options.serverEntryPoint), templateUpdates);
|
||||
// Bundle everything on initial build
|
||||
bundlingResult = await bundler_context_1.BundlerContext.bundleAll([
|
||||
...bundlerContexts.typescriptContexts,
|
||||
...bundlerContexts.otherContexts,
|
||||
]);
|
||||
}
|
||||
// Update any external component styles if enabled and rebuilding.
|
||||
// TODO: Only attempt rebundling of invalidated styles once incremental build results are supported.
|
||||
if (rebuildState && options.externalRuntimeStyles) {
|
||||
componentStyleBundler.invalidate(rebuildState.fileChanges.all);
|
||||
const componentResults = await componentStyleBundler.bundleAllFiles(true, true);
|
||||
bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...componentResults]);
|
||||
}
|
||||
if (options.optimizationOptions.scripts && environment_options_1.shouldOptimizeChunks) {
|
||||
const { optimizeChunks } = await Promise.resolve().then(() => __importStar(require('./chunk-optimizer')));
|
||||
bundlingResult = await (0, profiling_1.profileAsync)('OPTIMIZE_CHUNKS', () => optimizeChunks(bundlingResult, options.sourcemapOptions.scripts ? !options.sourcemapOptions.hidden || 'hidden' : false));
|
||||
}
|
||||
const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, componentStyleBundler, codeBundleCache, templateUpdates);
|
||||
executionResult.addWarnings(bundlingResult.warnings);
|
||||
// Add used external component style referenced files to be watched
|
||||
if (options.externalRuntimeStyles) {
|
||||
executionResult.extraWatchFiles.push(...componentStyleBundler.collectReferencedFiles());
|
||||
}
|
||||
// Return if the bundling has errors
|
||||
if (bundlingResult.errors) {
|
||||
executionResult.addErrors(bundlingResult.errors);
|
||||
return executionResult;
|
||||
}
|
||||
// Analyze external imports if external options are enabled
|
||||
if (options.externalPackages || bundlingResult.externalConfiguration) {
|
||||
const { externalConfiguration = [], externalImports: { browser = [], server = [] }, } = bundlingResult;
|
||||
// Similar to esbuild, --external:@foo/bar automatically implies --external:@foo/bar/*,
|
||||
// which matches import paths like @foo/bar/baz.
|
||||
// This means all paths within the @foo/bar package are also marked as external.
|
||||
const exclusionsPrefixes = externalConfiguration.map((exclusion) => exclusion + '/');
|
||||
const exclusions = new Set(externalConfiguration);
|
||||
const explicitExternal = new Set();
|
||||
const isExplicitExternal = (dep) => {
|
||||
if (exclusions.has(dep)) {
|
||||
return true;
|
||||
}
|
||||
for (const prefix of exclusionsPrefixes) {
|
||||
if (dep.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const implicitBrowser = [];
|
||||
for (const dep of browser) {
|
||||
if (isExplicitExternal(dep)) {
|
||||
explicitExternal.add(dep);
|
||||
}
|
||||
else {
|
||||
implicitBrowser.push(dep);
|
||||
}
|
||||
}
|
||||
const implicitServer = [];
|
||||
for (const dep of server) {
|
||||
if (isExplicitExternal(dep)) {
|
||||
explicitExternal.add(dep);
|
||||
}
|
||||
else {
|
||||
implicitServer.push(dep);
|
||||
}
|
||||
}
|
||||
executionResult.setExternalMetadata(implicitBrowser, implicitServer, [...explicitExternal]);
|
||||
}
|
||||
const { metafile, initialFiles, outputFiles } = bundlingResult;
|
||||
executionResult.outputFiles.push(...outputFiles);
|
||||
// Analyze files for bundle budget failures if present
|
||||
let budgetFailures;
|
||||
if (options.budgets) {
|
||||
const compatStats = (0, budget_stats_1.generateBudgetStats)(metafile, outputFiles, initialFiles);
|
||||
budgetFailures = [...(0, bundle_calculator_1.checkBudgets)(options.budgets, compatStats, true)];
|
||||
for (const { message, severity } of budgetFailures) {
|
||||
if (severity === 'error') {
|
||||
executionResult.addError(message);
|
||||
}
|
||||
else {
|
||||
executionResult.addWarning(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calculate estimated transfer size if scripts are optimized
|
||||
let estimatedTransferSizes;
|
||||
if (optimizationOptions.scripts || optimizationOptions.styles.minify) {
|
||||
estimatedTransferSizes = await (0, utils_1.calculateEstimatedTransferSizes)(executionResult.outputFiles);
|
||||
}
|
||||
// Check metafile for CommonJS module usage if optimizing scripts
|
||||
if (optimizationOptions.scripts) {
|
||||
const messages = (0, commonjs_checker_1.checkCommonJSModules)(metafile, options.allowedCommonJsDependencies);
|
||||
executionResult.addWarnings(messages);
|
||||
}
|
||||
// Copy assets
|
||||
if (assets) {
|
||||
executionResult.addAssets(await (0, resolve_assets_1.resolveAssets)(assets, workspaceRoot));
|
||||
}
|
||||
// Extract and write licenses for used packages
|
||||
if (options.extractLicenses) {
|
||||
executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
|
||||
}
|
||||
// Watch input index HTML file if configured
|
||||
if (options.indexHtmlOptions) {
|
||||
executionResult.extraWatchFiles.push(options.indexHtmlOptions.input);
|
||||
executionResult.htmlIndexPath = options.indexHtmlOptions.output;
|
||||
executionResult.htmlBaseHref = options.baseHref;
|
||||
}
|
||||
// Create server app engine manifest
|
||||
if (serverEntryPoint) {
|
||||
executionResult.addOutputFile(manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME, (0, manifest_1.generateAngularServerAppEngineManifest)(i18nOptions, security.allowedHosts, baseHref), bundler_context_1.BuildOutputFileType.ServerRoot);
|
||||
}
|
||||
// Perform i18n translation inlining if enabled
|
||||
if (i18nOptions.shouldInline) {
|
||||
const result = await (0, i18n_1.inlineI18n)(metafile, options, executionResult, initialFiles);
|
||||
executionResult.addErrors(result.errors);
|
||||
executionResult.addWarnings(result.warnings);
|
||||
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
||||
}
|
||||
else {
|
||||
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
|
||||
// Set lang attribute to the defined source locale if present
|
||||
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
|
||||
// Deduplicate and add errors and warnings
|
||||
executionResult.addErrors([...new Set(result.errors)]);
|
||||
executionResult.addWarnings([...new Set(result.warnings)]);
|
||||
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
|
||||
executionResult.outputFiles.push(...result.additionalOutputFiles);
|
||||
executionResult.assetFiles.push(...result.additionalAssets);
|
||||
}
|
||||
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: executionResult.prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
||||
// Write metafile if stats option is enabled
|
||||
if (options.stats) {
|
||||
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
||||
}
|
||||
if (!jsonLogs) {
|
||||
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputInfo);
|
||||
executionResult.addLog((0, utils_1.logBuildStats)(metafile, outputFiles, initialFiles, budgetFailures, colors, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose));
|
||||
}
|
||||
return executionResult;
|
||||
}
|
||||
//# sourceMappingURL=execute-build.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @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 { Metafile } from 'esbuild';
|
||||
import { BuildOutputFile, InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
||||
import { BuildOutputAsset, PrerenderedRoutesRecord } from '../../tools/esbuild/bundler-execution-result';
|
||||
import { NormalizedApplicationBuildOptions } from './options';
|
||||
/**
|
||||
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
||||
* @param metafile An esbuild metafile object.
|
||||
* @param options The normalized application builder options used to create the build.
|
||||
* @param outputFiles The output files of an executed build.
|
||||
* @param assetFiles The assets of an executed build.
|
||||
* @param initialFiles A map containing initial file information for the executed build.
|
||||
* @param locale A language locale to insert in the index.html.
|
||||
*/
|
||||
export declare function executePostBundleSteps(metafile: Metafile, options: NormalizedApplicationBuildOptions, outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[], initialFiles: Map<string, InitialFileRecord>, locale: string | undefined): Promise<{
|
||||
errors: string[];
|
||||
warnings: string[];
|
||||
additionalOutputFiles: BuildOutputFile[];
|
||||
additionalAssets: BuildOutputAsset[];
|
||||
prerenderedRoutes: PrerenderedRoutesRecord;
|
||||
}>;
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.executePostBundleSteps = executePostBundleSteps;
|
||||
const node_assert_1 = __importDefault(require("node:assert"));
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const index_html_generator_1 = require("../../tools/esbuild/index-html-generator");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const manifest_1 = require("../../utils/server-rendering/manifest");
|
||||
const models_1 = require("../../utils/server-rendering/models");
|
||||
const prerender_1 = require("../../utils/server-rendering/prerender");
|
||||
const service_worker_1 = require("../../utils/service-worker");
|
||||
const options_1 = require("./options");
|
||||
const schema_1 = require("./schema");
|
||||
/**
|
||||
* Run additional builds steps including SSG, AppShell, Index HTML file and Service worker generation.
|
||||
* @param metafile An esbuild metafile object.
|
||||
* @param options The normalized application builder options used to create the build.
|
||||
* @param outputFiles The output files of an executed build.
|
||||
* @param assetFiles The assets of an executed build.
|
||||
* @param initialFiles A map containing initial file information for the executed build.
|
||||
* @param locale A language locale to insert in the index.html.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
async function executePostBundleSteps(metafile, options, outputFiles, assetFiles, initialFiles, locale) {
|
||||
const additionalAssets = [];
|
||||
const additionalOutputFiles = [];
|
||||
const allErrors = [];
|
||||
const allWarnings = [];
|
||||
const prerenderedRoutes = {};
|
||||
const { baseHref = '/', serviceWorker, ssrOptions, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, publicPath, workspaceRoot, partialSSRBuild, } = options;
|
||||
// Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
||||
// NOTE: Critical CSS inlining is deliberately omitted here, as it will be handled during server rendering.
|
||||
// Additionally, when using prerendering or AppShell, the index HTML file may be regenerated.
|
||||
// To prevent generating duplicate files with the same filename, a `Map` is used to store and manage the files.
|
||||
const additionalHtmlOutputFiles = new Map();
|
||||
// Generate index HTML file
|
||||
// If localization is enabled, index generation is handled in the inlining process.
|
||||
if (indexHtmlOptions) {
|
||||
const { csrContent, ssrContent, errors, warnings } = await (0, index_html_generator_1.generateIndexHtml)(initialFiles, outputFiles, options, locale);
|
||||
allErrors.push(...errors);
|
||||
allWarnings.push(...warnings);
|
||||
additionalHtmlOutputFiles.set(indexHtmlOptions.output, (0, utils_1.createOutputFile)(indexHtmlOptions.output, csrContent, bundler_context_1.BuildOutputFileType.Browser));
|
||||
if (ssrContent) {
|
||||
additionalHtmlOutputFiles.set(options_1.INDEX_HTML_SERVER, (0, utils_1.createOutputFile)(options_1.INDEX_HTML_SERVER, ssrContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
||||
}
|
||||
}
|
||||
// Create server manifest
|
||||
const initialFilesPaths = new Set(initialFiles.keys());
|
||||
if (serverEntryPoint && (outputMode || prerenderOptions || appShellOptions || ssrOptions)) {
|
||||
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale, baseHref, initialFilesPaths, metafile, publicPath);
|
||||
additionalOutputFiles.push(...serverAssetsChunks, (0, utils_1.createOutputFile)(manifest_1.SERVER_APP_MANIFEST_FILENAME, manifestContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
||||
}
|
||||
// Pre-render (SSG) and App-shell
|
||||
// If localization is enabled, prerendering is handled in the inlining process.
|
||||
if (!partialSSRBuild &&
|
||||
(prerenderOptions || appShellOptions || (outputMode && serverEntryPoint)) &&
|
||||
!allErrors.length) {
|
||||
(0, node_assert_1.default)(indexHtmlOptions, 'The "index" option is required when using the "ssg" or "appShell" options.');
|
||||
const { output, warnings, errors, serializableRouteTreeNode } = await (0, prerender_1.prerenderPages)(workspaceRoot, baseHref, appShellOptions, prerenderOptions, [...outputFiles, ...additionalOutputFiles], assetFiles, outputMode, sourcemapOptions.scripts, environment_options_1.maxWorkers);
|
||||
allErrors.push(...errors);
|
||||
allWarnings.push(...warnings);
|
||||
const indexHasBeenPrerendered = output[indexHtmlOptions.output];
|
||||
for (const [path, { content, appShellRoute }] of Object.entries(output)) {
|
||||
// Update the index contents with the app shell under these conditions:
|
||||
// - Replace 'index.html' with the app shell only if it hasn't been prerendered yet.
|
||||
// - Always replace 'index.csr.html' with the app shell.
|
||||
let filePath = path;
|
||||
if (appShellRoute && !indexHasBeenPrerendered) {
|
||||
if (outputMode !== schema_1.OutputMode.Server && indexHtmlOptions.output === options_1.INDEX_HTML_CSR) {
|
||||
filePath = 'index.html';
|
||||
}
|
||||
else {
|
||||
filePath = indexHtmlOptions.output;
|
||||
}
|
||||
}
|
||||
additionalHtmlOutputFiles.set(filePath, (0, utils_1.createOutputFile)(filePath, content, bundler_context_1.BuildOutputFileType.Browser));
|
||||
}
|
||||
const serializableRouteTreeNodeForManifest = [];
|
||||
for (const metadata of serializableRouteTreeNode) {
|
||||
serializableRouteTreeNodeForManifest.push(metadata);
|
||||
if (metadata.renderMode === models_1.RouteRenderMode.Prerender && !metadata.route.includes('*')) {
|
||||
prerenderedRoutes[metadata.route] = { headers: metadata.headers };
|
||||
}
|
||||
}
|
||||
if (outputMode === schema_1.OutputMode.Server) {
|
||||
// Regenerate the manifest to append route tree. This is only needed if SSR is enabled.
|
||||
const manifest = additionalOutputFiles.find((f) => f.path === manifest_1.SERVER_APP_MANIFEST_FILENAME);
|
||||
(0, node_assert_1.default)(manifest, `${manifest_1.SERVER_APP_MANIFEST_FILENAME} was not found in output files.`);
|
||||
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale, baseHref, initialFilesPaths, metafile, publicPath);
|
||||
for (const chunk of serverAssetsChunks) {
|
||||
const idx = additionalOutputFiles.findIndex(({ path }) => path === chunk.path);
|
||||
if (idx === -1) {
|
||||
additionalOutputFiles.push(chunk);
|
||||
}
|
||||
else {
|
||||
additionalOutputFiles[idx] = chunk;
|
||||
}
|
||||
}
|
||||
manifest.contents = new TextEncoder().encode(manifestContent);
|
||||
}
|
||||
}
|
||||
additionalOutputFiles.push(...additionalHtmlOutputFiles.values());
|
||||
// Augment the application with service worker support
|
||||
// If localization is enabled, service worker is handled in the inlining process.
|
||||
if (serviceWorker) {
|
||||
try {
|
||||
const serviceWorkerResult = await (0, service_worker_1.augmentAppWithServiceWorkerEsbuild)(workspaceRoot, serviceWorker, baseHref, options.indexHtmlOptions?.output,
|
||||
// Ensure additional files recently added are used
|
||||
[...outputFiles, ...additionalOutputFiles], assetFiles);
|
||||
additionalOutputFiles.push((0, utils_1.createOutputFile)('ngsw.json', serviceWorkerResult.manifest, bundler_context_1.BuildOutputFileType.Browser));
|
||||
additionalAssets.push(...serviceWorkerResult.assetFiles);
|
||||
}
|
||||
catch (error) {
|
||||
allErrors.push(error instanceof Error ? error.message : `${error}`);
|
||||
}
|
||||
}
|
||||
return {
|
||||
errors: allErrors,
|
||||
warnings: allWarnings,
|
||||
additionalAssets,
|
||||
prerenderedRoutes,
|
||||
additionalOutputFiles,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=execute-post-bundle.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"execute-post-bundle.js","sourceRoot":"","sources":["execute-post-bundle.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAuCH,wDAmNC;AAvPD,8DAAiC;AACjC,yEAI6C;AAK7C,mFAA6E;AAC7E,qDAA6D;AAC7D,yEAA6D;AAC7D,oEAG+C;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AC,gBAAgB,EAAE,MAAM;YAChC,kDAAkD;YAClD,CAAC,GAAG,WAAW,EAAE,GAAG,qBAAqB,CAAC,EAC1C,UAAU,CACX,CAAC;YAEF,qBAAqB,CAAC,IAAI,CACxB,IAAA,wBAAgB,EAAC,WAAW,EAAE,mBAAmB,CAAC,QAAQ,EAAE,qCAAmB,CAAC,OAAO,CAAC,CACzF,CAAC;YACF,gBAAgB,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,WAAW;QACrB,gBAAgB;QAChB,iBAAiB;QACjB,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { Metafile } from 'esbuild';
|
||||
import { InitialFileRecord } from '../../tools/esbuild/bundler-context';
|
||||
import { ExecutionResult, PrerenderedRoutesRecord } from '../../tools/esbuild/bundler-execution-result';
|
||||
import { NormalizedApplicationBuildOptions } from './options';
|
||||
/**
|
||||
* Inlines all active locales as specified by the application build options into all
|
||||
* application JavaScript files created during the build.
|
||||
* @param metafile An esbuild metafile object.
|
||||
* @param options The normalized application builder options used to create the build.
|
||||
* @param executionResult The result of an executed build.
|
||||
* @param initialFiles A map containing initial file information for the executed build.
|
||||
*/
|
||||
export declare function inlineI18n(metafile: Metafile, options: NormalizedApplicationBuildOptions, executionResult: ExecutionResult, initialFiles: Map<string, InitialFileRecord>): Promise<{
|
||||
errors: string[];
|
||||
warnings: string[];
|
||||
prerenderedRoutes: PrerenderedRoutesRecord;
|
||||
}>;
|
||||
/**
|
||||
* Loads all active translations using the translation loaders from the `@angular/localize` package.
|
||||
* @param context The architect builder context for the current build.
|
||||
* @param i18n The normalized i18n options to use.
|
||||
*/
|
||||
export declare function loadActiveTranslations(context: BuilderContext, i18n: NormalizedApplicationBuildOptions['i18nOptions']): Promise<void>;
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.inlineI18n = inlineI18n;
|
||||
exports.loadActiveTranslations = loadActiveTranslations;
|
||||
const node_path_1 = require("node:path");
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const i18n_inliner_1 = require("../../tools/esbuild/i18n-inliner");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const i18n_options_1 = require("../../utils/i18n-options");
|
||||
const load_translations_1 = require("../../utils/load-translations");
|
||||
const execute_post_bundle_1 = require("./execute-post-bundle");
|
||||
const options_1 = require("./options");
|
||||
/**
|
||||
* Inlines all active locales as specified by the application build options into all
|
||||
* application JavaScript files created during the build.
|
||||
* @param metafile An esbuild metafile object.
|
||||
* @param options The normalized application builder options used to create the build.
|
||||
* @param executionResult The result of an executed build.
|
||||
* @param initialFiles A map containing initial file information for the executed build.
|
||||
*/
|
||||
async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
||||
const { i18nOptions, optimizationOptions, baseHref, cacheOptions } = options;
|
||||
// Create the multi-threaded inliner with common options and the files generated from the build.
|
||||
const inliner = new i18n_inliner_1.I18nInliner({
|
||||
missingTranslation: i18nOptions.missingTranslationBehavior ?? 'warning',
|
||||
outputFiles: executionResult.outputFiles,
|
||||
shouldOptimize: optimizationOptions.scripts,
|
||||
persistentCachePath: cacheOptions.enabled ? cacheOptions.path : undefined,
|
||||
}, environment_options_1.maxWorkers);
|
||||
const inlineResult = {
|
||||
errors: [],
|
||||
warnings: [],
|
||||
prerenderedRoutes: {},
|
||||
};
|
||||
// For each active locale, use the inliner to process the output files of the build.
|
||||
const updatedOutputFiles = [];
|
||||
const updatedAssetFiles = [];
|
||||
// Root and SSR entry files are not modified.
|
||||
const unModifiedOutputFiles = executionResult.outputFiles.filter(({ type }) => type === bundler_context_1.BuildOutputFileType.Root || type === bundler_context_1.BuildOutputFileType.ServerRoot);
|
||||
try {
|
||||
for (const locale of i18nOptions.inlineLocales) {
|
||||
// A locale specific set of files is returned from the inliner.
|
||||
const localeInlineResult = await inliner.inlineForLocale(locale, i18nOptions.locales[locale].translation);
|
||||
const localeOutputFiles = localeInlineResult.outputFiles;
|
||||
inlineResult.errors.push(...localeInlineResult.errors);
|
||||
inlineResult.warnings.push(...localeInlineResult.warnings);
|
||||
const { errors, warnings, additionalAssets, additionalOutputFiles, prerenderedRoutes: generatedRoutes, } = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, {
|
||||
...options,
|
||||
baseHref: (0, options_1.getLocaleBaseHref)(baseHref, i18nOptions, locale) ?? baseHref,
|
||||
}, [...unModifiedOutputFiles, ...localeOutputFiles], executionResult.assetFiles, initialFiles, locale);
|
||||
localeOutputFiles.push(...additionalOutputFiles);
|
||||
inlineResult.errors.push(...errors);
|
||||
inlineResult.warnings.push(...warnings);
|
||||
// Update directory with locale base or subPath
|
||||
const subPath = i18nOptions.locales[locale].subPath;
|
||||
if (i18nOptions.flatOutput !== true) {
|
||||
localeOutputFiles.forEach((file) => {
|
||||
file.path = (0, node_path_1.join)(subPath, file.path);
|
||||
});
|
||||
for (const assetFile of [...executionResult.assetFiles, ...additionalAssets]) {
|
||||
updatedAssetFiles.push({
|
||||
source: assetFile.source,
|
||||
destination: (0, node_path_1.join)(subPath, assetFile.destination),
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
executionResult.assetFiles.push(...additionalAssets);
|
||||
}
|
||||
inlineResult.prerenderedRoutes = { ...inlineResult.prerenderedRoutes, ...generatedRoutes };
|
||||
updatedOutputFiles.push(...localeOutputFiles);
|
||||
}
|
||||
// Update the result with all localized files.
|
||||
executionResult.outputFiles = [
|
||||
// Root and SSR entry files are not modified.
|
||||
...unModifiedOutputFiles,
|
||||
// Updated files for each locale.
|
||||
...updatedOutputFiles,
|
||||
];
|
||||
// Assets are only changed if not using the flat output option
|
||||
if (!i18nOptions.flatOutput) {
|
||||
executionResult.assetFiles = updatedAssetFiles;
|
||||
}
|
||||
// Inline any template updates if present
|
||||
if (executionResult.templateUpdates?.size) {
|
||||
// The development server only allows a single locale but issue a warning if used programmatically (experimental)
|
||||
// with multiple locales and template HMR.
|
||||
if (i18nOptions.inlineLocales.size > 1) {
|
||||
inlineResult.warnings.push(`Component HMR updates can only be inlined with a single locale. The first locale will be used.`);
|
||||
}
|
||||
const firstLocale = [...i18nOptions.inlineLocales][0];
|
||||
for (const [id, content] of executionResult.templateUpdates) {
|
||||
const templateUpdateResult = await inliner.inlineTemplateUpdate(firstLocale, i18nOptions.locales[firstLocale].translation, content, id);
|
||||
executionResult.templateUpdates.set(id, templateUpdateResult.code);
|
||||
inlineResult.errors.push(...templateUpdateResult.errors);
|
||||
inlineResult.warnings.push(...templateUpdateResult.warnings);
|
||||
}
|
||||
}
|
||||
return inlineResult;
|
||||
}
|
||||
finally {
|
||||
await inliner.close();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Loads all active translations using the translation loaders from the `@angular/localize` package.
|
||||
* @param context The architect builder context for the current build.
|
||||
* @param i18n The normalized i18n options to use.
|
||||
*/
|
||||
async function loadActiveTranslations(context, i18n) {
|
||||
// Load locale data and translations (if present)
|
||||
let loader;
|
||||
for (const [locale, desc] of Object.entries(i18n.locales)) {
|
||||
if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
|
||||
continue;
|
||||
}
|
||||
if (!desc.files.length) {
|
||||
continue;
|
||||
}
|
||||
loader ??= await (0, load_translations_1.createTranslationLoader)();
|
||||
(0, i18n_options_1.loadTranslations)(locale, desc, context.workspaceRoot, loader, {
|
||||
warn(message) {
|
||||
context.logger.warn(message);
|
||||
},
|
||||
error(message) {
|
||||
throw new Error(message);
|
||||
},
|
||||
}, undefined, i18n.duplicateTranslationBehavior);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=i18n.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["i18n.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAyBH,gCAwIC;AAOD,wDAkCC;AAtMD,yCAAiC;AACjC,yEAA6F;AAK7F,mEAA+D;AAC/D,yEAA6D;AAC7D,2DAA4D;AAC5D,qEAAwE;AACxE,+DAA+D;AAC/D,uCAAiF;AAEjF;;;;;;;GAOG;AACI,KAAK,UAAU,UAAU,CAC9B,QAAkB,EAClB,OAA0C,EAC1C,eAAgC,EAChC,YAA4C;IAM5C,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE7E,gGAAgG;IAChG,MAAM,OAAO,GAAG,IAAI,0BAAW,CAC7B;QACE,kBAAkB,EAAE,WAAW,CAAC,0BAA0B,IAAI,SAAS;QACvE,WAAW,EAAE,eAAe,CAAC,WAAW;QACxC,cAAc,EAAE,mBAAmB,CAAC,OAAO;QAC3C,mBAAmB,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KAC1E,EACD,gCAAU,CACX,CAAC;IAEF,MAAM,YAAY,GAId;QACF,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,iBAAiB,EAAE,EAAE;KACtB,C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C,YAAY,EAAE,CAAC;YACpE,SAAS;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACvB,SAAS;QACX,CAAC;QAED,MAAM,KAAK,MAAM,IAAA,2CAAuB,GAAE,CAAC;QAE3C,IAAA,+BAAgB,EACd,MAAM,EACN,IAAI,EACJ,OAAO,CAAC,aAAa,EACrB,MAAM,EACN;YACE,IAAI,CAAC,OAAO;gBACV,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YACD,KAAK,CAAC,OAAO;gBACX,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;SACF,EACD,SAAS,EACT,IAAI,CAAC,4BAA4B,CAClC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @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 { Builder, BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
||||
import { ApplicationBuilderExtensions, ApplicationBuilderInternalOptions } from './options';
|
||||
import { Result } from './results';
|
||||
import { Schema as ApplicationBuilderOptions } from './schema';
|
||||
export type { ApplicationBuilderOptions };
|
||||
export declare function buildApplicationInternal(options: ApplicationBuilderInternalOptions, context: BuilderContext & {
|
||||
signal?: AbortSignal;
|
||||
}, extensions?: ApplicationBuilderExtensions): AsyncIterable<Result>;
|
||||
/**
|
||||
* Builds an application using the `application` builder with the provided
|
||||
* options.
|
||||
*
|
||||
* Usage of the `extensions` parameter is NOT supported and may cause unexpected
|
||||
* build output or build failures.
|
||||
*
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*
|
||||
* @param options The options defined by the builder's schema to use.
|
||||
* @param context An Architect builder context instance.
|
||||
* @param extensions An object contain extension points for the build.
|
||||
* @returns The build output results of the build.
|
||||
*/
|
||||
export declare function buildApplication(options: ApplicationBuilderOptions, context: BuilderContext, extensions?: ApplicationBuilderExtensions): AsyncIterable<BuilderOutput>;
|
||||
declare const builder: Builder<ApplicationBuilderOptions>;
|
||||
export default builder;
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildApplicationInternal = buildApplicationInternal;
|
||||
exports.buildApplication = buildApplication;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const node_assert_1 = __importDefault(require("node:assert"));
|
||||
const promises_1 = __importDefault(require("node:fs/promises"));
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
const color_1 = require("../../utils/color");
|
||||
const delete_output_dir_1 = require("../../utils/delete-output-dir");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const purge_cache_1 = require("../../utils/purge-cache");
|
||||
const version_1 = require("../../utils/version");
|
||||
const build_action_1 = require("./build-action");
|
||||
const execute_build_1 = require("./execute-build");
|
||||
const options_1 = require("./options");
|
||||
const results_1 = require("./results");
|
||||
const isNodeV22orHigher = Number(process.versions.node.split('.', 1)[0]) >= 22;
|
||||
async function* buildApplicationInternal(options,
|
||||
// TODO: Integrate abort signal support into builder system
|
||||
context, extensions) {
|
||||
const { workspaceRoot, logger, target } = context;
|
||||
// Check Angular version.
|
||||
(0, version_1.assertCompatibleAngularVersion)(workspaceRoot);
|
||||
// Purge old build disk cache.
|
||||
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
||||
// Determine project name from builder context target
|
||||
const projectName = target?.project;
|
||||
if (!projectName) {
|
||||
context.logger.error(`The 'application' builder requires a target to be specified.`);
|
||||
// Only the vite-based dev server current uses the errors value
|
||||
yield { kind: results_1.ResultKind.Failure, errors: [] };
|
||||
return;
|
||||
}
|
||||
if (environment_options_1.bazelEsbuildPluginPath) {
|
||||
extensions ??= {};
|
||||
extensions.codePlugins ??= [];
|
||||
const { default: bazelEsbuildPlugin } = await Promise.resolve(`${environment_options_1.bazelEsbuildPluginPath}`).then(s => __importStar(require(s)));
|
||||
extensions.codePlugins.push(bazelEsbuildPlugin);
|
||||
}
|
||||
const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, options, extensions);
|
||||
if (!normalizedOptions.outputOptions.ignoreServer) {
|
||||
const { browser, server } = normalizedOptions.outputOptions;
|
||||
if (browser === '') {
|
||||
context.logger.error(`'outputPath.browser' cannot be configured to an empty string when SSR is enabled.`);
|
||||
yield { kind: results_1.ResultKind.Failure, errors: [] };
|
||||
return;
|
||||
}
|
||||
if (browser === server) {
|
||||
context.logger.error(`'outputPath.browser' and 'outputPath.server' cannot be configured to the same value.`);
|
||||
yield { kind: results_1.ResultKind.Failure, errors: [] };
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Setup an abort controller with a builder teardown if no signal is present
|
||||
let signal = context.signal;
|
||||
if (!signal) {
|
||||
const controller = new AbortController();
|
||||
signal = controller.signal;
|
||||
context.addTeardown(() => controller.abort('builder-teardown'));
|
||||
}
|
||||
yield* (0, build_action_1.runEsBuildBuildAction)(async (rebuildState) => {
|
||||
const { serverEntryPoint, jsonLogs, partialSSRBuild } = normalizedOptions;
|
||||
const startTime = process.hrtime.bigint();
|
||||
const result = await (0, execute_build_1.executeBuild)(normalizedOptions, context, rebuildState);
|
||||
if (jsonLogs) {
|
||||
result.addLog(await (0, utils_1.createJsonBuildManifest)(result, normalizedOptions));
|
||||
}
|
||||
else {
|
||||
if (serverEntryPoint && !partialSSRBuild) {
|
||||
const prerenderedRoutesLength = Object.keys(result.prerenderedRoutes).length;
|
||||
let prerenderMsg = `Prerendered ${prerenderedRoutesLength} static route`;
|
||||
prerenderMsg += prerenderedRoutesLength !== 1 ? 's.' : '.';
|
||||
result.addLog(color_1.colors.magenta(prerenderMsg));
|
||||
}
|
||||
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
|
||||
const hasError = result.errors.length > 0;
|
||||
result.addLog(`Application bundle generation ${hasError ? 'failed' : 'complete'}.` +
|
||||
` [${buildTime.toFixed(3)} seconds] - ${new Date().toISOString()}\n`);
|
||||
}
|
||||
return result;
|
||||
}, {
|
||||
watch: normalizedOptions.watch,
|
||||
preserveSymlinks: normalizedOptions.preserveSymlinks,
|
||||
poll: normalizedOptions.poll,
|
||||
cacheOptions: normalizedOptions.cacheOptions,
|
||||
outputOptions: normalizedOptions.outputOptions,
|
||||
verbose: normalizedOptions.verbose,
|
||||
projectRoot: normalizedOptions.projectRoot,
|
||||
workspaceRoot: normalizedOptions.workspaceRoot,
|
||||
progress: normalizedOptions.progress,
|
||||
clearScreen: normalizedOptions.clearScreen,
|
||||
colors: normalizedOptions.colors,
|
||||
jsonLogs: normalizedOptions.jsonLogs,
|
||||
incrementalResults: normalizedOptions.incrementalResults,
|
||||
logger,
|
||||
signal,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Builds an application using the `application` builder with the provided
|
||||
* options.
|
||||
*
|
||||
* Usage of the `extensions` parameter is NOT supported and may cause unexpected
|
||||
* build output or build failures.
|
||||
*
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*
|
||||
* @param options The options defined by the builder's schema to use.
|
||||
* @param context An Architect builder context instance.
|
||||
* @param extensions An object contain extension points for the build.
|
||||
* @returns The build output results of the build.
|
||||
*/
|
||||
async function* buildApplication(options, context, extensions) {
|
||||
let initial = true;
|
||||
const internalOptions = { ...options, incrementalResults: true };
|
||||
for await (const result of buildApplicationInternal(internalOptions, context, extensions)) {
|
||||
const outputOptions = result.detail?.['outputOptions'];
|
||||
if (initial) {
|
||||
initial = false;
|
||||
// Clean the output location if requested.
|
||||
// Output options may not be present if the build failed.
|
||||
if (outputOptions?.clean) {
|
||||
await (0, delete_output_dir_1.deleteOutputDir)(context.workspaceRoot, outputOptions.base, [
|
||||
outputOptions.browser,
|
||||
outputOptions.server,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (result.kind === results_1.ResultKind.Failure) {
|
||||
yield { success: false };
|
||||
continue;
|
||||
}
|
||||
(0, node_assert_1.default)(outputOptions, 'Application output options are required for builder usage.');
|
||||
(0, node_assert_1.default)(result.kind === results_1.ResultKind.Full || result.kind === results_1.ResultKind.Incremental, 'Application build did not provide a file result output.');
|
||||
// TODO: Restructure output logging to better handle stdout JSON piping
|
||||
if (!environment_options_1.useJSONBuildLogs) {
|
||||
context.logger.info(`Output location: ${outputOptions.base}\n`);
|
||||
}
|
||||
// Writes the output files to disk and ensures the containing directories are present
|
||||
const directoryExists = new Set();
|
||||
await (0, utils_1.emitFilesToDisk)(Object.entries(result.files), async ([filePath, file]) => {
|
||||
if (outputOptions.ignoreServer &&
|
||||
(file.type === bundler_context_1.BuildOutputFileType.ServerApplication ||
|
||||
file.type === bundler_context_1.BuildOutputFileType.ServerRoot)) {
|
||||
return;
|
||||
}
|
||||
const fullFilePath = generateFullPath(filePath, file.type, outputOptions);
|
||||
// Ensure output subdirectories exist
|
||||
const fileBasePath = node_path_1.default.dirname(fullFilePath);
|
||||
if (fileBasePath && !directoryExists.has(fileBasePath)) {
|
||||
await promises_1.default.mkdir(fileBasePath, { recursive: true });
|
||||
directoryExists.add(fileBasePath);
|
||||
}
|
||||
if (file.origin === 'memory') {
|
||||
// Write file contents
|
||||
await promises_1.default.writeFile(fullFilePath, file.contents);
|
||||
}
|
||||
else {
|
||||
// Copy file contents
|
||||
if (isNodeV22orHigher) {
|
||||
// Use newer `cp` API on Node.js 22+ (minimum v22 for CLI is 22.11)
|
||||
await promises_1.default.cp(file.inputPath, fullFilePath, {
|
||||
mode: promises_1.default.constants.COPYFILE_FICLONE,
|
||||
preserveTimestamps: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
// For Node.js 20 use `copyFile` (`cp` is not stable for v20)
|
||||
// TODO: Remove when Node.js 20 is no longer supported
|
||||
await promises_1.default.copyFile(file.inputPath, fullFilePath, promises_1.default.constants.COPYFILE_FICLONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Delete any removed files if incremental
|
||||
if (result.kind === results_1.ResultKind.Incremental && result.removed?.length) {
|
||||
await Promise.all(result.removed.map((file) => {
|
||||
const fullFilePath = generateFullPath(file.path, file.type, outputOptions);
|
||||
return promises_1.default.rm(fullFilePath, { force: true, maxRetries: 3 });
|
||||
}));
|
||||
}
|
||||
yield { success: true };
|
||||
}
|
||||
}
|
||||
function generateFullPath(filePath, type, outputOptions) {
|
||||
let typeDirectory;
|
||||
switch (type) {
|
||||
case bundler_context_1.BuildOutputFileType.Browser:
|
||||
case bundler_context_1.BuildOutputFileType.Media:
|
||||
typeDirectory = outputOptions.browser;
|
||||
break;
|
||||
case bundler_context_1.BuildOutputFileType.ServerApplication:
|
||||
case bundler_context_1.BuildOutputFileType.ServerRoot:
|
||||
typeDirectory = outputOptions.server;
|
||||
break;
|
||||
case bundler_context_1.BuildOutputFileType.Root:
|
||||
typeDirectory = '';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unhandled write for file "${filePath}" with type "${bundler_context_1.BuildOutputFileType[type]}".`);
|
||||
}
|
||||
// NOTE: 'base' is a fully resolved path at this point
|
||||
const fullFilePath = node_path_1.default.join(outputOptions.base, typeDirectory, filePath);
|
||||
return fullFilePath;
|
||||
}
|
||||
const builder = (0, architect_1.createBuilder)(buildApplication);
|
||||
exports.default = builder;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+214
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { Plugin } from 'esbuild';
|
||||
import { I18nOptions } from '../../utils/i18n-options';
|
||||
import { IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
||||
import { Schema as ApplicationBuilderOptions, ExperimentalPlatform, I18NTranslation, OutputMode, OutputPathClass } from './schema';
|
||||
/**
|
||||
* The filename for the client-side rendered HTML template.
|
||||
* This template is used for client-side rendering (CSR) in a web application.
|
||||
*/
|
||||
export declare const INDEX_HTML_CSR = "index.csr.html";
|
||||
/**
|
||||
* The filename for the server-side rendered HTML template.
|
||||
* This template is used for server-side rendering (SSR) in a web application.
|
||||
*/
|
||||
export declare const INDEX_HTML_SERVER = "index.server.html";
|
||||
export type NormalizedOutputOptions = Required<OutputPathClass> & {
|
||||
clean: boolean;
|
||||
ignoreServer: boolean;
|
||||
};
|
||||
export type NormalizedApplicationBuildOptions = Awaited<ReturnType<typeof normalizeOptions>>;
|
||||
export interface ApplicationBuilderExtensions {
|
||||
codePlugins?: Plugin[];
|
||||
indexHtmlTransformer?: IndexHtmlTransform;
|
||||
}
|
||||
/** Internal options hidden from builder schema but available when invoked programmatically. */
|
||||
interface InternalOptions {
|
||||
/**
|
||||
* Entry points to use for the compilation. Incompatible with `browser`, which must not be provided. May be relative or absolute paths.
|
||||
* If given a relative path, it is resolved relative to the current workspace and will generate an output at the same relative location
|
||||
* in the output directory. If given an absolute path, the output will be generated in the root of the output directory with the same base
|
||||
* name.
|
||||
*
|
||||
* If provided a Map, the key is the name of the output bundle and the value is the entry point file.
|
||||
*/
|
||||
entryPoints?: Set<string> | Map<string, string>;
|
||||
/** File extension to use for the generated output files. */
|
||||
outExtension?: 'js' | 'mjs';
|
||||
/**
|
||||
* Indicates whether all node packages should be marked as external.
|
||||
* Currently used by the dev-server to support prebundling.
|
||||
*/
|
||||
externalPackages?: boolean | {
|
||||
exclude: string[];
|
||||
};
|
||||
/**
|
||||
* Forces the output from the localize post-processing to not create nested directories per locale output.
|
||||
* This is only used by the development server which currently only supports a single locale per build.
|
||||
*/
|
||||
forceI18nFlatOutput?: boolean;
|
||||
/**
|
||||
* When set to `true`, enables fast SSR in development mode by disabling the full manifest generation and prerendering.
|
||||
*
|
||||
* This option is intended to optimize performance during development by skipping prerendering and route extraction when not required.
|
||||
* @default false
|
||||
*/
|
||||
partialSSRBuild?: boolean;
|
||||
/**
|
||||
* Enables the use of AOT compiler emitted external runtime styles.
|
||||
* External runtime styles use `link` elements instead of embedded style content in the output JavaScript.
|
||||
* This option is only intended to be used with a development server that can process and serve component
|
||||
* styles.
|
||||
*/
|
||||
externalRuntimeStyles?: boolean;
|
||||
/**
|
||||
* Enables the AOT compiler to generate template component update functions.
|
||||
* This option is only intended to be used with a development server that can process and serve component
|
||||
* template updates.
|
||||
*/
|
||||
templateUpdates?: boolean;
|
||||
/**
|
||||
* Enables emitting incremental build results when in watch mode. A full build result will only be emitted
|
||||
* for the initial build. This option also requires watch to be enabled to have an effect.
|
||||
*/
|
||||
incrementalResults?: boolean;
|
||||
/**
|
||||
* Enables instrumentation to collect code coverage data for specific files.
|
||||
*
|
||||
* Used exclusively for tests and shouldn't be used for other kinds of builds.
|
||||
*/
|
||||
instrumentForCoverage?: (filename: string) => boolean;
|
||||
}
|
||||
/** Full set of options for `application` builder. */
|
||||
export type ApplicationBuilderInternalOptions = Omit<ApplicationBuilderOptions & InternalOptions, 'browser'> & {
|
||||
browser?: string;
|
||||
};
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @param plugins An optional array of programmatically supplied build plugins.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
export declare function normalizeOptions(context: BuilderContext, projectName: string, options: ApplicationBuilderInternalOptions, extensions?: ApplicationBuilderExtensions): Promise<{
|
||||
advancedOptimizations: boolean;
|
||||
allowedCommonJsDependencies: string[] | undefined;
|
||||
baseHref: string | undefined;
|
||||
cacheOptions: import("../../utils/normalize-cache").NormalizedCachedOptions;
|
||||
crossOrigin: import("./schema").CrossOrigin | undefined;
|
||||
externalDependencies: string[] | undefined;
|
||||
externalPackages: boolean | {
|
||||
exclude: string[] | undefined;
|
||||
} | undefined;
|
||||
extractLicenses: boolean | undefined;
|
||||
inlineStyleLanguage: string;
|
||||
jit: boolean;
|
||||
stats: boolean;
|
||||
polyfills: string[] | undefined;
|
||||
poll: number | undefined;
|
||||
progress: boolean;
|
||||
preserveSymlinks: boolean;
|
||||
stylePreprocessorOptions: import("./schema").StylePreprocessorOptions | undefined;
|
||||
subresourceIntegrity: boolean | undefined;
|
||||
serverEntryPoint: string | undefined;
|
||||
prerenderOptions: {
|
||||
discoverRoutes: boolean;
|
||||
routesFile: string | undefined;
|
||||
} | undefined;
|
||||
appShellOptions: {
|
||||
route: string;
|
||||
} | undefined;
|
||||
outputMode: OutputMode | undefined;
|
||||
ssrOptions: {
|
||||
entry?: undefined;
|
||||
platform?: undefined;
|
||||
} | {
|
||||
entry: string | undefined;
|
||||
platform: ExperimentalPlatform;
|
||||
} | undefined;
|
||||
verbose: boolean | undefined;
|
||||
watch: boolean | undefined;
|
||||
workspaceRoot: string;
|
||||
entryPoints: Record<string, string>;
|
||||
optimizationOptions: import("../../utils").NormalizedOptimizationOptions;
|
||||
outputOptions: NormalizedOutputOptions;
|
||||
outExtension: "js" | "mjs" | undefined;
|
||||
sourcemapOptions: import("./schema").SourceMapClass;
|
||||
tsconfig: string;
|
||||
projectRoot: string;
|
||||
assets: (import("./schema").AssetPatternClass & {
|
||||
output: string;
|
||||
})[] | undefined;
|
||||
outputNames: {
|
||||
bundles: string;
|
||||
media: string;
|
||||
};
|
||||
fileReplacements: Record<string, string> | undefined;
|
||||
globalStyles: {
|
||||
name: string;
|
||||
files: string[];
|
||||
initial: boolean;
|
||||
}[];
|
||||
globalScripts: {
|
||||
name: string;
|
||||
files: string[];
|
||||
initial: boolean;
|
||||
}[];
|
||||
serviceWorker: string | undefined;
|
||||
indexHtmlOptions: {
|
||||
input: string;
|
||||
output: string;
|
||||
insertionOrder: [string, boolean][];
|
||||
transformer: IndexHtmlTransform | undefined;
|
||||
preloadInitial: boolean;
|
||||
} | undefined;
|
||||
tailwindConfiguration: {
|
||||
file: string;
|
||||
package: string;
|
||||
} | undefined;
|
||||
postcssConfiguration: {
|
||||
configPath: string;
|
||||
config: import("../../utils/postcss-configuration").PostcssConfiguration;
|
||||
} | undefined;
|
||||
i18nOptions: I18nOptions & {
|
||||
duplicateTranslationBehavior?: I18NTranslation;
|
||||
missingTranslationBehavior?: I18NTranslation;
|
||||
};
|
||||
namedChunks: boolean | undefined;
|
||||
budgets: import("./schema").Budget[] | undefined;
|
||||
publicPath: string | undefined;
|
||||
plugins: Plugin[] | undefined;
|
||||
loaderExtensions: Record<string, "file" | "base64" | "binary" | "text" | "dataurl"> | undefined;
|
||||
jsonLogs: boolean;
|
||||
colors: boolean;
|
||||
clearScreen: boolean | undefined;
|
||||
define: {
|
||||
[key: string]: string;
|
||||
} | undefined;
|
||||
partialSSRBuild: boolean;
|
||||
externalRuntimeStyles: boolean | undefined;
|
||||
instrumentForCoverage: ((filename: string) => boolean) | undefined;
|
||||
security: {
|
||||
allowedHosts: string[];
|
||||
autoCsp: {
|
||||
unsafeEval: boolean;
|
||||
} | undefined;
|
||||
};
|
||||
templateUpdates: boolean;
|
||||
incrementalResults: boolean;
|
||||
customConditions: string[] | undefined;
|
||||
frameworkVersion: string;
|
||||
}>;
|
||||
export declare function getLocaleBaseHref(baseHref: string | undefined, i18n: NormalizedApplicationBuildOptions['i18nOptions'], locale: string): string | undefined;
|
||||
export {};
|
||||
+499
@@ -0,0 +1,499 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.INDEX_HTML_SERVER = exports.INDEX_HTML_CSR = void 0;
|
||||
exports.normalizeOptions = normalizeOptions;
|
||||
exports.getLocaleBaseHref = getLocaleBaseHref;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const promises_1 = require("node:fs/promises");
|
||||
const node_module_1 = require("node:module");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const utils_1 = require("../../utils");
|
||||
const color_1 = require("../../utils/color");
|
||||
const environment_options_1 = require("../../utils/environment-options");
|
||||
const i18n_options_1 = require("../../utils/i18n-options");
|
||||
const normalize_cache_1 = require("../../utils/normalize-cache");
|
||||
const postcss_configuration_1 = require("../../utils/postcss-configuration");
|
||||
const project_metadata_1 = require("../../utils/project-metadata");
|
||||
const url_1 = require("../../utils/url");
|
||||
const schema_1 = require("./schema");
|
||||
/**
|
||||
* The filename for the client-side rendered HTML template.
|
||||
* This template is used for client-side rendering (CSR) in a web application.
|
||||
*/
|
||||
exports.INDEX_HTML_CSR = 'index.csr.html';
|
||||
/**
|
||||
* The filename for the server-side rendered HTML template.
|
||||
* This template is used for server-side rendering (SSR) in a web application.
|
||||
*/
|
||||
exports.INDEX_HTML_SERVER = 'index.server.html';
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @param plugins An optional array of programmatically supplied build plugins.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
async function normalizeOptions(context, projectName, options, extensions) {
|
||||
// If not explicitly set, default to the Node.js process argument
|
||||
const preserveSymlinks = options.preserveSymlinks ?? process.execArgv.includes('--preserve-symlinks');
|
||||
// Setup base paths based on workspace root and project information
|
||||
const workspaceRoot = preserveSymlinks
|
||||
? context.workspaceRoot
|
||||
: // NOTE: promises.realpath should not be used here since it uses realpath.native which
|
||||
// can cause case conversion and other undesirable behavior on Windows systems.
|
||||
// ref: https://github.com/nodejs/node/issues/7726
|
||||
(0, node_fs_1.realpathSync)(context.workspaceRoot);
|
||||
const projectMetadata = await context.getProjectMetadata(projectName);
|
||||
const { projectRoot, projectSourceRoot } = (0, project_metadata_1.getProjectRootPaths)(workspaceRoot, projectMetadata);
|
||||
// Gather persistent caching option and provide a project specific cache location
|
||||
const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
|
||||
cacheOptions.path = node_path_1.default.join(cacheOptions.path, projectName);
|
||||
const i18nOptions = (0, i18n_options_1.createI18nOptions)(projectMetadata, options.localize, context.logger, !!options.ssr);
|
||||
i18nOptions.duplicateTranslationBehavior = options.i18nDuplicateTranslation;
|
||||
i18nOptions.missingTranslationBehavior = options.i18nMissingTranslation;
|
||||
if (options.forceI18nFlatOutput) {
|
||||
i18nOptions.flatOutput = true;
|
||||
}
|
||||
const entryPoints = normalizeEntryPoints(workspaceRoot, projectSourceRoot, options.browser, options.entryPoints);
|
||||
const tsconfig = node_path_1.default.join(workspaceRoot, options.tsConfig);
|
||||
const optimizationOptions = (0, utils_1.normalizeOptimization)(options.optimization);
|
||||
const sourcemapOptions = (0, utils_1.normalizeSourceMaps)(options.sourceMap ?? false);
|
||||
const assets = options.assets?.length
|
||||
? (0, utils_1.normalizeAssetPatterns)(options.assets, workspaceRoot, projectRoot, projectSourceRoot)
|
||||
: undefined;
|
||||
let fileReplacements;
|
||||
if (options.fileReplacements) {
|
||||
for (const replacement of options.fileReplacements) {
|
||||
const fileReplaceWith = node_path_1.default.join(workspaceRoot, replacement.with);
|
||||
try {
|
||||
await (0, promises_1.access)(fileReplaceWith, promises_1.constants.F_OK);
|
||||
}
|
||||
catch {
|
||||
throw new Error(`The ${fileReplaceWith} path in file replacements does not exist.`);
|
||||
}
|
||||
fileReplacements ??= {};
|
||||
fileReplacements[node_path_1.default.join(workspaceRoot, replacement.replace)] = fileReplaceWith;
|
||||
}
|
||||
}
|
||||
let loaderExtensions;
|
||||
if (options.loader) {
|
||||
for (const [extension, value] of Object.entries(options.loader)) {
|
||||
if (extension[0] !== '.' || /\.[cm]?[jt]sx?$/.test(extension)) {
|
||||
continue;
|
||||
}
|
||||
if (value !== 'text' &&
|
||||
value !== 'binary' &&
|
||||
value !== 'file' &&
|
||||
value !== 'dataurl' &&
|
||||
value !== 'base64' &&
|
||||
value !== 'empty') {
|
||||
continue;
|
||||
}
|
||||
loaderExtensions ??= {};
|
||||
loaderExtensions[extension] = value;
|
||||
}
|
||||
}
|
||||
// Validate prerender and ssr options when using the outputMode
|
||||
if (options.outputMode === schema_1.OutputMode.Server) {
|
||||
if (!options.server) {
|
||||
throw new Error('The "server" option is required when "outputMode" is set to "server".');
|
||||
}
|
||||
if (typeof options.ssr === 'boolean' || !options.ssr?.entry) {
|
||||
throw new Error('The "ssr.entry" option is required when "outputMode" is set to "server".');
|
||||
}
|
||||
}
|
||||
if (options.outputMode) {
|
||||
if (!options.server) {
|
||||
options.ssr = false;
|
||||
}
|
||||
if (options.prerender !== undefined) {
|
||||
context.logger.warn('The "prerender" option is not considered when "outputMode" is specified.');
|
||||
}
|
||||
options.prerender = !!options.server;
|
||||
if (options.appShell !== undefined) {
|
||||
context.logger.warn('The "appShell" option is not considered when "outputMode" is specified.');
|
||||
}
|
||||
}
|
||||
// A configuration file can exist in the project or workspace root
|
||||
const searchDirectories = await (0, postcss_configuration_1.generateSearchDirectories)([projectRoot, workspaceRoot]);
|
||||
const postcssConfiguration = await (0, postcss_configuration_1.loadPostcssConfiguration)(searchDirectories);
|
||||
// Skip tailwind configuration if postcss is customized
|
||||
const tailwindConfiguration = postcssConfiguration
|
||||
? undefined
|
||||
: await getTailwindConfig(searchDirectories, workspaceRoot, context);
|
||||
let serverEntryPoint;
|
||||
if (typeof options.server === 'string') {
|
||||
if (options.server === '') {
|
||||
throw new Error('The "server" option cannot be an empty string.');
|
||||
}
|
||||
serverEntryPoint = node_path_1.default.join(workspaceRoot, options.server);
|
||||
}
|
||||
let prerenderOptions;
|
||||
if (options.prerender) {
|
||||
const { discoverRoutes = true, routesFile = undefined } = options.prerender === true ? {} : options.prerender;
|
||||
prerenderOptions = {
|
||||
discoverRoutes,
|
||||
routesFile: routesFile && node_path_1.default.join(workspaceRoot, routesFile),
|
||||
};
|
||||
}
|
||||
let ssrOptions;
|
||||
if (options.ssr === true) {
|
||||
ssrOptions = {};
|
||||
}
|
||||
else if (typeof options.ssr === 'object') {
|
||||
const { entry, experimentalPlatform = schema_1.ExperimentalPlatform.Node } = options.ssr;
|
||||
ssrOptions = {
|
||||
entry: entry && node_path_1.default.join(workspaceRoot, entry),
|
||||
platform: experimentalPlatform,
|
||||
};
|
||||
}
|
||||
let appShellOptions;
|
||||
if (options.appShell) {
|
||||
appShellOptions = {
|
||||
route: 'shell',
|
||||
};
|
||||
}
|
||||
const outputPath = options.outputPath ?? node_path_1.default.join(workspaceRoot, 'dist', projectName);
|
||||
const outputOptions = {
|
||||
browser: 'browser',
|
||||
server: 'server',
|
||||
media: 'media',
|
||||
...(typeof outputPath === 'string' ? undefined : outputPath),
|
||||
base: (0, project_metadata_1.normalizeDirectoryPath)(node_path_1.default.resolve(workspaceRoot, typeof outputPath === 'string' ? outputPath : outputPath.base)),
|
||||
clean: options.deleteOutputPath ?? true,
|
||||
// For app-shell and SSG server files are not required by users.
|
||||
// Omit these when SSR is not enabled.
|
||||
ignoreServer: ((ssrOptions === undefined || serverEntryPoint === undefined) &&
|
||||
options.outputMode === undefined) ||
|
||||
options.outputMode === schema_1.OutputMode.Static,
|
||||
};
|
||||
const outputNames = {
|
||||
bundles: options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Bundles
|
||||
? '[name]-[hash]'
|
||||
: '[name]',
|
||||
media: outputOptions.media +
|
||||
(options.outputHashing === schema_1.OutputHashing.All || options.outputHashing === schema_1.OutputHashing.Media
|
||||
? '/[name]-[hash]'
|
||||
: '/[name]'),
|
||||
};
|
||||
const globalStyles = normalizeGlobalEntries(options.styles, 'styles');
|
||||
const globalScripts = normalizeGlobalEntries(options.scripts, 'scripts');
|
||||
let indexHtmlOptions;
|
||||
// index can never have a value of `true` but in the schema it's of type `boolean`.
|
||||
if (typeof options.index !== 'boolean') {
|
||||
let indexInput;
|
||||
let indexOutput;
|
||||
// The output file will be created within the configured output path
|
||||
if (typeof options.index === 'string') {
|
||||
indexInput = indexOutput = node_path_1.default.join(workspaceRoot, options.index);
|
||||
}
|
||||
else if (typeof options.index === 'undefined') {
|
||||
indexInput = node_path_1.default.join(projectSourceRoot, 'index.html');
|
||||
indexOutput = 'index.html';
|
||||
}
|
||||
else {
|
||||
indexInput = node_path_1.default.join(workspaceRoot, options.index.input);
|
||||
indexOutput = options.index.output || 'index.html';
|
||||
}
|
||||
/**
|
||||
* If SSR is activated, create a distinct entry file for the `index.html`.
|
||||
* This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
|
||||
* if it exists (handling SSG).
|
||||
*
|
||||
* For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
|
||||
*
|
||||
* This approach can also be applied to service workers, where the `index.csr.html` is served instead of the prerendered `index.html`.
|
||||
*/
|
||||
const indexBaseName = node_path_1.default.basename(indexOutput);
|
||||
indexOutput =
|
||||
(ssrOptions || prerenderOptions) && indexBaseName === 'index.html'
|
||||
? exports.INDEX_HTML_CSR
|
||||
: indexBaseName;
|
||||
indexHtmlOptions = {
|
||||
input: indexInput,
|
||||
output: indexOutput,
|
||||
insertionOrder: [
|
||||
['polyfills', true],
|
||||
...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
|
||||
...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
|
||||
['main', true],
|
||||
// [name, esm]
|
||||
],
|
||||
transformer: extensions?.indexHtmlTransformer,
|
||||
// Preload initial defaults to true
|
||||
preloadInitial: typeof options.index !== 'object' || (options.index.preloadInitial ?? true),
|
||||
};
|
||||
}
|
||||
if (appShellOptions || ssrOptions || prerenderOptions) {
|
||||
if (!serverEntryPoint) {
|
||||
throw new Error('The "server" option is required when enabling "ssr", "prerender" or "app-shell".');
|
||||
}
|
||||
if (!indexHtmlOptions) {
|
||||
throw new Error('The "index" option cannot be set to false when enabling "ssr", "prerender" or "app-shell".');
|
||||
}
|
||||
}
|
||||
const { autoCsp, allowedHosts = [] } = options.security ?? {};
|
||||
const security = {
|
||||
allowedHosts,
|
||||
autoCsp: autoCsp
|
||||
? {
|
||||
unsafeEval: autoCsp === true ? false : !!autoCsp.unsafeEval,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
// Initial options to keep
|
||||
const { allowedCommonJsDependencies, aot = true, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, outputMode, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, namedChunks, budgets, deployUrl, clearScreen, define, partialSSRBuild = false, externalRuntimeStyles, instrumentForCoverage, } = options;
|
||||
// Return all the normalized options
|
||||
return {
|
||||
advancedOptimizations: !!aot && optimizationOptions.scripts,
|
||||
allowedCommonJsDependencies,
|
||||
baseHref,
|
||||
cacheOptions,
|
||||
crossOrigin,
|
||||
externalDependencies: normalizeExternals(externalDependencies),
|
||||
externalPackages: typeof externalPackages === 'object'
|
||||
? {
|
||||
...externalPackages,
|
||||
exclude: normalizeExternals(externalPackages.exclude),
|
||||
}
|
||||
: externalPackages,
|
||||
extractLicenses,
|
||||
inlineStyleLanguage,
|
||||
jit: !aot,
|
||||
stats: !!statsJson,
|
||||
polyfills: polyfills === undefined || Array.isArray(polyfills) ? polyfills : [polyfills],
|
||||
poll,
|
||||
progress,
|
||||
preserveSymlinks,
|
||||
stylePreprocessorOptions,
|
||||
subresourceIntegrity,
|
||||
serverEntryPoint,
|
||||
prerenderOptions,
|
||||
appShellOptions,
|
||||
outputMode,
|
||||
ssrOptions,
|
||||
verbose,
|
||||
watch,
|
||||
workspaceRoot,
|
||||
entryPoints,
|
||||
optimizationOptions,
|
||||
outputOptions,
|
||||
outExtension,
|
||||
sourcemapOptions,
|
||||
tsconfig,
|
||||
projectRoot,
|
||||
assets,
|
||||
outputNames,
|
||||
fileReplacements,
|
||||
globalStyles,
|
||||
globalScripts,
|
||||
serviceWorker: serviceWorker
|
||||
? node_path_1.default.join(workspaceRoot, typeof serviceWorker === 'string' ? serviceWorker : 'src/ngsw-config.json')
|
||||
: undefined,
|
||||
indexHtmlOptions,
|
||||
tailwindConfiguration,
|
||||
postcssConfiguration,
|
||||
i18nOptions,
|
||||
namedChunks,
|
||||
budgets: budgets?.length ? budgets : undefined,
|
||||
publicPath: deployUrl,
|
||||
plugins: extensions?.codePlugins?.length ? extensions?.codePlugins : undefined,
|
||||
loaderExtensions,
|
||||
jsonLogs: environment_options_1.useJSONBuildLogs,
|
||||
colors: (0, color_1.supportColor)(),
|
||||
clearScreen,
|
||||
define,
|
||||
partialSSRBuild: environment_options_1.usePartialSsrBuild || partialSSRBuild,
|
||||
externalRuntimeStyles: aot && externalRuntimeStyles,
|
||||
instrumentForCoverage,
|
||||
security,
|
||||
templateUpdates: !!options.templateUpdates,
|
||||
incrementalResults: !!options.incrementalResults,
|
||||
customConditions: options.conditions,
|
||||
frameworkVersion: await findFrameworkVersion(projectRoot),
|
||||
};
|
||||
}
|
||||
async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
|
||||
const tailwindConfigurationPath = (0, postcss_configuration_1.findTailwindConfiguration)(searchDirectories);
|
||||
if (!tailwindConfigurationPath) {
|
||||
return undefined;
|
||||
}
|
||||
// Create a node resolver from the configuration file
|
||||
const resolver = (0, node_module_1.createRequire)(tailwindConfigurationPath);
|
||||
try {
|
||||
return {
|
||||
file: tailwindConfigurationPath,
|
||||
package: resolver.resolve('tailwindcss'),
|
||||
};
|
||||
}
|
||||
catch {
|
||||
const relativeTailwindConfigPath = node_path_1.default.relative(workspaceRoot, tailwindConfigurationPath);
|
||||
context.logger.warn(`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
|
||||
` but the 'tailwindcss' package is not installed.` +
|
||||
` To enable Tailwind CSS, please install the 'tailwindcss' package.`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Normalize entry point options. To maintain compatibility with the legacy browser builder, we need a single `browser`
|
||||
* option which defines a single entry point. However, we also want to support multiple entry points as an internal option.
|
||||
* The two options are mutually exclusive and if `browser` is provided it will be used as the sole entry point.
|
||||
* If `entryPoints` are provided, they will be used as the set of entry points.
|
||||
*
|
||||
* @param workspaceRoot Path to the root of the Angular workspace.
|
||||
* @param browser The `browser` option pointing at the application entry point. While required per the schema file, it may be omitted by
|
||||
* programmatic usages of `browser-esbuild`.
|
||||
* @param entryPoints Set of entry points to use if provided.
|
||||
* @returns An object mapping entry point names to their file paths.
|
||||
*/
|
||||
function normalizeEntryPoints(workspaceRoot, projectSourceRoot, browser, entryPoints) {
|
||||
if (browser === '') {
|
||||
throw new Error('`browser` option cannot be an empty string.');
|
||||
}
|
||||
// `browser` and `entryPoints` are mutually exclusive.
|
||||
if (browser && entryPoints) {
|
||||
throw new Error('Only one of `browser` or `entryPoints` may be provided.');
|
||||
}
|
||||
if (browser) {
|
||||
// Use `browser` alone.
|
||||
return { 'main': node_path_1.default.join(workspaceRoot, browser) };
|
||||
}
|
||||
else if (!entryPoints) {
|
||||
// Default browser entry if no explicit entry points
|
||||
return { 'main': node_path_1.default.join(projectSourceRoot, 'main.ts') };
|
||||
}
|
||||
else if (entryPoints instanceof Map) {
|
||||
return Object.fromEntries(Array.from(entryPoints.entries(), ([name, entryPoint]) => {
|
||||
// Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
|
||||
const isRelativePath = entryPoint.startsWith('.');
|
||||
const entryPointPath = isRelativePath ? node_path_1.default.join(workspaceRoot, entryPoint) : entryPoint;
|
||||
return [name, entryPointPath];
|
||||
}));
|
||||
}
|
||||
else {
|
||||
// Use `entryPoints` alone.
|
||||
const entryPointPaths = {};
|
||||
for (const entryPoint of entryPoints) {
|
||||
const parsedEntryPoint = node_path_1.default.parse(entryPoint);
|
||||
// Use the input file path without an extension as the "name" of the entry point dictating its output location.
|
||||
// Relative entry points are generated at the same relative path in the output directory.
|
||||
// Absolute entry points are always generated with the same file name in the root of the output directory. This includes absolute
|
||||
// paths pointing at files actually within the workspace root.
|
||||
const entryPointName = node_path_1.default.isAbsolute(entryPoint)
|
||||
? parsedEntryPoint.name
|
||||
: node_path_1.default.join(parsedEntryPoint.dir, parsedEntryPoint.name);
|
||||
// Get the full file path to a relative entry point input. Leave bare specifiers alone so they are resolved as modules.
|
||||
const isRelativePath = entryPoint.startsWith('.');
|
||||
const entryPointPath = isRelativePath ? node_path_1.default.join(workspaceRoot, entryPoint) : entryPoint;
|
||||
// Check for conflicts with previous entry points.
|
||||
const existingEntryPointPath = entryPointPaths[entryPointName];
|
||||
if (existingEntryPointPath) {
|
||||
throw new Error(`\`${existingEntryPointPath}\` and \`${entryPointPath}\` both output to the same location \`${entryPointName}\`.` +
|
||||
' Rename or move one of the files to fix the conflict.');
|
||||
}
|
||||
entryPointPaths[entryPointName] = entryPointPath;
|
||||
}
|
||||
return entryPointPaths;
|
||||
}
|
||||
}
|
||||
function normalizeGlobalEntries(rawEntries, defaultName) {
|
||||
if (!rawEntries?.length) {
|
||||
return [];
|
||||
}
|
||||
const bundles = new Map();
|
||||
for (const rawEntry of rawEntries) {
|
||||
let entry;
|
||||
if (typeof rawEntry === 'string') {
|
||||
// string entries use default bundle name and inject values
|
||||
entry = { input: rawEntry };
|
||||
}
|
||||
else {
|
||||
entry = rawEntry;
|
||||
}
|
||||
const { bundleName, input, inject = true } = entry;
|
||||
// Non-injected entries default to the file name
|
||||
const name = bundleName || (inject ? defaultName : node_path_1.default.basename(input, node_path_1.default.extname(input)));
|
||||
const existing = bundles.get(name);
|
||||
if (!existing) {
|
||||
bundles.set(name, { name, files: [input], initial: inject });
|
||||
continue;
|
||||
}
|
||||
if (existing.initial !== inject) {
|
||||
throw new Error(`The "${name}" bundle is mixing injected and non-injected entries. ` +
|
||||
'Verify that the project options are correct.');
|
||||
}
|
||||
existing.files.push(input);
|
||||
}
|
||||
return [...bundles.values()];
|
||||
}
|
||||
function getLocaleBaseHref(baseHref = '', i18n, locale) {
|
||||
if (i18n.flatOutput) {
|
||||
return undefined;
|
||||
}
|
||||
const localeData = i18n.locales[locale];
|
||||
if (!localeData) {
|
||||
return undefined;
|
||||
}
|
||||
const baseHrefSuffix = localeData.baseHref ?? localeData.subPath + '/';
|
||||
let joinedBaseHref;
|
||||
if (baseHrefSuffix !== '') {
|
||||
joinedBaseHref = (0, url_1.addTrailingSlash)((0, url_1.joinUrlParts)(baseHref, baseHrefSuffix));
|
||||
if (baseHref && baseHref[0] !== '/') {
|
||||
joinedBaseHref = (0, url_1.stripLeadingSlash)(joinedBaseHref);
|
||||
}
|
||||
}
|
||||
return joinedBaseHref;
|
||||
}
|
||||
/**
|
||||
* Normalizes an array of external dependency paths by ensuring that
|
||||
* wildcard patterns (`/*`) are removed from package names.
|
||||
*
|
||||
* This avoids the need to handle this normalization repeatedly in our plugins,
|
||||
* as esbuild already treats `--external:@foo/bar` as implicitly including
|
||||
* `--external:@foo/bar/*`. By standardizing the input, we ensure consistency
|
||||
* and reduce redundant checks across our plugins.
|
||||
*
|
||||
* @param value - An optional array of dependency paths to normalize.
|
||||
* @returns A new array with wildcard patterns removed from package names, or `undefined` if input is `undefined`.
|
||||
*/
|
||||
function normalizeExternals(value) {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
return [
|
||||
...new Set(value.map((d) =>
|
||||
// remove "/*" wildcard in the end if provided string is not path-like
|
||||
d.endsWith('/*') && !/^\.{0,2}\//.test(d) ? d.slice(0, -2) : d)),
|
||||
];
|
||||
}
|
||||
async function findFrameworkVersion(projectRoot) {
|
||||
// Create a custom require function for ESM compliance.
|
||||
// NOTE: The trailing slash is significant.
|
||||
const projectResolve = (0, node_module_1.createRequire)(projectRoot + '/').resolve;
|
||||
try {
|
||||
const manifestPath = projectResolve('@angular/core/package.json');
|
||||
const manifestData = await (0, promises_1.readFile)(manifestPath, 'utf-8');
|
||||
const manifestObject = JSON.parse(manifestData);
|
||||
const version = manifestObject.version;
|
||||
return version;
|
||||
}
|
||||
catch {
|
||||
throw new Error('Error: It appears that "@angular/core" is missing as a dependency. Please ensure it is included in your project.');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=options.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @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 { BuildOutputFileType } from '../../tools/esbuild/bundler-context';
|
||||
export declare enum ResultKind {
|
||||
Failure = 0,
|
||||
Full = 1,
|
||||
Incremental = 2,
|
||||
ComponentUpdate = 3
|
||||
}
|
||||
export type Result = FailureResult | FullResult | IncrementalResult | ComponentUpdateResult;
|
||||
export interface BaseResult {
|
||||
kind: ResultKind;
|
||||
warnings?: ResultMessage[];
|
||||
duration?: number;
|
||||
detail?: Record<string, unknown>;
|
||||
}
|
||||
export interface FailureResult extends BaseResult {
|
||||
kind: ResultKind.Failure;
|
||||
errors: ResultMessage[];
|
||||
}
|
||||
export interface FullResult extends BaseResult {
|
||||
kind: ResultKind.Full;
|
||||
files: Record<string, ResultFile>;
|
||||
}
|
||||
export interface IncrementalResult extends BaseResult {
|
||||
kind: ResultKind.Incremental;
|
||||
background?: boolean;
|
||||
added: string[];
|
||||
removed: {
|
||||
path: string;
|
||||
type: BuildOutputFileType;
|
||||
}[];
|
||||
modified: string[];
|
||||
files: Record<string, ResultFile>;
|
||||
}
|
||||
export type ResultFile = DiskFile | MemoryFile;
|
||||
export interface BaseResultFile {
|
||||
origin: 'memory' | 'disk';
|
||||
type: BuildOutputFileType;
|
||||
}
|
||||
export interface DiskFile extends BaseResultFile {
|
||||
origin: 'disk';
|
||||
inputPath: string;
|
||||
}
|
||||
export interface MemoryFile extends BaseResultFile {
|
||||
origin: 'memory';
|
||||
hash: string;
|
||||
contents: Uint8Array;
|
||||
}
|
||||
export interface ResultMessage {
|
||||
text: string;
|
||||
location?: {
|
||||
file: string;
|
||||
line: number;
|
||||
column: number;
|
||||
} | null;
|
||||
notes?: {
|
||||
text: string;
|
||||
}[];
|
||||
}
|
||||
export interface ComponentUpdateResult extends BaseResult {
|
||||
kind: ResultKind.ComponentUpdate;
|
||||
updates: {
|
||||
id: string;
|
||||
type: 'style' | 'template';
|
||||
content: string;
|
||||
}[];
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ResultKind = void 0;
|
||||
var ResultKind;
|
||||
(function (ResultKind) {
|
||||
ResultKind[ResultKind["Failure"] = 0] = "Failure";
|
||||
ResultKind[ResultKind["Full"] = 1] = "Full";
|
||||
ResultKind[ResultKind["Incremental"] = 2] = "Incremental";
|
||||
ResultKind[ResultKind["ComponentUpdate"] = 3] = "ComponentUpdate";
|
||||
})(ResultKind || (exports.ResultKind = ResultKind = {}));
|
||||
//# sourceMappingURL=results.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"results.js","sourceRoot":"","sources":["results.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,iDAAO,CAAA;IACP,2CAAI,CAAA;IACJ,yDAAW,CAAA;IACX,iEAAe,CAAA;AACjB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
|
||||
+650
@@ -0,0 +1,650 @@
|
||||
/**
|
||||
* Application builder target options
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* A list of CommonJS or AMD packages that are allowed to be used without a build time
|
||||
* warning. Use `'*'` to allow all.
|
||||
*/
|
||||
allowedCommonJsDependencies?: string[];
|
||||
/**
|
||||
* Build using Ahead of Time compilation.
|
||||
*/
|
||||
aot?: boolean;
|
||||
/**
|
||||
* Generates an application shell during build time.
|
||||
*/
|
||||
appShell?: boolean;
|
||||
/**
|
||||
* Define the assets to be copied to the output directory. These assets are copied as-is
|
||||
* without any further processing or hashing.
|
||||
*/
|
||||
assets?: AssetPattern[];
|
||||
/**
|
||||
* Base url for the application being built.
|
||||
*/
|
||||
baseHref?: string;
|
||||
/**
|
||||
* The full path for the browser entry point to the application, relative to the current
|
||||
* workspace.
|
||||
*/
|
||||
browser?: string;
|
||||
/**
|
||||
* Budget thresholds to ensure parts of your application stay within boundaries which you
|
||||
* set.
|
||||
*/
|
||||
budgets?: Budget[];
|
||||
/**
|
||||
* Automatically clear the terminal screen during rebuilds.
|
||||
*/
|
||||
clearScreen?: boolean;
|
||||
/**
|
||||
* Custom package resolution conditions used to resolve conditional exports/imports.
|
||||
* Defaults to ['module', 'development'/'production']. The following special conditions are
|
||||
* always present if the requirements are satisfied: 'default', 'import', 'require',
|
||||
* 'browser', 'node'.
|
||||
*/
|
||||
conditions?: string[];
|
||||
/**
|
||||
* Define the crossorigin attribute setting of elements that provide CORS support.
|
||||
*/
|
||||
crossOrigin?: CrossOrigin;
|
||||
/**
|
||||
* Defines global identifiers that will be replaced with a specified constant value when
|
||||
* found in any JavaScript or TypeScript code including libraries. The value will be used
|
||||
* directly. String values must be put in quotes. Identifiers within Angular metadata such
|
||||
* as Component Decorators will not be replaced.
|
||||
*/
|
||||
define?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* Delete the output path before building.
|
||||
*/
|
||||
deleteOutputPath?: boolean;
|
||||
/**
|
||||
* Customize the base path for the URLs of resources in 'index.html' and component
|
||||
* stylesheets. This option is only necessary for specific deployment scenarios, such as
|
||||
* with Angular Elements or when utilizing different CDN locations.
|
||||
*/
|
||||
deployUrl?: string;
|
||||
/**
|
||||
* Exclude the listed external dependencies from being bundled into the bundle. Instead, the
|
||||
* created bundle relies on these dependencies to be available during runtime. Note:
|
||||
* `@foo/bar` marks all paths within the `@foo/bar` package as external, including sub-paths
|
||||
* like `@foo/bar/baz`.
|
||||
*/
|
||||
externalDependencies?: string[];
|
||||
/**
|
||||
* Extract all licenses in a separate file.
|
||||
*/
|
||||
extractLicenses?: boolean;
|
||||
/**
|
||||
* Replace compilation source files with other compilation source files in the build.
|
||||
*/
|
||||
fileReplacements?: FileReplacement[];
|
||||
/**
|
||||
* How to handle duplicate translations for i18n.
|
||||
*/
|
||||
i18nDuplicateTranslation?: I18NTranslation;
|
||||
/**
|
||||
* How to handle missing translations for i18n.
|
||||
*/
|
||||
i18nMissingTranslation?: I18NTranslation;
|
||||
/**
|
||||
* Configures the generation of the application's HTML index.
|
||||
*/
|
||||
index?: IndexUnion;
|
||||
/**
|
||||
* The stylesheet language to use for the application's inline component styles.
|
||||
*/
|
||||
inlineStyleLanguage?: InlineStyleLanguage;
|
||||
/**
|
||||
* Defines the type of loader to use with a specified file extension when used with a
|
||||
* JavaScript `import`. `text` inlines the content as a string; `binary` inlines the content
|
||||
* as a Uint8Array; `file` emits the file and provides the runtime location of the file;
|
||||
* `dataurl` inlines the content as a data URL with best guess of MIME type; `base64`
|
||||
* inlines the content as a Base64-encoded string; `empty` considers the content to be empty
|
||||
* and not include it in bundles.
|
||||
*/
|
||||
loader?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* Translate the bundles in one or more locales.
|
||||
*/
|
||||
localize?: Localize;
|
||||
/**
|
||||
* Use file name for lazy loaded chunks.
|
||||
*/
|
||||
namedChunks?: boolean;
|
||||
/**
|
||||
* Enables optimization of the build output. Including minification of scripts and styles,
|
||||
* tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For
|
||||
* more information, see
|
||||
* https://angular.dev/reference/configs/workspace-config#optimization-configuration.
|
||||
*/
|
||||
optimization?: OptimizationUnion;
|
||||
/**
|
||||
* Define the output filename cache-busting hashing mode.
|
||||
*
|
||||
* - `none`: No hashing.
|
||||
* - `all`: Hash for all output bundles.
|
||||
* - `media`: Hash for all output media (e.g., images, fonts, etc. that are referenced in
|
||||
* CSS files).
|
||||
* - `bundles`: Hash for output of lazy and main bundles.
|
||||
*/
|
||||
outputHashing?: OutputHashing;
|
||||
/**
|
||||
* Defines the type of build output artifact. 'static': Generates a static site build
|
||||
* artifact for deployment on any static hosting service. 'server': Generates a server
|
||||
* application build artifact, required for applications using hybrid rendering or APIs.
|
||||
*/
|
||||
outputMode?: OutputMode;
|
||||
/**
|
||||
* Specify the output path relative to workspace root.
|
||||
*/
|
||||
outputPath?: OutputPathUnion;
|
||||
/**
|
||||
* Enable and define the file watching poll time period in milliseconds.
|
||||
*/
|
||||
poll?: number;
|
||||
/**
|
||||
* A list of polyfills to include in the build. Can be a full path for a file, relative to
|
||||
* the current workspace or module specifier. Example: 'zone.js'.
|
||||
*/
|
||||
polyfills?: string[];
|
||||
/**
|
||||
* Prerender (SSG) pages of your application during build time.
|
||||
*/
|
||||
prerender?: PrerenderUnion;
|
||||
/**
|
||||
* Do not use the real path when resolving modules. If unset then will default to `true` if
|
||||
* NodeJS option --preserve-symlinks is set.
|
||||
*/
|
||||
preserveSymlinks?: boolean;
|
||||
/**
|
||||
* Log progress to the console while building.
|
||||
*/
|
||||
progress?: boolean;
|
||||
/**
|
||||
* Global scripts to be included in the build.
|
||||
*/
|
||||
scripts?: ScriptElement[];
|
||||
/**
|
||||
* Security features to protect against XSS and other common attacks
|
||||
*/
|
||||
security?: Security;
|
||||
/**
|
||||
* The full path for the server entry point to the application, relative to the current
|
||||
* workspace.
|
||||
*/
|
||||
server?: Serv;
|
||||
/**
|
||||
* Generates a service worker configuration.
|
||||
*/
|
||||
serviceWorker?: Serv;
|
||||
/**
|
||||
* Output source maps for scripts and styles. For more information, see
|
||||
* https://angular.dev/reference/configs/workspace-config#source-map-configuration.
|
||||
*/
|
||||
sourceMap?: SourceMapUnion;
|
||||
/**
|
||||
* Server side render (SSR) pages of your application during runtime.
|
||||
*/
|
||||
ssr?: SsrUnion;
|
||||
/**
|
||||
* Generates a 'stats.json' file which can be analyzed with
|
||||
* https://esbuild.github.io/analyze/.
|
||||
*/
|
||||
statsJson?: boolean;
|
||||
/**
|
||||
* Options to pass to style preprocessors.
|
||||
*/
|
||||
stylePreprocessorOptions?: StylePreprocessorOptions;
|
||||
/**
|
||||
* Global styles to be included in the build.
|
||||
*/
|
||||
styles?: StyleElement[];
|
||||
/**
|
||||
* Enables the use of subresource integrity validation.
|
||||
*/
|
||||
subresourceIntegrity?: boolean;
|
||||
/**
|
||||
* The full path for the TypeScript configuration file, relative to the current workspace.
|
||||
*/
|
||||
tsConfig: string;
|
||||
/**
|
||||
* Adds more details to output logging.
|
||||
*/
|
||||
verbose?: boolean;
|
||||
/**
|
||||
* Run build when files change.
|
||||
*/
|
||||
watch?: boolean;
|
||||
/**
|
||||
* TypeScript configuration for Web Worker modules.
|
||||
*/
|
||||
webWorkerTsConfig?: string;
|
||||
};
|
||||
export type AssetPattern = AssetPatternClass | string;
|
||||
export type AssetPatternClass = {
|
||||
/**
|
||||
* Allow glob patterns to follow symlink directories. This allows subdirectories of the
|
||||
* symlink to be searched.
|
||||
*/
|
||||
followSymlinks?: boolean;
|
||||
/**
|
||||
* The pattern to match.
|
||||
*/
|
||||
glob: string;
|
||||
/**
|
||||
* An array of globs to ignore.
|
||||
*/
|
||||
ignore?: string[];
|
||||
/**
|
||||
* The input directory path in which to apply 'glob'. Defaults to the project root.
|
||||
*/
|
||||
input: string;
|
||||
/**
|
||||
* Absolute path within the output.
|
||||
*/
|
||||
output?: string;
|
||||
};
|
||||
export type Budget = {
|
||||
/**
|
||||
* The baseline size for comparison.
|
||||
*/
|
||||
baseline?: string;
|
||||
/**
|
||||
* The threshold for error relative to the baseline (min & max).
|
||||
*/
|
||||
error?: string;
|
||||
/**
|
||||
* The maximum threshold for error relative to the baseline.
|
||||
*/
|
||||
maximumError?: string;
|
||||
/**
|
||||
* The maximum threshold for warning relative to the baseline.
|
||||
*/
|
||||
maximumWarning?: string;
|
||||
/**
|
||||
* The minimum threshold for error relative to the baseline.
|
||||
*/
|
||||
minimumError?: string;
|
||||
/**
|
||||
* The minimum threshold for warning relative to the baseline.
|
||||
*/
|
||||
minimumWarning?: string;
|
||||
/**
|
||||
* The name of the bundle.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* The type of budget.
|
||||
*/
|
||||
type: Type;
|
||||
/**
|
||||
* The threshold for warning relative to the baseline (min & max).
|
||||
*/
|
||||
warning?: string;
|
||||
};
|
||||
/**
|
||||
* The type of budget.
|
||||
*/
|
||||
export declare enum Type {
|
||||
All = "all",
|
||||
AllScript = "allScript",
|
||||
Any = "any",
|
||||
AnyComponentStyle = "anyComponentStyle",
|
||||
AnyScript = "anyScript",
|
||||
Bundle = "bundle",
|
||||
Initial = "initial"
|
||||
}
|
||||
/**
|
||||
* Define the crossorigin attribute setting of elements that provide CORS support.
|
||||
*/
|
||||
export declare enum CrossOrigin {
|
||||
Anonymous = "anonymous",
|
||||
None = "none",
|
||||
UseCredentials = "use-credentials"
|
||||
}
|
||||
export type FileReplacement = {
|
||||
replace: string;
|
||||
with: string;
|
||||
};
|
||||
/**
|
||||
* How to handle duplicate translations for i18n.
|
||||
*
|
||||
* How to handle missing translations for i18n.
|
||||
*/
|
||||
export declare enum I18NTranslation {
|
||||
Error = "error",
|
||||
Ignore = "ignore",
|
||||
Warning = "warning"
|
||||
}
|
||||
/**
|
||||
* Configures the generation of the application's HTML index.
|
||||
*/
|
||||
export type IndexUnion = boolean | IndexObject | string;
|
||||
export type IndexObject = {
|
||||
/**
|
||||
* The path of a file to use for the application's generated HTML index.
|
||||
*/
|
||||
input: string;
|
||||
/**
|
||||
* The output path of the application's generated HTML index file. The full provided path
|
||||
* will be used and will be considered relative to the application's configured output path.
|
||||
*/
|
||||
output?: string;
|
||||
/**
|
||||
* Generates 'preload', 'modulepreload', and 'preconnect' link elements for initial
|
||||
* application files and resources.
|
||||
*/
|
||||
preloadInitial?: boolean;
|
||||
[property: string]: any;
|
||||
};
|
||||
/**
|
||||
* The stylesheet language to use for the application's inline component styles.
|
||||
*/
|
||||
export declare enum InlineStyleLanguage {
|
||||
Css = "css",
|
||||
Less = "less",
|
||||
Sass = "sass",
|
||||
Scss = "scss"
|
||||
}
|
||||
/**
|
||||
* Translate the bundles in one or more locales.
|
||||
*/
|
||||
export type Localize = string[] | boolean;
|
||||
/**
|
||||
* Enables optimization of the build output. Including minification of scripts and styles,
|
||||
* tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For
|
||||
* more information, see
|
||||
* https://angular.dev/reference/configs/workspace-config#optimization-configuration.
|
||||
*/
|
||||
export type OptimizationUnion = boolean | OptimizationClass;
|
||||
export type OptimizationClass = {
|
||||
/**
|
||||
* Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY`
|
||||
* environment variable can be used to specify a proxy server.
|
||||
*/
|
||||
fonts?: FontsUnion;
|
||||
/**
|
||||
* Enables optimization of the scripts output.
|
||||
*/
|
||||
scripts?: boolean;
|
||||
/**
|
||||
* Enables optimization of the styles output.
|
||||
*/
|
||||
styles?: StylesUnion;
|
||||
};
|
||||
/**
|
||||
* Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY`
|
||||
* environment variable can be used to specify a proxy server.
|
||||
*/
|
||||
export type FontsUnion = boolean | FontsClass;
|
||||
export type FontsClass = {
|
||||
/**
|
||||
* Reduce render blocking requests by inlining external Google Fonts and Adobe Fonts CSS
|
||||
* definitions in the application's HTML index file. This option requires internet access.
|
||||
* `HTTPS_PROXY` environment variable can be used to specify a proxy server.
|
||||
*/
|
||||
inline?: boolean;
|
||||
};
|
||||
/**
|
||||
* Enables optimization of the styles output.
|
||||
*/
|
||||
export type StylesUnion = boolean | StylesClass;
|
||||
export type StylesClass = {
|
||||
/**
|
||||
* Extract and inline critical CSS definitions to improve first paint time.
|
||||
*/
|
||||
inlineCritical?: boolean;
|
||||
/**
|
||||
* Minify CSS definitions by removing extraneous whitespace and comments, merging
|
||||
* identifiers and minimizing values.
|
||||
*/
|
||||
minify?: boolean;
|
||||
/**
|
||||
* Remove comments in global CSS that contains '@license' or '@preserve' or that starts with
|
||||
* '//!' or '/*!'.
|
||||
*/
|
||||
removeSpecialComments?: boolean;
|
||||
};
|
||||
/**
|
||||
* Define the output filename cache-busting hashing mode.
|
||||
*
|
||||
* - `none`: No hashing.
|
||||
* - `all`: Hash for all output bundles.
|
||||
* - `media`: Hash for all output media (e.g., images, fonts, etc. that are referenced in
|
||||
* CSS files).
|
||||
* - `bundles`: Hash for output of lazy and main bundles.
|
||||
*/
|
||||
export declare enum OutputHashing {
|
||||
All = "all",
|
||||
Bundles = "bundles",
|
||||
Media = "media",
|
||||
None = "none"
|
||||
}
|
||||
/**
|
||||
* Defines the type of build output artifact. 'static': Generates a static site build
|
||||
* artifact for deployment on any static hosting service. 'server': Generates a server
|
||||
* application build artifact, required for applications using hybrid rendering or APIs.
|
||||
*/
|
||||
export declare enum OutputMode {
|
||||
Server = "server",
|
||||
Static = "static"
|
||||
}
|
||||
/**
|
||||
* Specify the output path relative to workspace root.
|
||||
*/
|
||||
export type OutputPathUnion = OutputPathClass | string;
|
||||
export type OutputPathClass = {
|
||||
/**
|
||||
* Specify the output path relative to workspace root.
|
||||
*/
|
||||
base: string;
|
||||
/**
|
||||
* The output directory name of your browser build within the output path base. Defaults to
|
||||
* 'browser'.
|
||||
*/
|
||||
browser?: string;
|
||||
/**
|
||||
* The output directory name of your media files within the output browser directory.
|
||||
* Defaults to 'media'.
|
||||
*/
|
||||
media?: string;
|
||||
/**
|
||||
* The output directory name of your server build within the output path base. Defaults to
|
||||
* 'server'.
|
||||
*/
|
||||
server?: string;
|
||||
};
|
||||
/**
|
||||
* Prerender (SSG) pages of your application during build time.
|
||||
*/
|
||||
export type PrerenderUnion = boolean | PrerenderClass;
|
||||
export type PrerenderClass = {
|
||||
/**
|
||||
* Whether the builder should process the Angular Router configuration to find all
|
||||
* unparameterized routes and prerender them.
|
||||
*/
|
||||
discoverRoutes?: boolean;
|
||||
/**
|
||||
* The path to a file that contains a list of all routes to prerender, separated by
|
||||
* newlines. This option is useful if you want to prerender routes with parameterized URLs.
|
||||
*/
|
||||
routesFile?: string;
|
||||
};
|
||||
export type ScriptElement = ScriptClass | string;
|
||||
export type ScriptClass = {
|
||||
/**
|
||||
* The bundle name for this extra entry point.
|
||||
*/
|
||||
bundleName?: string;
|
||||
/**
|
||||
* If the bundle will be referenced in the HTML file.
|
||||
*/
|
||||
inject?: boolean;
|
||||
/**
|
||||
* The file to include.
|
||||
*/
|
||||
input: string;
|
||||
};
|
||||
/**
|
||||
* Security features to protect against XSS and other common attacks
|
||||
*/
|
||||
export type Security = {
|
||||
/**
|
||||
* A list of hostnames that are allowed to access the server-side application. For more
|
||||
* information, see
|
||||
* https://angular.dev/best-practices/security#preventing-server-side-request-forgery-ssrf.
|
||||
*/
|
||||
allowedHosts?: string[];
|
||||
/**
|
||||
* Enables automatic generation of a hash-based Strict Content Security Policy
|
||||
* (https://web.dev/articles/strict-csp#choose-hash) based on scripts in index.html. Will
|
||||
* default to true once we are out of experimental/preview phases.
|
||||
*/
|
||||
autoCsp?: AutoCspUnion;
|
||||
};
|
||||
/**
|
||||
* Enables automatic generation of a hash-based Strict Content Security Policy
|
||||
* (https://web.dev/articles/strict-csp#choose-hash) based on scripts in index.html. Will
|
||||
* default to true once we are out of experimental/preview phases.
|
||||
*/
|
||||
export type AutoCspUnion = boolean | AutoCspClass;
|
||||
export type AutoCspClass = {
|
||||
/**
|
||||
* Include the `unsafe-eval` directive (https://web.dev/articles/strict-csp#remove-eval) in
|
||||
* the auto-CSP. Please only enable this if you are absolutely sure that you need to, as
|
||||
* allowing calls to eval will weaken the XSS defenses provided by the auto-CSP.
|
||||
*/
|
||||
unsafeEval?: boolean;
|
||||
};
|
||||
/**
|
||||
* The full path for the server entry point to the application, relative to the current
|
||||
* workspace.
|
||||
*
|
||||
* Generates a service worker configuration.
|
||||
*/
|
||||
export type Serv = boolean | string;
|
||||
/**
|
||||
* Output source maps for scripts and styles. For more information, see
|
||||
* https://angular.dev/reference/configs/workspace-config#source-map-configuration.
|
||||
*/
|
||||
export type SourceMapUnion = boolean | SourceMapClass;
|
||||
export type SourceMapClass = {
|
||||
/**
|
||||
* Output source maps used for error reporting tools.
|
||||
*/
|
||||
hidden?: boolean;
|
||||
/**
|
||||
* Output source maps for all scripts.
|
||||
*/
|
||||
scripts?: boolean;
|
||||
/**
|
||||
* Output original source content for files within the source map.
|
||||
*/
|
||||
sourcesContent?: boolean;
|
||||
/**
|
||||
* Output source maps for all styles.
|
||||
*/
|
||||
styles?: boolean;
|
||||
/**
|
||||
* Resolve vendor packages source maps.
|
||||
*/
|
||||
vendor?: boolean;
|
||||
};
|
||||
/**
|
||||
* Server side render (SSR) pages of your application during runtime.
|
||||
*/
|
||||
export type SsrUnion = boolean | SsrClass;
|
||||
export type SsrClass = {
|
||||
/**
|
||||
* The server entry-point that when executed will spawn the web server.
|
||||
*/
|
||||
entry?: string;
|
||||
/**
|
||||
* Specifies the platform for which the server bundle is generated. This affects the APIs
|
||||
* and modules available in the server-side code.
|
||||
*
|
||||
* - `node`: (Default) Generates a bundle optimized for Node.js environments.
|
||||
* - `neutral`: Generates a platform-neutral bundle suitable for environments like edge
|
||||
* workers, and other serverless platforms. This option avoids using Node.js-specific APIs,
|
||||
* making the bundle more portable.
|
||||
*
|
||||
* Please note that this feature does not provide polyfills for Node.js modules.
|
||||
* Additionally, it is experimental, and the schematics may undergo changes in future
|
||||
* versions.
|
||||
*/
|
||||
experimentalPlatform?: ExperimentalPlatform;
|
||||
};
|
||||
/**
|
||||
* Specifies the platform for which the server bundle is generated. This affects the APIs
|
||||
* and modules available in the server-side code.
|
||||
*
|
||||
* - `node`: (Default) Generates a bundle optimized for Node.js environments.
|
||||
* - `neutral`: Generates a platform-neutral bundle suitable for environments like edge
|
||||
* workers, and other serverless platforms. This option avoids using Node.js-specific APIs,
|
||||
* making the bundle more portable.
|
||||
*
|
||||
* Please note that this feature does not provide polyfills for Node.js modules.
|
||||
* Additionally, it is experimental, and the schematics may undergo changes in future
|
||||
* versions.
|
||||
*/
|
||||
export declare enum ExperimentalPlatform {
|
||||
Neutral = "neutral",
|
||||
Node = "node"
|
||||
}
|
||||
/**
|
||||
* Options to pass to style preprocessors.
|
||||
*/
|
||||
export type StylePreprocessorOptions = {
|
||||
/**
|
||||
* Paths to include. Paths will be resolved to workspace root.
|
||||
*/
|
||||
includePaths?: string[];
|
||||
/**
|
||||
* Options to pass to the sass preprocessor.
|
||||
*/
|
||||
sass?: Sass;
|
||||
};
|
||||
/**
|
||||
* Options to pass to the sass preprocessor.
|
||||
*/
|
||||
export type Sass = {
|
||||
/**
|
||||
* A set of deprecations to treat as fatal. If a deprecation warning of any provided type is
|
||||
* encountered during compilation, the compiler will error instead. If a Version is
|
||||
* provided, then all deprecations that were active in that compiler version will be treated
|
||||
* as fatal.
|
||||
*/
|
||||
fatalDeprecations?: string[];
|
||||
/**
|
||||
* A set of future deprecations to opt into early. Future deprecations passed here will be
|
||||
* treated as active by the compiler, emitting warnings as necessary.
|
||||
*/
|
||||
futureDeprecations?: string[];
|
||||
/**
|
||||
* A set of active deprecations to ignore. If a deprecation warning of any provided type is
|
||||
* encountered during compilation, the compiler will ignore it instead.
|
||||
*/
|
||||
silenceDeprecations?: string[];
|
||||
};
|
||||
export type StyleElement = StyleClass | string;
|
||||
export type StyleClass = {
|
||||
/**
|
||||
* The bundle name for this extra entry point.
|
||||
*/
|
||||
bundleName?: string;
|
||||
/**
|
||||
* If the bundle will be referenced in the HTML file.
|
||||
*/
|
||||
inject?: boolean;
|
||||
/**
|
||||
* The file to include.
|
||||
*/
|
||||
input: string;
|
||||
};
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ExperimentalPlatform = exports.OutputMode = exports.OutputHashing = exports.InlineStyleLanguage = exports.I18NTranslation = exports.CrossOrigin = exports.Type = void 0;
|
||||
/**
|
||||
* The type of budget.
|
||||
*/
|
||||
var Type;
|
||||
(function (Type) {
|
||||
Type["All"] = "all";
|
||||
Type["AllScript"] = "allScript";
|
||||
Type["Any"] = "any";
|
||||
Type["AnyComponentStyle"] = "anyComponentStyle";
|
||||
Type["AnyScript"] = "anyScript";
|
||||
Type["Bundle"] = "bundle";
|
||||
Type["Initial"] = "initial";
|
||||
})(Type || (exports.Type = Type = {}));
|
||||
/**
|
||||
* Define the crossorigin attribute setting of elements that provide CORS support.
|
||||
*/
|
||||
var CrossOrigin;
|
||||
(function (CrossOrigin) {
|
||||
CrossOrigin["Anonymous"] = "anonymous";
|
||||
CrossOrigin["None"] = "none";
|
||||
CrossOrigin["UseCredentials"] = "use-credentials";
|
||||
})(CrossOrigin || (exports.CrossOrigin = CrossOrigin = {}));
|
||||
/**
|
||||
* How to handle duplicate translations for i18n.
|
||||
*
|
||||
* How to handle missing translations for i18n.
|
||||
*/
|
||||
var I18NTranslation;
|
||||
(function (I18NTranslation) {
|
||||
I18NTranslation["Error"] = "error";
|
||||
I18NTranslation["Ignore"] = "ignore";
|
||||
I18NTranslation["Warning"] = "warning";
|
||||
})(I18NTranslation || (exports.I18NTranslation = I18NTranslation = {}));
|
||||
/**
|
||||
* The stylesheet language to use for the application's inline component styles.
|
||||
*/
|
||||
var InlineStyleLanguage;
|
||||
(function (InlineStyleLanguage) {
|
||||
InlineStyleLanguage["Css"] = "css";
|
||||
InlineStyleLanguage["Less"] = "less";
|
||||
InlineStyleLanguage["Sass"] = "sass";
|
||||
InlineStyleLanguage["Scss"] = "scss";
|
||||
})(InlineStyleLanguage || (exports.InlineStyleLanguage = InlineStyleLanguage = {}));
|
||||
/**
|
||||
* Define the output filename cache-busting hashing mode.
|
||||
*
|
||||
* - `none`: No hashing.
|
||||
* - `all`: Hash for all output bundles.
|
||||
* - `media`: Hash for all output media (e.g., images, fonts, etc. that are referenced in
|
||||
* CSS files).
|
||||
* - `bundles`: Hash for output of lazy and main bundles.
|
||||
*/
|
||||
var OutputHashing;
|
||||
(function (OutputHashing) {
|
||||
OutputHashing["All"] = "all";
|
||||
OutputHashing["Bundles"] = "bundles";
|
||||
OutputHashing["Media"] = "media";
|
||||
OutputHashing["None"] = "none";
|
||||
})(OutputHashing || (exports.OutputHashing = OutputHashing = {}));
|
||||
/**
|
||||
* Defines the type of build output artifact. 'static': Generates a static site build
|
||||
* artifact for deployment on any static hosting service. 'server': Generates a server
|
||||
* application build artifact, required for applications using hybrid rendering or APIs.
|
||||
*/
|
||||
var OutputMode;
|
||||
(function (OutputMode) {
|
||||
OutputMode["Server"] = "server";
|
||||
OutputMode["Static"] = "static";
|
||||
})(OutputMode || (exports.OutputMode = OutputMode = {}));
|
||||
/**
|
||||
* Specifies the platform for which the server bundle is generated. This affects the APIs
|
||||
* and modules available in the server-side code.
|
||||
*
|
||||
* - `node`: (Default) Generates a bundle optimized for Node.js environments.
|
||||
* - `neutral`: Generates a platform-neutral bundle suitable for environments like edge
|
||||
* workers, and other serverless platforms. This option avoids using Node.js-specific APIs,
|
||||
* making the bundle more portable.
|
||||
*
|
||||
* Please note that this feature does not provide polyfills for Node.js modules.
|
||||
* Additionally, it is experimental, and the schematics may undergo changes in future
|
||||
* versions.
|
||||
*/
|
||||
var ExperimentalPlatform;
|
||||
(function (ExperimentalPlatform) {
|
||||
ExperimentalPlatform["Neutral"] = "neutral";
|
||||
ExperimentalPlatform["Node"] = "node";
|
||||
})(ExperimentalPlatform || (exports.ExperimentalPlatform = ExperimentalPlatform = {}));
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AAC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|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "Application schema for Build Facade.",
|
||||
"description": "Application builder target options",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"assets": {
|
||||
"type": "array",
|
||||
"description": "Define the assets to be copied to the output directory. These assets are copied as-is without any further processing or hashing.",
|
||||
"default": [],
|
||||
"items": {
|
||||
"$ref": "#/definitions/assetPattern"
|
||||
}
|
||||
},
|
||||
"browser": {
|
||||
"type": "string",
|
||||
"description": "The full path for the browser entry point to the application, relative to the current workspace."
|
||||
},
|
||||
"server": {
|
||||
"description": "The full path for the server entry point to the application, relative to the current workspace.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The full path for the server entry point to the application, relative to the current workspace."
|
||||
},
|
||||
{
|
||||
"const": false,
|
||||
"type": "boolean",
|
||||
"description": "Indicates that a server entry point is not provided."
|
||||
}
|
||||
]
|
||||
},
|
||||
"polyfills": {
|
||||
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"uniqueItems": true
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"tsConfig": {
|
||||
"type": "string",
|
||||
"description": "The full path for the TypeScript configuration file, relative to the current workspace."
|
||||
},
|
||||
"deployUrl": {
|
||||
"type": "string",
|
||||
"description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations."
|
||||
},
|
||||
"security": {
|
||||
"description": "Security features to protect against XSS and other common attacks",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"allowedHosts": {
|
||||
"description": "A list of hostnames that are allowed to access the server-side application. For more information, see https://angular.dev/best-practices/security#preventing-server-side-request-forgery-ssrf.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"autoCsp": {
|
||||
"description": "Enables automatic generation of a hash-based Strict Content Security Policy (https://web.dev/articles/strict-csp#choose-hash) based on scripts in index.html. Will default to true once we are out of experimental/preview phases.",
|
||||
"default": false,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"unsafeEval": {
|
||||
"type": "boolean",
|
||||
"description": "Include the `unsafe-eval` directive (https://web.dev/articles/strict-csp#remove-eval) in the auto-CSP. Please only enable this if you are absolutely sure that you need to, as allowing calls to eval will weaken the XSS defenses provided by the auto-CSP.",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"description": "Global scripts to be included in the build.",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"input": {
|
||||
"type": "string",
|
||||
"description": "The file to include.",
|
||||
"pattern": "\\.[cm]?jsx?$"
|
||||
},
|
||||
"bundleName": {
|
||||
"type": "string",
|
||||
"pattern": "^[\\w\\-.]*$",
|
||||
"description": "The bundle name for this extra entry point."
|
||||
},
|
||||
"inject": {
|
||||
"type": "boolean",
|
||||
"description": "If the bundle will be referenced in the HTML file.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["input"]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The JavaScript/TypeScript file or package containing the file to include."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"styles": {
|
||||
"description": "Global styles to be included in the build.",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"input": {
|
||||
"type": "string",
|
||||
"description": "The file to include.",
|
||||
"pattern": "\\.(?:css|scss|sass|less)$"
|
||||
},
|
||||
"bundleName": {
|
||||
"type": "string",
|
||||
"pattern": "^[\\w\\-.]*$",
|
||||
"description": "The bundle name for this extra entry point."
|
||||
},
|
||||
"inject": {
|
||||
"type": "boolean",
|
||||
"description": "If the bundle will be referenced in the HTML file.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["input"]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The file to include.",
|
||||
"pattern": "\\.(?:css|scss|sass|less)$"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"inlineStyleLanguage": {
|
||||
"description": "The stylesheet language to use for the application's inline component styles.",
|
||||
"type": "string",
|
||||
"default": "css",
|
||||
"enum": ["css", "less", "sass", "scss"]
|
||||
},
|
||||
"stylePreprocessorOptions": {
|
||||
"description": "Options to pass to style preprocessors.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"includePaths": {
|
||||
"description": "Paths to include. Paths will be resolved to workspace root.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"sass": {
|
||||
"description": "Options to pass to the sass preprocessor.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fatalDeprecations": {
|
||||
"description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"silenceDeprecations": {
|
||||
"description": " A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"futureDeprecations": {
|
||||
"description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"externalDependencies": {
|
||||
"description": "Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime. Note: `@foo/bar` marks all paths within the `@foo/bar` package as external, including sub-paths like `@foo/bar/baz`.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"clearScreen": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Automatically clear the terminal screen during rebuilds."
|
||||
},
|
||||
"optimization": {
|
||||
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.dev/reference/configs/workspace-config#optimization-configuration.",
|
||||
"default": true,
|
||||
"x-user-analytics": "ep.ng_optimization",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"scripts": {
|
||||
"type": "boolean",
|
||||
"description": "Enables optimization of the scripts output.",
|
||||
"default": true
|
||||
},
|
||||
"styles": {
|
||||
"description": "Enables optimization of the styles output.",
|
||||
"default": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"minify": {
|
||||
"type": "boolean",
|
||||
"description": "Minify CSS definitions by removing extraneous whitespace and comments, merging identifiers and minimizing values.",
|
||||
"default": true
|
||||
},
|
||||
"inlineCritical": {
|
||||
"type": "boolean",
|
||||
"description": "Extract and inline critical CSS definitions to improve first paint time.",
|
||||
"default": true
|
||||
},
|
||||
"removeSpecialComments": {
|
||||
"type": "boolean",
|
||||
"description": "Remove comments in global CSS that contains '@license' or '@preserve' or that starts with '//!' or '/*!'.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fonts": {
|
||||
"description": "Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
|
||||
"default": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"inline": {
|
||||
"type": "boolean",
|
||||
"description": "Reduce render blocking requests by inlining external Google Fonts and Adobe Fonts CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"loader": {
|
||||
"description": "Defines the type of loader to use with a specified file extension when used with a JavaScript `import`. `text` inlines the content as a string; `binary` inlines the content as a Uint8Array; `file` emits the file and provides the runtime location of the file; `dataurl` inlines the content as a data URL with best guess of MIME type; `base64` inlines the content as a Base64-encoded string; `empty` considers the content to be empty and not include it in bundles.",
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^\\.\\S+$": { "enum": ["text", "binary", "file", "dataurl", "base64", "empty"] }
|
||||
}
|
||||
},
|
||||
"define": {
|
||||
"description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"conditions": {
|
||||
"description": "Custom package resolution conditions used to resolve conditional exports/imports. Defaults to ['module', 'development'/'production']. The following special conditions are always present if the requirements are satisfied: 'default', 'import', 'require', 'browser', 'node'.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"fileReplacements": {
|
||||
"description": "Replace compilation source files with other compilation source files in the build.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/fileReplacement"
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"outputPath": {
|
||||
"description": "Specify the output path relative to workspace root.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"base": {
|
||||
"type": "string",
|
||||
"description": "Specify the output path relative to workspace root."
|
||||
},
|
||||
"browser": {
|
||||
"type": "string",
|
||||
"pattern": "^[-\\w\\.]*$",
|
||||
"default": "browser",
|
||||
"description": "The output directory name of your browser build within the output path base. Defaults to 'browser'."
|
||||
},
|
||||
"server": {
|
||||
"type": "string",
|
||||
"pattern": "^[-\\w\\.]*$",
|
||||
"default": "server",
|
||||
"description": "The output directory name of your server build within the output path base. Defaults to 'server'."
|
||||
},
|
||||
"media": {
|
||||
"type": "string",
|
||||
"pattern": "^[-\\w\\.]+$",
|
||||
"default": "media",
|
||||
"description": "The output directory name of your media files within the output browser directory. Defaults to 'media'."
|
||||
}
|
||||
},
|
||||
"required": ["base"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"aot": {
|
||||
"type": "boolean",
|
||||
"description": "Build using Ahead of Time compilation.",
|
||||
"x-user-analytics": "ep.ng_aot",
|
||||
"default": true
|
||||
},
|
||||
"sourceMap": {
|
||||
"description": "Output source maps for scripts and styles. For more information, see https://angular.dev/reference/configs/workspace-config#source-map-configuration.",
|
||||
"default": false,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"scripts": {
|
||||
"type": "boolean",
|
||||
"description": "Output source maps for all scripts.",
|
||||
"default": true
|
||||
},
|
||||
"styles": {
|
||||
"type": "boolean",
|
||||
"description": "Output source maps for all styles.",
|
||||
"default": true
|
||||
},
|
||||
"hidden": {
|
||||
"type": "boolean",
|
||||
"description": "Output source maps used for error reporting tools.",
|
||||
"default": false
|
||||
},
|
||||
"vendor": {
|
||||
"type": "boolean",
|
||||
"description": "Resolve vendor packages source maps.",
|
||||
"default": false
|
||||
},
|
||||
"sourcesContent": {
|
||||
"type": "boolean",
|
||||
"description": "Output original source content for files within the source map.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"baseHref": {
|
||||
"type": "string",
|
||||
"description": "Base url for the application being built."
|
||||
},
|
||||
"verbose": {
|
||||
"type": "boolean",
|
||||
"description": "Adds more details to output logging.",
|
||||
"default": false
|
||||
},
|
||||
"progress": {
|
||||
"type": "boolean",
|
||||
"description": "Log progress to the console while building.",
|
||||
"default": true
|
||||
},
|
||||
"i18nMissingTranslation": {
|
||||
"type": "string",
|
||||
"description": "How to handle missing translations for i18n.",
|
||||
"enum": ["warning", "error", "ignore"],
|
||||
"default": "warning"
|
||||
},
|
||||
"i18nDuplicateTranslation": {
|
||||
"type": "string",
|
||||
"description": "How to handle duplicate translations for i18n.",
|
||||
"enum": ["warning", "error", "ignore"],
|
||||
"default": "warning"
|
||||
},
|
||||
"localize": {
|
||||
"description": "Translate the bundles in one or more locales.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Translate all locales."
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "List of locales ID's to translate.",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z]{2,3}(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-[a-zA-Z]{5,8})?(-x(-[a-zA-Z0-9]{1,8})+)?$"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"watch": {
|
||||
"type": "boolean",
|
||||
"description": "Run build when files change.",
|
||||
"default": false
|
||||
},
|
||||
"outputHashing": {
|
||||
"type": "string",
|
||||
"description": "Define the output filename cache-busting hashing mode.\n\n- `none`: No hashing.\n- `all`: Hash for all output bundles. \n- `media`: Hash for all output media (e.g., images, fonts, etc. that are referenced in CSS files).\n- `bundles`: Hash for output of lazy and main bundles.",
|
||||
"default": "none",
|
||||
"enum": ["none", "all", "media", "bundles"]
|
||||
},
|
||||
"poll": {
|
||||
"type": "number",
|
||||
"description": "Enable and define the file watching poll time period in milliseconds."
|
||||
},
|
||||
"deleteOutputPath": {
|
||||
"type": "boolean",
|
||||
"description": "Delete the output path before building.",
|
||||
"default": true
|
||||
},
|
||||
"preserveSymlinks": {
|
||||
"type": "boolean",
|
||||
"description": "Do not use the real path when resolving modules. If unset then will default to `true` if NodeJS option --preserve-symlinks is set."
|
||||
},
|
||||
"extractLicenses": {
|
||||
"type": "boolean",
|
||||
"description": "Extract all licenses in a separate file.",
|
||||
"default": true
|
||||
},
|
||||
"namedChunks": {
|
||||
"type": "boolean",
|
||||
"description": "Use file name for lazy loaded chunks.",
|
||||
"default": false
|
||||
},
|
||||
"subresourceIntegrity": {
|
||||
"type": "boolean",
|
||||
"description": "Enables the use of subresource integrity validation.",
|
||||
"default": false
|
||||
},
|
||||
"serviceWorker": {
|
||||
"description": "Generates a service worker configuration.",
|
||||
"default": false,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Path to ngsw-config.json."
|
||||
},
|
||||
{
|
||||
"const": false,
|
||||
"type": "boolean",
|
||||
"description": "Does not generate a service worker configuration."
|
||||
}
|
||||
]
|
||||
},
|
||||
"index": {
|
||||
"description": "Configures the generation of the application's HTML index.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The path of a file to use for the application's HTML index. The filename of the specified path will be used for the generated file and will be created in the root of the application's configured output path."
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"description": "",
|
||||
"properties": {
|
||||
"input": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "The path of a file to use for the application's generated HTML index."
|
||||
},
|
||||
"output": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"default": "index.html",
|
||||
"description": "The output path of the application's generated HTML index file. The full provided path will be used and will be considered relative to the application's configured output path."
|
||||
},
|
||||
"preloadInitial": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Generates 'preload', 'modulepreload', and 'preconnect' link elements for initial application files and resources."
|
||||
}
|
||||
},
|
||||
"required": ["input"]
|
||||
},
|
||||
{
|
||||
"const": false,
|
||||
"type": "boolean",
|
||||
"description": "Does not generate an `index.html` file."
|
||||
}
|
||||
]
|
||||
},
|
||||
"statsJson": {
|
||||
"type": "boolean",
|
||||
"description": "Generates a 'stats.json' file which can be analyzed with https://esbuild.github.io/analyze/.",
|
||||
"default": false
|
||||
},
|
||||
"budgets": {
|
||||
"description": "Budget thresholds to ensure parts of your application stay within boundaries which you set.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/budget"
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"webWorkerTsConfig": {
|
||||
"type": "string",
|
||||
"description": "TypeScript configuration for Web Worker modules."
|
||||
},
|
||||
"crossOrigin": {
|
||||
"type": "string",
|
||||
"description": "Define the crossorigin attribute setting of elements that provide CORS support.",
|
||||
"default": "none",
|
||||
"enum": ["none", "anonymous", "use-credentials"]
|
||||
},
|
||||
"allowedCommonJsDependencies": {
|
||||
"description": "A list of CommonJS or AMD packages that are allowed to be used without a build time warning. Use `'*'` to allow all.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"prerender": {
|
||||
"description": "Prerender (SSG) pages of your application during build time.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Enable prerending of pages of your application during build time."
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"routesFile": {
|
||||
"type": "string",
|
||||
"description": "The path to a file that contains a list of all routes to prerender, separated by newlines. This option is useful if you want to prerender routes with parameterized URLs."
|
||||
},
|
||||
"discoverRoutes": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the builder should process the Angular Router configuration to find all unparameterized routes and prerender them.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"ssr": {
|
||||
"description": "Server side render (SSR) pages of your application during runtime.",
|
||||
"default": false,
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Enable the server bundles to be written to disk."
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entry": {
|
||||
"type": "string",
|
||||
"description": "The server entry-point that when executed will spawn the web server."
|
||||
},
|
||||
"experimentalPlatform": {
|
||||
"description": "Specifies the platform for which the server bundle is generated. This affects the APIs and modules available in the server-side code. \n\n- `node`: (Default) Generates a bundle optimized for Node.js environments. \n- `neutral`: Generates a platform-neutral bundle suitable for environments like edge workers, and other serverless platforms. This option avoids using Node.js-specific APIs, making the bundle more portable. \n\nPlease note that this feature does not provide polyfills for Node.js modules. Additionally, it is experimental, and the schematics may undergo changes in future versions.",
|
||||
"default": "node",
|
||||
"enum": ["node", "neutral"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"appShell": {
|
||||
"type": "boolean",
|
||||
"description": "Generates an application shell during build time."
|
||||
},
|
||||
"outputMode": {
|
||||
"type": "string",
|
||||
"description": "Defines the type of build output artifact. 'static': Generates a static site build artifact for deployment on any static hosting service. 'server': Generates a server application build artifact, required for applications using hybrid rendering or APIs.",
|
||||
"enum": ["static", "server"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["tsConfig"],
|
||||
"definitions": {
|
||||
"assetPattern": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"followSymlinks": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Allow glob patterns to follow symlink directories. This allows subdirectories of the symlink to be searched."
|
||||
},
|
||||
"glob": {
|
||||
"type": "string",
|
||||
"description": "The pattern to match."
|
||||
},
|
||||
"input": {
|
||||
"type": "string",
|
||||
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
|
||||
},
|
||||
"ignore": {
|
||||
"description": "An array of globs to ignore.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "Absolute path within the output."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["glob", "input"]
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fileReplacement": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"replace": {
|
||||
"type": "string",
|
||||
"pattern": "\\.(([cm]?[jt])sx?|json)$"
|
||||
},
|
||||
"with": {
|
||||
"type": "string",
|
||||
"pattern": "\\.(([cm]?[jt])sx?|json)$"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["replace", "with"]
|
||||
},
|
||||
"budget": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The type of budget.",
|
||||
"enum": ["all", "allScript", "any", "anyScript", "anyComponentStyle", "bundle", "initial"]
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the bundle."
|
||||
},
|
||||
"baseline": {
|
||||
"type": "string",
|
||||
"description": "The baseline size for comparison."
|
||||
},
|
||||
"maximumWarning": {
|
||||
"type": "string",
|
||||
"description": "The maximum threshold for warning relative to the baseline."
|
||||
},
|
||||
"maximumError": {
|
||||
"type": "string",
|
||||
"description": "The maximum threshold for error relative to the baseline."
|
||||
},
|
||||
"minimumWarning": {
|
||||
"type": "string",
|
||||
"description": "The minimum threshold for warning relative to the baseline."
|
||||
},
|
||||
"minimumError": {
|
||||
"type": "string",
|
||||
"description": "The minimum threshold for error relative to the baseline."
|
||||
},
|
||||
"warning": {
|
||||
"type": "string",
|
||||
"description": "The threshold for warning relative to the baseline (min & max)."
|
||||
},
|
||||
"error": {
|
||||
"type": "string",
|
||||
"description": "The threshold for error relative to the baseline (min & max)."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["type"]
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 { AngularCompilation } from '../../tools/angular/compilation';
|
||||
import { ComponentStylesheetBundler } from '../../tools/esbuild/angular/component-stylesheets';
|
||||
import { SourceFileCache } from '../../tools/esbuild/angular/source-file-cache';
|
||||
import { BundlerContext } from '../../tools/esbuild/bundler-context';
|
||||
import { NormalizedApplicationBuildOptions } from './options';
|
||||
/**
|
||||
* Generates one or more BundlerContext instances based on the builder provided
|
||||
* configuration.
|
||||
* @param options The normalized application builder options to use.
|
||||
* @param browsers An string array of browserslist browsers to support.
|
||||
* @param codeBundleCache An instance of the TypeScript source file cache.
|
||||
* @returns An array of BundlerContext objects.
|
||||
*/
|
||||
export declare function setupBundlerContexts(options: NormalizedApplicationBuildOptions, target: string[], codeBundleCache: SourceFileCache, stylesheetBundler: ComponentStylesheetBundler, angularCompilation: AngularCompilation, templateUpdates: Map<string, string> | undefined): {
|
||||
typescriptContexts: BundlerContext[];
|
||||
otherContexts: BundlerContext[];
|
||||
};
|
||||
export declare function createComponentStyleBundler(options: NormalizedApplicationBuildOptions, target: string[]): ComponentStylesheetBundler;
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupBundlerContexts = setupBundlerContexts;
|
||||
exports.createComponentStyleBundler = createComponentStyleBundler;
|
||||
const component_stylesheets_1 = require("../../tools/esbuild/angular/component-stylesheets");
|
||||
const application_code_bundle_1 = require("../../tools/esbuild/application-code-bundle");
|
||||
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
const global_scripts_1 = require("../../tools/esbuild/global-scripts");
|
||||
const global_styles_1 = require("../../tools/esbuild/global-styles");
|
||||
const utils_1 = require("../../tools/esbuild/utils");
|
||||
/**
|
||||
* Generates one or more BundlerContext instances based on the builder provided
|
||||
* configuration.
|
||||
* @param options The normalized application builder options to use.
|
||||
* @param browsers An string array of browserslist browsers to support.
|
||||
* @param codeBundleCache An instance of the TypeScript source file cache.
|
||||
* @returns An array of BundlerContext objects.
|
||||
*/
|
||||
function setupBundlerContexts(options, target, codeBundleCache, stylesheetBundler, angularCompilation, templateUpdates) {
|
||||
const { outputMode, serverEntryPoint, appShellOptions, prerenderOptions, ssrOptions, workspaceRoot, watch = false, } = options;
|
||||
const typescriptContexts = [];
|
||||
const otherContexts = [];
|
||||
// Browser application code
|
||||
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createBrowserCodeBundleOptions)(options, target, codeBundleCache, stylesheetBundler, angularCompilation, templateUpdates)));
|
||||
// Browser polyfills code
|
||||
const browserPolyfillBundleOptions = (0, application_code_bundle_1.createBrowserPolyfillBundleOptions)(options, target, codeBundleCache, stylesheetBundler);
|
||||
if (browserPolyfillBundleOptions) {
|
||||
const browserPolyfillContext = new bundler_context_1.BundlerContext(workspaceRoot, watch, browserPolyfillBundleOptions);
|
||||
if (typeof browserPolyfillBundleOptions === 'function') {
|
||||
otherContexts.push(browserPolyfillContext);
|
||||
}
|
||||
else {
|
||||
typescriptContexts.push(browserPolyfillContext);
|
||||
}
|
||||
}
|
||||
// Global Stylesheets
|
||||
if (options.globalStyles.length > 0) {
|
||||
for (const initial of [true, false]) {
|
||||
const bundleOptions = (0, global_styles_1.createGlobalStylesBundleOptions)(options, target, initial);
|
||||
if (bundleOptions) {
|
||||
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Global Scripts
|
||||
if (options.globalScripts.length > 0) {
|
||||
for (const initial of [true, false]) {
|
||||
const bundleOptions = (0, global_scripts_1.createGlobalScriptsBundleOptions)(options, target, initial);
|
||||
if (bundleOptions) {
|
||||
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Skip server build when none of the features are enabled.
|
||||
if (serverEntryPoint && (outputMode || prerenderOptions || appShellOptions || ssrOptions)) {
|
||||
const nodeTargets = [...target, ...(0, utils_1.getSupportedNodeTargets)()];
|
||||
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createServerMainCodeBundleOptions)(options, nodeTargets, codeBundleCache, stylesheetBundler)));
|
||||
if (outputMode && ssrOptions?.entry) {
|
||||
// New behavior introduced: 'server.ts' is now bundled separately from 'main.server.ts'.
|
||||
typescriptContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, (0, application_code_bundle_1.createSsrEntryCodeBundleOptions)(options, nodeTargets, codeBundleCache, stylesheetBundler)));
|
||||
}
|
||||
// Server polyfills code
|
||||
const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache.loadResultCache);
|
||||
if (serverPolyfillBundleOptions) {
|
||||
otherContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, watch, serverPolyfillBundleOptions));
|
||||
}
|
||||
}
|
||||
return { typescriptContexts, otherContexts };
|
||||
}
|
||||
function createComponentStyleBundler(options, target) {
|
||||
const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, externalDependencies, preserveSymlinks, stylePreprocessorOptions, inlineStyleLanguage, cacheOptions, tailwindConfiguration, postcssConfiguration, publicPath, } = options;
|
||||
const incremental = !!options.watch;
|
||||
return new component_stylesheets_1.ComponentStylesheetBundler({
|
||||
workspaceRoot,
|
||||
inlineFonts: !!optimizationOptions.fonts.inline,
|
||||
optimization: !!optimizationOptions.styles.minify,
|
||||
sourcemap:
|
||||
// Hidden component stylesheet sourcemaps are inaccessible which is effectively
|
||||
// the same as being disabled. Disabling has the advantage of avoiding the overhead
|
||||
// of sourcemap processing.
|
||||
sourcemapOptions.styles && !sourcemapOptions.hidden ? 'linked' : false,
|
||||
sourcesContent: sourcemapOptions.sourcesContent,
|
||||
outputNames,
|
||||
includePaths: stylePreprocessorOptions?.includePaths,
|
||||
// string[] | undefined' is not assignable to type '(Version | DeprecationOrId)[] | undefined'.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
sass: stylePreprocessorOptions?.sass,
|
||||
externalDependencies,
|
||||
target,
|
||||
preserveSymlinks,
|
||||
tailwindConfiguration,
|
||||
postcssConfiguration,
|
||||
cacheOptions,
|
||||
publicPath,
|
||||
}, inlineStyleLanguage, incremental);
|
||||
}
|
||||
//# sourceMappingURL=setup-bundling.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"setup-bundling.js","sourceRoot":"","sources":["setup-bundling.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA0BH,oDAmHC;AAED,kEA+CC;AA3LD,6FAA+F;AAE/F,yFAMqD;AACrD,yEAAqE;AACrE,uEAAsF;AACtF,qEAAoF;AACpF,qDAAoE;AAGpE;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAClC,OAA0C,EAC1C,MAAgB,EAChB,eAAgC,EAChC,iBAA6C,EAC7C,kBAAsC,EACtC,eAAgD;IAKhD,MAAM,EACJ,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,GAAG,KAAK,GACd,GAAG,OAAO,CAAC;IACZ,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B,MAAM,aAA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gB,2BAA2B,CACzC,OAA0C,EAC1C,MAAgB;IAEhB,MAAM,EACJ,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,GACX,GAAG,OAAO,CAAC;IACZ,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAEpC,OAAO,IAAI,kDAA0B,CACnC;QACE,aAAa;QACb,WAAW,EAAE,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM;QAC/C,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM;QACjD,SAAS;QACP,+EAA+E;QAC/E,mFAAmF;QACnF,2BAA2B;QAC3B,gBAAgB,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;QACxE,cAAc,EAAE,gBAAgB,CAAC,cAAc;QAC/C,WAAW;QACX,YAAY,EAAE,wBAAwB,EAAE,YAAY;QACpD,+FAA+F;QAC/F,8DAA8D;QAC9D,IAAI,EAAE,wBAAwB,EAAE,IAAW;QAC3C,oBAAoB;QACpB,MAAM;QACN,gBAAgB;QAChB,qBAAqB;QACrB,oBAAoB;QACpB,YAAY;QACZ,UAAU;KACX,EACD,mBAAmB,EACnB,WAAW,CACZ,CAAC;AACJ,CAAC"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { Plugin } from 'esbuild';
|
||||
import type http from 'node:http';
|
||||
import { type IndexHtmlTransform } from './internal';
|
||||
import type { DevServerBuilderOutput } from './output';
|
||||
import type { Schema as DevServerBuilderOptions } from './schema';
|
||||
/**
|
||||
* A Builder that executes a development server based on the provided browser target option.
|
||||
*
|
||||
* Usage of the `transforms` and/or `extensions` parameters is NOT supported and may cause
|
||||
* unexpected build output or build failures.
|
||||
*
|
||||
* @param options Dev Server options.
|
||||
* @param context The build context.
|
||||
* @param extensions An optional object containing an array of build plugins (esbuild-based)
|
||||
* and/or HTTP request middleware.
|
||||
*
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*/
|
||||
export declare function execute(options: DevServerBuilderOptions, context: BuilderContext, extensions?: {
|
||||
buildPlugins?: Plugin[];
|
||||
middleware?: ((req: http.IncomingMessage, res: http.ServerResponse, next: (err?: unknown) => void) => void)[];
|
||||
indexHtmlTransformer?: IndexHtmlTransform;
|
||||
}): AsyncIterable<DevServerBuilderOutput>;
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.execute = execute;
|
||||
const check_port_1 = require("../../utils/check-port");
|
||||
const internal_1 = require("./internal");
|
||||
const options_1 = require("./options");
|
||||
const vite_1 = require("./vite");
|
||||
/**
|
||||
* A Builder that executes a development server based on the provided browser target option.
|
||||
*
|
||||
* Usage of the `transforms` and/or `extensions` parameters is NOT supported and may cause
|
||||
* unexpected build output or build failures.
|
||||
*
|
||||
* @param options Dev Server options.
|
||||
* @param context The build context.
|
||||
* @param extensions An optional object containing an array of build plugins (esbuild-based)
|
||||
* and/or HTTP request middleware.
|
||||
*
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*/
|
||||
async function* execute(options, context, extensions) {
|
||||
// Determine project name from builder context target
|
||||
const projectName = context.target?.project;
|
||||
if (!projectName) {
|
||||
context.logger.error(`The "dev-server" builder requires a target to be specified.`);
|
||||
return;
|
||||
}
|
||||
const { builderName, normalizedOptions } = await initialize(options, projectName, context);
|
||||
yield* (0, vite_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, { codePlugins: plugins }), context, { indexHtml: extensions?.indexHtmlTransformer }, extensions);
|
||||
}
|
||||
async function initialize(initialOptions, projectName, context) {
|
||||
// Purge old build disk cache.
|
||||
await (0, internal_1.purgeStaleBuildCache)(context);
|
||||
const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, initialOptions);
|
||||
const builderName = await context.getBuilderNameForTarget(normalizedOptions.buildTarget);
|
||||
if (!/^127\.\d+\.\d+\.\d+/g.test(normalizedOptions.host) &&
|
||||
normalizedOptions.host !== '::1' &&
|
||||
normalizedOptions.host !== 'localhost') {
|
||||
context.logger.warn(`
|
||||
Warning: This is a simple server for use in testing or debugging Angular applications
|
||||
locally. It hasn't been reviewed for security issues.
|
||||
|
||||
Binding this server to an open connection can result in compromising your application or
|
||||
computer. Using a different host than the one passed to the "--host" flag might result in
|
||||
websocket connection issues.
|
||||
`);
|
||||
}
|
||||
normalizedOptions.port = await (0, check_port_1.checkPort)(normalizedOptions.port, normalizedOptions.host);
|
||||
return {
|
||||
builderName,
|
||||
normalizedOptions,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=builder.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"builder.js","sourceRoot":"","sources":["builder.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA6BH,0BAgCC;AAxDD,uDAAmD;AACnD,yCAIoB;AACpB,uCAA6C;AAG7C,iCAAuC;AAEvC;;;;;;;;;;;;GAYG;AACI,KAAK,SAAS,CAAC,CAAC,OAAO,CAC5B,OAAgC,EAChC,OAAuB,EACvB,UAQC;IAED,qDAAqD;IACrD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5C,IAAI,CA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,CAAC;AACJ,CAAC"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 { Builder } from '@angular-devkit/architect';
|
||||
import { execute } from './builder';
|
||||
import type { DevServerBuilderOutput } from './output';
|
||||
import type { Schema as DevServerBuilderOptions } from './schema';
|
||||
export { type DevServerBuilderOptions, type DevServerBuilderOutput, execute as executeDevServerBuilder, };
|
||||
declare const builder: Builder<DevServerBuilderOptions>;
|
||||
export default builder;
|
||||
export { execute as executeDevServer };
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.executeDevServer = exports.executeDevServerBuilder = void 0;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const builder_1 = require("./builder");
|
||||
Object.defineProperty(exports, "executeDevServerBuilder", { enumerable: true, get: function () { return builder_1.execute; } });
|
||||
Object.defineProperty(exports, "executeDevServer", { enumerable: true, get: function () { return builder_1.execute; } });
|
||||
const builder = (0, architect_1.createBuilder)(builder_1.execute);
|
||||
exports.default = builder;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,yDAAmE;AACnE,uCAAoC;AAOvB,wGAPJ,iBAAO,OAOoB;AAUhB,iGAjBX,iBAAO,OAiBoB;AARpC,MAAM,OAAO,GAAqC,IAAA,yBAAa,EAG7D,iBAAO,CAAC,CAAC;AAEX,kBAAe,OAAO,CAAC"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
export { type BuildOutputFile, BuildOutputFileType } from '../../tools/esbuild/bundler-context';
|
||||
export { createRxjsEsmResolutionPlugin } from '../../tools/esbuild/rxjs-esm-resolution-plugin';
|
||||
export { JavaScriptTransformer } from '../../tools/esbuild/javascript-transformer';
|
||||
export { getFeatureSupport, isZonelessApp } from '../../tools/esbuild/utils';
|
||||
export { type IndexHtmlTransform } from '../../utils/index-file/index-html-generator';
|
||||
export { purgeStaleBuildCache } from '../../utils/purge-cache';
|
||||
export { getSupportedBrowsers } from '../../utils/supported-browsers';
|
||||
export { transformSupportedBrowsersToTargets } from '../../tools/esbuild/utils';
|
||||
export { buildApplicationInternal } from '../../builders/application';
|
||||
export type { ApplicationBuilderInternalOptions } from '../../builders/application/options';
|
||||
export type { ExternalResultMetadata } from '../../tools/esbuild/bundler-execution-result';
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildApplicationInternal = exports.transformSupportedBrowsersToTargets = exports.getSupportedBrowsers = exports.purgeStaleBuildCache = exports.isZonelessApp = exports.getFeatureSupport = exports.JavaScriptTransformer = exports.createRxjsEsmResolutionPlugin = exports.BuildOutputFileType = void 0;
|
||||
var bundler_context_1 = require("../../tools/esbuild/bundler-context");
|
||||
Object.defineProperty(exports, "BuildOutputFileType", { enumerable: true, get: function () { return bundler_context_1.BuildOutputFileType; } });
|
||||
var rxjs_esm_resolution_plugin_1 = require("../../tools/esbuild/rxjs-esm-resolution-plugin");
|
||||
Object.defineProperty(exports, "createRxjsEsmResolutionPlugin", { enumerable: true, get: function () { return rxjs_esm_resolution_plugin_1.createRxjsEsmResolutionPlugin; } });
|
||||
var javascript_transformer_1 = require("../../tools/esbuild/javascript-transformer");
|
||||
Object.defineProperty(exports, "JavaScriptTransformer", { enumerable: true, get: function () { return javascript_transformer_1.JavaScriptTransformer; } });
|
||||
var utils_1 = require("../../tools/esbuild/utils");
|
||||
Object.defineProperty(exports, "getFeatureSupport", { enumerable: true, get: function () { return utils_1.getFeatureSupport; } });
|
||||
Object.defineProperty(exports, "isZonelessApp", { enumerable: true, get: function () { return utils_1.isZonelessApp; } });
|
||||
var purge_cache_1 = require("../../utils/purge-cache");
|
||||
Object.defineProperty(exports, "purgeStaleBuildCache", { enumerable: true, get: function () { return purge_cache_1.purgeStaleBuildCache; } });
|
||||
var supported_browsers_1 = require("../../utils/supported-browsers");
|
||||
Object.defineProperty(exports, "getSupportedBrowsers", { enumerable: true, get: function () { return supported_browsers_1.getSupportedBrowsers; } });
|
||||
var utils_2 = require("../../tools/esbuild/utils");
|
||||
Object.defineProperty(exports, "transformSupportedBrowsersToTargets", { enumerable: true, get: function () { return utils_2.transformSupportedBrowsersToTargets; } });
|
||||
var application_1 = require("../../builders/application");
|
||||
Object.defineProperty(exports, "buildApplicationInternal", { enumerable: true, get: function () { return application_1.buildApplicationInternal; } });
|
||||
//# sourceMappingURL=internal.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"internal.js","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uEAAgG;AAAjE,sHAAA,mBAAmB,OAAA;AAClD,6FAA+F;AAAtF,2IAAA,6BAA6B,OAAA;AACtC,qFAAmF;AAA1E,+HAAA,qBAAqB,OAAA;AAC9B,mDAA6E;AAApE,0GAAA,iBAAiB,OAAA;AAAE,sGAAA,aAAa,OAAA;AAEzC,uDAA+D;AAAtD,mHAAA,oBAAoB,OAAA;AAC7B,qEAAsE;AAA7D,0HAAA,oBAAoB,OAAA;AAC7B,mDAAgF;AAAvE,4HAAA,mCAAmC,OAAA;AAC5C,0DAAsE;AAA7D,uHAAA,wBAAwB,OAAA"}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import { Schema as DevServerOptions } from './schema';
|
||||
export type NormalizedDevServerOptions = Awaited<ReturnType<typeof normalizeOptions>>;
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
export declare function normalizeOptions(context: BuilderContext, projectName: string, options: DevServerOptions): Promise<{
|
||||
buildTarget: import("@angular-devkit/architect").Target;
|
||||
host: string;
|
||||
port: number;
|
||||
poll: number | undefined;
|
||||
open: boolean | undefined;
|
||||
verbose: boolean | undefined;
|
||||
define: {
|
||||
[key: string]: string;
|
||||
} | undefined;
|
||||
watch: boolean | undefined;
|
||||
liveReload: boolean;
|
||||
hmr: boolean;
|
||||
headers: {
|
||||
[key: string]: string;
|
||||
} | undefined;
|
||||
workspaceRoot: string;
|
||||
projectRoot: string;
|
||||
cacheOptions: import("../../utils/normalize-cache").NormalizedCachedOptions;
|
||||
proxyConfig: string | undefined;
|
||||
servePath: string | undefined;
|
||||
ssl: boolean | undefined;
|
||||
sslCert: string | undefined;
|
||||
sslKey: string | undefined;
|
||||
prebundle: import("./schema").PrebundleUnion | undefined;
|
||||
inspect: boolean | {
|
||||
host?: string;
|
||||
port?: number;
|
||||
};
|
||||
allowedHosts: true | string[];
|
||||
}>;
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeOptions = normalizeOptions;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const utils_1 = require("../../utils");
|
||||
const normalize_cache_1 = require("../../utils/normalize-cache");
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
async function normalizeOptions(context, projectName, options) {
|
||||
const { workspaceRoot, logger } = context;
|
||||
const projectMetadata = await context.getProjectMetadata(projectName);
|
||||
const projectRoot = node_path_1.default.join(workspaceRoot, projectMetadata.root ?? '');
|
||||
const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
|
||||
// Target specifier defaults to the current project's build target using a development configuration
|
||||
const buildTargetSpecifier = options.buildTarget ?? `::development`;
|
||||
const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
|
||||
// Get the application builder options.
|
||||
const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
|
||||
const rawBuildOptions = await context.getTargetOptions(buildTarget);
|
||||
const buildOptions = (await context.validateOptions(rawBuildOptions, browserBuilderName));
|
||||
const optimization = (0, utils_1.normalizeOptimization)(buildOptions.optimization);
|
||||
if (options.prebundle) {
|
||||
if (!cacheOptions.enabled) {
|
||||
// Warn if the initial options provided by the user enable prebundling but caching is disabled
|
||||
logger.warn('Prebundling has been configured but will not be used because caching has been disabled.');
|
||||
}
|
||||
else if (optimization.scripts) {
|
||||
// Warn if the initial options provided by the user enable prebundling but script optimization is enabled.
|
||||
logger.warn('Prebundling has been configured but will not be used because scripts optimization is enabled.');
|
||||
}
|
||||
}
|
||||
let inspect = false;
|
||||
const inspectRaw = options.inspect;
|
||||
if (inspectRaw === true || inspectRaw === '' || inspectRaw === 'true') {
|
||||
inspect = {
|
||||
host: undefined,
|
||||
port: undefined,
|
||||
};
|
||||
}
|
||||
else if (typeof inspectRaw === 'string' && inspectRaw !== 'false') {
|
||||
const port = +inspectRaw;
|
||||
if (isFinite(port)) {
|
||||
inspect = {
|
||||
host: undefined,
|
||||
port,
|
||||
};
|
||||
}
|
||||
else {
|
||||
const [host, port] = inspectRaw.split(':');
|
||||
inspect = {
|
||||
host,
|
||||
port: isNaN(+port) ? undefined : +port,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Initial options to keep
|
||||
const { host, port, poll, open, verbose, define, watch, liveReload, hmr, headers, proxyConfig, servePath, ssl, sslCert, sslKey, prebundle, allowedHosts, } = options;
|
||||
// Return all the normalized options
|
||||
return {
|
||||
buildTarget,
|
||||
host: host ?? 'localhost',
|
||||
port: port ?? 4200,
|
||||
poll,
|
||||
open,
|
||||
verbose,
|
||||
define,
|
||||
watch,
|
||||
liveReload: !!liveReload,
|
||||
hmr: hmr ?? !!liveReload,
|
||||
headers,
|
||||
workspaceRoot,
|
||||
projectRoot,
|
||||
cacheOptions,
|
||||
proxyConfig,
|
||||
servePath,
|
||||
ssl,
|
||||
sslCert,
|
||||
sslKey,
|
||||
// Prebundling defaults to true but requires caching to function
|
||||
prebundle: cacheOptions.enabled && !optimization.scripts && prebundle,
|
||||
inspect,
|
||||
allowedHosts: allowedHosts ? allowedHosts : [],
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=options.js.map
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EAAE,IAAI,IAAI,WAAW;QACzB,IAAI,EAAE,IAAI,IAAI,IAAI;QAClB,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,MAAM;QACN,KAAK;QACL,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,UAAU;QACxB,OAAO;QACP,aAAa;QACb,WAAW;QACX,YAAY;QACZ,WAAW;QACX,SAAS;QACT,GAAG;QACH,OAAO;QACP,MAAM;QACN,gEAAgE;QAChE,SAAS,EAAE,YAAY,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,IAAI,SAAS;QACrE,OAAO;QACP,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;KAC/C,CAAC;AACJ,CAAC"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @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 { BuilderOutput } from '@angular-devkit/architect';
|
||||
/**
|
||||
* @experimental Direct usage of this type is considered experimental.
|
||||
*/
|
||||
export interface DevServerBuilderOutput extends BuilderOutput {
|
||||
baseUrl: string;
|
||||
port?: number;
|
||||
address?: string;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=output.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"output.js","sourceRoot":"","sources":["output.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* Dev Server target options for Build Facade.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* The hosts that the development server will respond to. This option sets the Vite option
|
||||
* of the same name. For further details:
|
||||
* https://vite.dev/config/server-options.html#server-allowedhosts
|
||||
*/
|
||||
allowedHosts?: AllowedHosts;
|
||||
/**
|
||||
* A build builder target to serve in the format of `project:target[:configuration]`. You
|
||||
* can also pass in more than one configuration name as a comma-separated list. Example:
|
||||
* `project:target:production,staging`.
|
||||
*/
|
||||
buildTarget: string;
|
||||
/**
|
||||
* Defines global identifiers that will be replaced with a specified constant value when
|
||||
* found in any JavaScript or TypeScript code including libraries. The value will be used
|
||||
* directly. String values must be put in quotes. Identifiers within Angular metadata such
|
||||
* as Component Decorators will not be replaced.
|
||||
*/
|
||||
define?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* Custom HTTP headers to be added to all responses.
|
||||
*/
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only
|
||||
* global and component stylesheets are supported.
|
||||
*/
|
||||
hmr?: boolean;
|
||||
/**
|
||||
* Host to listen on.
|
||||
*/
|
||||
host?: string;
|
||||
/**
|
||||
* Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are
|
||||
* enabled.
|
||||
*/
|
||||
inspect?: Inspect;
|
||||
/**
|
||||
* Whether to reload the page on change, using live-reload.
|
||||
*/
|
||||
liveReload?: boolean;
|
||||
/**
|
||||
* Opens the url in default browser.
|
||||
*/
|
||||
open?: boolean;
|
||||
/**
|
||||
* Enable and define the file watching poll time period in milliseconds.
|
||||
*/
|
||||
poll?: number;
|
||||
/**
|
||||
* Port to listen on.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* Enable and control the Vite-based development server's prebundling capabilities. To
|
||||
* enable prebundling, the Angular CLI cache must also be enabled.
|
||||
*/
|
||||
prebundle?: PrebundleUnion;
|
||||
/**
|
||||
* Proxy configuration file. For more information, see
|
||||
* https://angular.dev/tools/cli/serve#proxying-to-a-backend-server.
|
||||
*/
|
||||
proxyConfig?: string;
|
||||
/**
|
||||
* The pathname where the application will be served.
|
||||
*/
|
||||
servePath?: string;
|
||||
/**
|
||||
* Serve using HTTPS.
|
||||
*/
|
||||
ssl?: boolean;
|
||||
/**
|
||||
* SSL certificate to use for serving HTTPS.
|
||||
*/
|
||||
sslCert?: string;
|
||||
/**
|
||||
* SSL key to use for serving HTTPS.
|
||||
*/
|
||||
sslKey?: string;
|
||||
/**
|
||||
* Adds more details to output logging.
|
||||
*/
|
||||
verbose?: boolean;
|
||||
/**
|
||||
* Rebuild on change.
|
||||
*/
|
||||
watch?: boolean;
|
||||
};
|
||||
/**
|
||||
* The hosts that the development server will respond to. This option sets the Vite option
|
||||
* of the same name. For further details:
|
||||
* https://vite.dev/config/server-options.html#server-allowedhosts
|
||||
*/
|
||||
export type AllowedHosts = string[] | boolean;
|
||||
/**
|
||||
* Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are
|
||||
* enabled.
|
||||
*/
|
||||
export type Inspect = boolean | string;
|
||||
/**
|
||||
* Enable and control the Vite-based development server's prebundling capabilities. To
|
||||
* enable prebundling, the Angular CLI cache must also be enabled.
|
||||
*/
|
||||
export type PrebundleUnion = boolean | PrebundleClass;
|
||||
export type PrebundleClass = {
|
||||
/**
|
||||
* List of package imports that should not be prebundled by the development server. The
|
||||
* packages will be bundled into the application code itself. Note: specifying `@foo/bar`
|
||||
* marks all paths within the `@foo/bar` package as excluded, including sub-paths like
|
||||
* `@foo/bar/baz`.
|
||||
*/
|
||||
exclude: string[];
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF"}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "Dev Server Target",
|
||||
"description": "Dev Server target options for Build Facade.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"buildTarget": {
|
||||
"type": "string",
|
||||
"description": "A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
|
||||
"pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
|
||||
},
|
||||
"port": {
|
||||
"type": "number",
|
||||
"description": "Port to listen on.",
|
||||
"default": 4200
|
||||
},
|
||||
"host": {
|
||||
"type": "string",
|
||||
"description": "Host to listen on.",
|
||||
"default": "localhost"
|
||||
},
|
||||
"proxyConfig": {
|
||||
"type": "string",
|
||||
"description": "Proxy configuration file. For more information, see https://angular.dev/tools/cli/serve#proxying-to-a-backend-server."
|
||||
},
|
||||
"ssl": {
|
||||
"type": "boolean",
|
||||
"description": "Serve using HTTPS.",
|
||||
"default": false
|
||||
},
|
||||
"sslKey": {
|
||||
"type": "string",
|
||||
"description": "SSL key to use for serving HTTPS."
|
||||
},
|
||||
"sslCert": {
|
||||
"type": "string",
|
||||
"description": "SSL certificate to use for serving HTTPS."
|
||||
},
|
||||
"allowedHosts": {
|
||||
"description": "The hosts that the development server will respond to. This option sets the Vite option of the same name. For further details: https://vite.dev/config/server-options.html#server-allowedhosts",
|
||||
"default": [],
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"description": "A list of hosts that the development server will respond to.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Indicates that all hosts are allowed. This is not recommended and a security risk."
|
||||
}
|
||||
]
|
||||
},
|
||||
"define": {
|
||||
"description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"type": "object",
|
||||
"description": "Custom HTTP headers to be added to all responses.",
|
||||
"propertyNames": {
|
||||
"pattern": "^[-_A-Za-z0-9]+$"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"open": {
|
||||
"type": "boolean",
|
||||
"description": "Opens the url in default browser.",
|
||||
"default": false,
|
||||
"alias": "o"
|
||||
},
|
||||
"verbose": {
|
||||
"type": "boolean",
|
||||
"description": "Adds more details to output logging."
|
||||
},
|
||||
"liveReload": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to reload the page on change, using live-reload.",
|
||||
"default": true
|
||||
},
|
||||
"servePath": {
|
||||
"type": "string",
|
||||
"description": "The pathname where the application will be served."
|
||||
},
|
||||
"hmr": {
|
||||
"type": "boolean",
|
||||
"description": "Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only global and component stylesheets are supported."
|
||||
},
|
||||
"watch": {
|
||||
"type": "boolean",
|
||||
"description": "Rebuild on change.",
|
||||
"default": true
|
||||
},
|
||||
"poll": {
|
||||
"type": "number",
|
||||
"description": "Enable and define the file watching poll time period in milliseconds."
|
||||
},
|
||||
"inspect": {
|
||||
"default": false,
|
||||
"description": "Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are enabled.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Activate the inspector on host and port in the format of `[[host:]port]`. See the security warning in https://nodejs.org/docs/latest-v22.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure regarding the host parameter usage."
|
||||
},
|
||||
{ "type": "boolean" }
|
||||
]
|
||||
},
|
||||
"prebundle": {
|
||||
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
|
||||
"default": true,
|
||||
"oneOf": [
|
||||
{ "type": "boolean" },
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exclude": {
|
||||
"description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself. Note: specifying `@foo/bar` marks all paths within the `@foo/bar` package as excluded, including sub-paths like `@foo/bar/baz`.",
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["exclude"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": ["buildTarget"]
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { ViteDevServer } from 'vite';
|
||||
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
|
||||
import type { NormalizedDevServerOptions } from '../options';
|
||||
import type { OutputAssetRecord, OutputFileRecord } from './utils';
|
||||
/**
|
||||
* Invalidates any updated asset or generated files and resets their `updated` state.
|
||||
* This function also clears the server application cache when necessary.
|
||||
*
|
||||
* @returns A list of files that were updated and invalidated.
|
||||
*/
|
||||
export declare function invalidateUpdatedFiles(normalizePath: (id: string) => string, generatedFiles: Map<string, OutputFileRecord>, assetFiles: Map<string, OutputAssetRecord>, server: ViteDevServer): Promise<string[]>;
|
||||
/**
|
||||
* Handles updates for the client by sending HMR or full page reload commands
|
||||
* based on the updated files. It also ensures proper tracking of component styles and determines if
|
||||
* a full reload is needed.
|
||||
*/
|
||||
export declare function handleUpdate(server: ViteDevServer, serverOptions: NormalizedDevServerOptions, logger: BuilderContext['logger'], componentStyles: Map<string, ComponentStyleRecord>, updatedFiles: string[]): void;
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.invalidateUpdatedFiles = invalidateUpdatedFiles;
|
||||
exports.handleUpdate = handleUpdate;
|
||||
const node_path_1 = require("node:path");
|
||||
const internal_1 = require("../internal");
|
||||
/**
|
||||
* Invalidates any updated asset or generated files and resets their `updated` state.
|
||||
* This function also clears the server application cache when necessary.
|
||||
*
|
||||
* @returns A list of files that were updated and invalidated.
|
||||
*/
|
||||
async function invalidateUpdatedFiles(normalizePath, generatedFiles, assetFiles, server) {
|
||||
const updatedFiles = [];
|
||||
// Invalidate any updated asset
|
||||
for (const [file, record] of assetFiles) {
|
||||
if (!record.updated) {
|
||||
continue;
|
||||
}
|
||||
record.updated = false;
|
||||
updatedFiles.push(file);
|
||||
}
|
||||
// Invalidate any updated files
|
||||
let serverApplicationChanged = false;
|
||||
for (const [file, record] of generatedFiles) {
|
||||
if (!record.updated) {
|
||||
continue;
|
||||
}
|
||||
record.updated = false;
|
||||
updatedFiles.push(file);
|
||||
serverApplicationChanged ||= record.type === internal_1.BuildOutputFileType.ServerApplication;
|
||||
const updatedModules = server.moduleGraph.getModulesByFile(normalizePath((0, node_path_1.join)(server.config.root, file)));
|
||||
updatedModules?.forEach((m) => server.moduleGraph.invalidateModule(m));
|
||||
}
|
||||
if (serverApplicationChanged) {
|
||||
// Clear the server app cache and trigger module evaluation before reload to initiate dependency optimization.
|
||||
// The querystring is needed as a workaround for:
|
||||
// `ɵgetOrCreateAngularServerApp` can be undefined right after an error.
|
||||
const { ɵdestroyAngularServerApp } = (await server.ssrLoadModule(`/main.server.mjs?timestamp=${Date.now()}`));
|
||||
ɵdestroyAngularServerApp();
|
||||
}
|
||||
return updatedFiles;
|
||||
}
|
||||
/**
|
||||
* Handles updates for the client by sending HMR or full page reload commands
|
||||
* based on the updated files. It also ensures proper tracking of component styles and determines if
|
||||
* a full reload is needed.
|
||||
*/
|
||||
function handleUpdate(server, serverOptions, logger, componentStyles, updatedFiles) {
|
||||
if (!updatedFiles.length) {
|
||||
return;
|
||||
}
|
||||
if (serverOptions.hmr) {
|
||||
if (updatedFiles.every((f) => f.endsWith('.css'))) {
|
||||
let requiresReload = false;
|
||||
const timestamp = Date.now();
|
||||
const updates = updatedFiles.flatMap((filePath) => {
|
||||
// For component styles, an HMR update must be sent for each one with the corresponding
|
||||
// component identifier search parameter (`ngcomp`). The Vite client code will not keep
|
||||
// the existing search parameters when it performs an update and each one must be
|
||||
// specified explicitly. Typically, there is only one each though as specific style files
|
||||
// are not typically reused across components.
|
||||
const record = componentStyles.get(filePath);
|
||||
if (record) {
|
||||
if (record.reload) {
|
||||
// Shadow DOM components currently require a full reload.
|
||||
// Vite's CSS hot replacement does not support shadow root searching.
|
||||
requiresReload = true;
|
||||
return [];
|
||||
}
|
||||
return Array.from(record.used ?? []).map((id) => {
|
||||
return {
|
||||
type: 'css-update',
|
||||
timestamp,
|
||||
path: `${filePath}?ngcomp` + (typeof id === 'string' ? `=${id}` : ''),
|
||||
acceptedPath: filePath,
|
||||
};
|
||||
});
|
||||
}
|
||||
return {
|
||||
type: 'css-update',
|
||||
timestamp,
|
||||
path: filePath,
|
||||
acceptedPath: filePath,
|
||||
};
|
||||
});
|
||||
if (!requiresReload) {
|
||||
server.ws.send({
|
||||
type: 'update',
|
||||
updates,
|
||||
});
|
||||
logger.info('Stylesheet update sent to client(s).');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Send reload command to clients
|
||||
if (serverOptions.liveReload) {
|
||||
// Clear used component tracking on full reload
|
||||
componentStyles.forEach((record) => record.used?.clear());
|
||||
server.ws.send({
|
||||
type: 'full-reload',
|
||||
path: '*',
|
||||
});
|
||||
logger.info('Page reload sent to client(s).');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=hmr.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hmr.js","sourceRoot":"","sources":["hmr.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiBH,wDAiDC;AAOD,oCAyEC;AA9ID,yCAAiC;AAGjC,0CAAkD;AAIlD;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB,CAC1C,aAAqC,EACrC,cAA6C,EAC7C,UAA0C,EAC1C,MAAqB;IAErB,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,+BAA+B;IAC/B,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,SAAS;QACX,CAAC;QAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,+BAA+B;IAC/B,IAAI,wBAAwB,GAAG,KAAK,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,cAAc,EAAE,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,SAAS;QACX,CAAC;QAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,wBAAwB,KAAK,MAAM,CAAC,IAAI,KAAK,8BAAmB,CAAC,iBAAiB,CAAC;QAEnF,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,CACxD,aAAa,CAAC,IAAA,gBAAI,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAC9C,CAAC;QACF,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,M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IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;wBAC9C,OAAO;4BACL,IAAI,EAAE,YAAqB;4BAC3B,SAAS;4BACT,IAAI,EAAE,GAAG,QAAQ,SAAS,GAAG,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;4BACrE,YAAY,EAAE,QAAQ;yBACvB,CAAC;oBACJ,CAAC,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,YAAqB;oBAC3B,SAAS;oBACT,IAAI,EAAE,QAAQ;oBACd,YAAY,EAAE,QAAQ;iBACvB,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;oBACb,IAAI,EAAE,QAAQ;oBACd,OAAO;iBACR,CAAC,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;gBAEpD,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;IAED,iCAAiC;IACjC,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QAC7B,+CAA+C;QAC/C,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAE1D,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;YACb,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,GAAG;SACV,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @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 { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { Plugin } from 'esbuild';
|
||||
import type { Connect } from 'vite';
|
||||
import { Result } from '../../application/results';
|
||||
import { type ApplicationBuilderInternalOptions } from '../internal';
|
||||
import type { NormalizedDevServerOptions } from '../options';
|
||||
import type { DevServerBuilderOutput } from '../output';
|
||||
export type BuilderAction = (options: ApplicationBuilderInternalOptions, context: BuilderContext, plugins?: Plugin[]) => AsyncIterable<Result>;
|
||||
export declare function serveWithVite(serverOptions: NormalizedDevServerOptions, builderName: string, builderAction: BuilderAction, context: BuilderContext, transformers?: {
|
||||
indexHtml?: (content: string) => Promise<string>;
|
||||
}, extensions?: {
|
||||
middleware?: Connect.NextHandleFunction[];
|
||||
buildPlugins?: Plugin[];
|
||||
}): AsyncIterableIterator<DevServerBuilderOutput>;
|
||||
+390
@@ -0,0 +1,390 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.serveWithVite = serveWithVite;
|
||||
const node_assert_1 = __importDefault(require("node:assert"));
|
||||
const node_path_1 = require("node:path");
|
||||
const plugins_1 = require("../../../tools/vite/plugins");
|
||||
const utils_1 = require("../../../tools/vite/utils");
|
||||
const utils_2 = require("../../../utils");
|
||||
const environment_options_1 = require("../../../utils/environment-options");
|
||||
const results_1 = require("../../application/results");
|
||||
const schema_1 = require("../../application/schema");
|
||||
const internal_1 = require("../internal");
|
||||
const hmr_1 = require("./hmr");
|
||||
const server_1 = require("./server");
|
||||
const utils_3 = require("./utils");
|
||||
/**
|
||||
* Build options that are also present on the dev server but are only passed
|
||||
* to the build.
|
||||
*/
|
||||
const CONVENIENCE_BUILD_OPTIONS = ['watch', 'poll', 'verbose', 'define'];
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
async function* serveWithVite(serverOptions, builderName, builderAction, context, transformers, extensions) {
|
||||
// Get the browser configuration from the target name.
|
||||
const rawBrowserOptions = await context.getTargetOptions(serverOptions.buildTarget);
|
||||
// Deploy url is not used in the dev-server.
|
||||
delete rawBrowserOptions.deployUrl;
|
||||
// Copy convenience options to build
|
||||
for (const optionName of CONVENIENCE_BUILD_OPTIONS) {
|
||||
const optionValue = serverOptions[optionName];
|
||||
if (optionValue !== undefined) {
|
||||
if (optionName === 'define' && rawBrowserOptions[optionName]) {
|
||||
// Define has merging behavior within the application
|
||||
for (const [key, value] of Object.entries(optionValue)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
rawBrowserOptions[optionName][key] = value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
rawBrowserOptions[optionName] = optionValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Adjust architect to not force a JsonObject derived return type
|
||||
const browserOptions = (await context.validateOptions(rawBrowserOptions, builderName));
|
||||
if (browserOptions.prerender || (browserOptions.outputMode && browserOptions.server)) {
|
||||
// Disable prerendering if enabled and force SSR.
|
||||
// This is so instead of prerendering all the routes for every change, the page is "prerendered" when it is requested.
|
||||
browserOptions.prerender = undefined;
|
||||
browserOptions.ssr ||= true;
|
||||
}
|
||||
// Vite allowedHost syntax doesn't allow `*.` but `.` acts as `*.`
|
||||
// Angular SSR supports `*.`.
|
||||
const allowedHosts = Array.isArray(serverOptions.allowedHosts)
|
||||
? serverOptions.allowedHosts.map((host) => (host[0] === '.' ? '*' + host : host))
|
||||
: [];
|
||||
// Always allow the dev server host
|
||||
allowedHosts.push(serverOptions.host);
|
||||
browserOptions.security = {
|
||||
allowedHosts,
|
||||
// Disable auto CSP.
|
||||
autoCsp: false,
|
||||
};
|
||||
// Disable JSON build stats.
|
||||
// These are not accessible with the dev server and can cause HMR fallbacks.
|
||||
if (browserOptions.statsJson === true) {
|
||||
context.logger.warn('Build JSON statistics output (`statsJson` option) has been disabled.' +
|
||||
' The development server does not support this option.');
|
||||
}
|
||||
browserOptions.statsJson = false;
|
||||
// Set all packages as external to support Vite's prebundle caching
|
||||
browserOptions.externalPackages = serverOptions.prebundle;
|
||||
// Disable generating a full manifest with routes.
|
||||
// This is done during runtime when using the dev-server.
|
||||
browserOptions.partialSSRBuild = true;
|
||||
// The development server currently only supports a single locale when localizing.
|
||||
// This matches the behavior of the Webpack-based development server but could be expanded in the future.
|
||||
if (browserOptions.localize === true ||
|
||||
(Array.isArray(browserOptions.localize) && browserOptions.localize.length > 1)) {
|
||||
context.logger.warn('Localization (`localize` option) has been disabled. The development server only supports localizing a single locale per build.');
|
||||
browserOptions.localize = false;
|
||||
}
|
||||
else if (browserOptions.localize) {
|
||||
// When localization is enabled with a single locale, force a flat path to maintain behavior with the existing Webpack-based dev server.
|
||||
browserOptions.forceI18nFlatOutput = true;
|
||||
}
|
||||
const { vendor: thirdPartySourcemaps, scripts: scriptsSourcemaps } = (0, utils_2.normalizeSourceMaps)(browserOptions.sourceMap ?? false);
|
||||
if (scriptsSourcemaps && browserOptions.server) {
|
||||
// https://nodejs.org/api/process.html#processsetsourcemapsenabledval
|
||||
process.setSourceMapsEnabled(true);
|
||||
}
|
||||
if (serverOptions.hmr &&
|
||||
(browserOptions.outputHashing === schema_1.OutputHashing.All ||
|
||||
browserOptions.outputHashing === schema_1.OutputHashing.Bundles)) {
|
||||
serverOptions.hmr = false;
|
||||
context.logger.warn(`Hot Module Replacement (HMR) is disabled because the 'outputHashing' option is set to '${browserOptions.outputHashing}'. ` +
|
||||
'HMR is incompatible with this setting.');
|
||||
}
|
||||
const componentsHmrCanBeUsed = browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
|
||||
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
|
||||
browserOptions.externalRuntimeStyles = componentsHmrCanBeUsed && environment_options_1.useComponentStyleHmr;
|
||||
// Enable to support component template hot replacement (`NG_HMR_TEMPLATE=0` can be used to disable selectively)
|
||||
// This will also replace file-based/inline styles as code if external runtime styles are not enabled.
|
||||
browserOptions.templateUpdates = componentsHmrCanBeUsed && environment_options_1.useComponentTemplateHmr;
|
||||
browserOptions.incrementalResults = true;
|
||||
// Setup the prebundling transformer that will be shared across Vite prebundling requests
|
||||
const prebundleTransformer = new internal_1.JavaScriptTransformer(
|
||||
// Always enable JIT linking to support applications built with and without AOT.
|
||||
// In a development environment the additional scope information does not
|
||||
// have a negative effect unlike production where final output size is relevant.
|
||||
{ sourcemap: true, jit: true, thirdPartySourcemaps }, 1);
|
||||
// The index HTML path will be updated from the build results if provided by the builder
|
||||
let htmlIndexPath = 'index.html';
|
||||
const { createServer, normalizePath } = await Promise.resolve().then(() => __importStar(require('vite')));
|
||||
let server;
|
||||
let serverUrl;
|
||||
let hadError = false;
|
||||
const generatedFiles = new Map();
|
||||
const assetFiles = new Map();
|
||||
const externalMetadata = {
|
||||
implicitBrowser: [],
|
||||
implicitServer: [],
|
||||
explicitBrowser: [],
|
||||
explicitServer: [],
|
||||
};
|
||||
const componentStyles = new Map();
|
||||
const templateUpdates = new Map();
|
||||
// Add cleanup logic via a builder teardown.
|
||||
let deferred;
|
||||
context.addTeardown(async () => {
|
||||
await server?.close();
|
||||
await prebundleTransformer.close();
|
||||
deferred?.();
|
||||
});
|
||||
// TODO: Switch this to an architect schedule call when infrastructure settings are supported
|
||||
for await (const result of builderAction(browserOptions, context, extensions?.buildPlugins)) {
|
||||
if (result.kind === results_1.ResultKind.Failure) {
|
||||
if (result.errors.length && server) {
|
||||
hadError = true;
|
||||
server.ws.send({
|
||||
type: 'error',
|
||||
err: {
|
||||
message: result.errors[0].text,
|
||||
stack: '',
|
||||
loc: result.errors[0].location ?? undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
yield { baseUrl: '', success: false };
|
||||
continue;
|
||||
}
|
||||
// Clear existing error overlay on successful result
|
||||
if (hadError && server) {
|
||||
hadError = false;
|
||||
// Send an empty update to clear the error overlay
|
||||
server.ws.send({
|
||||
'type': 'update',
|
||||
updates: [],
|
||||
});
|
||||
}
|
||||
let needClientUpdate = true;
|
||||
switch (result.kind) {
|
||||
case results_1.ResultKind.Full:
|
||||
if (result.detail?.['htmlIndexPath']) {
|
||||
htmlIndexPath = result.detail['htmlIndexPath'];
|
||||
}
|
||||
if (serverOptions.servePath === undefined && result.detail?.['htmlBaseHref']) {
|
||||
const baseHref = result.detail['htmlBaseHref'];
|
||||
// Remove trailing slash
|
||||
serverOptions.servePath =
|
||||
baseHref !== './' && baseHref.at(-1) === '/' ? baseHref.slice(0, -1) : baseHref;
|
||||
}
|
||||
assetFiles.clear();
|
||||
componentStyles.clear();
|
||||
generatedFiles.clear();
|
||||
for (const [outputPath, file] of Object.entries(result.files)) {
|
||||
(0, utils_3.updateResultRecord)(outputPath, file, normalizePath, htmlIndexPath, generatedFiles, assetFiles, componentStyles,
|
||||
// The initial build will not yet have a server setup
|
||||
!server);
|
||||
}
|
||||
// Clear stale template updates on code rebuilds
|
||||
templateUpdates.clear();
|
||||
break;
|
||||
case results_1.ResultKind.Incremental:
|
||||
(0, node_assert_1.default)(server, 'Builder must provide an initial full build before incremental results.');
|
||||
// Background updates should only update server files/options
|
||||
needClientUpdate = !result.background;
|
||||
for (const removed of result.removed) {
|
||||
const filePath = '/' + normalizePath(removed.path);
|
||||
generatedFiles.delete(filePath);
|
||||
assetFiles.delete(filePath);
|
||||
}
|
||||
for (const modified of result.modified) {
|
||||
(0, utils_3.updateResultRecord)(modified, result.files[modified], normalizePath, htmlIndexPath, generatedFiles, assetFiles, componentStyles);
|
||||
}
|
||||
for (const added of result.added) {
|
||||
(0, utils_3.updateResultRecord)(added, result.files[added], normalizePath, htmlIndexPath, generatedFiles, assetFiles, componentStyles);
|
||||
}
|
||||
break;
|
||||
case results_1.ResultKind.ComponentUpdate:
|
||||
(0, node_assert_1.default)(serverOptions.hmr, 'Component updates are only supported with HMR enabled.');
|
||||
(0, node_assert_1.default)(server, 'Builder must provide an initial full build before component update results.');
|
||||
for (const componentUpdate of result.updates) {
|
||||
if (componentUpdate.type === 'template') {
|
||||
templateUpdates.set(componentUpdate.id, componentUpdate.content);
|
||||
server.ws.send('angular:component-update', {
|
||||
id: componentUpdate.id,
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
}
|
||||
}
|
||||
context.logger.info('Component update sent to client(s).');
|
||||
continue;
|
||||
default:
|
||||
context.logger.warn(`Unknown result kind [${result.kind}] provided by build.`);
|
||||
continue;
|
||||
}
|
||||
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
|
||||
(0, utils_1.updateExternalMetadata)(result, externalMetadata, browserOptions.externalDependencies);
|
||||
if (server) {
|
||||
// Update fs allow list to include any new assets from the build option.
|
||||
server.config.server.fs.allow = [
|
||||
...new Set([
|
||||
...server.config.server.fs.allow,
|
||||
...[...assetFiles.values()].map(({ source }) => source),
|
||||
]),
|
||||
];
|
||||
const updatedFiles = await (0, hmr_1.invalidateUpdatedFiles)(normalizePath, generatedFiles, assetFiles, server);
|
||||
if (needClientUpdate) {
|
||||
(0, hmr_1.handleUpdate)(server, serverOptions, context.logger, componentStyles, updatedFiles);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const projectName = context.target?.project;
|
||||
if (!projectName) {
|
||||
throw new Error('The builder requires a target.');
|
||||
}
|
||||
context.logger.info('NOTE: Raw file sizes do not reflect development server per-request transformations.');
|
||||
if (browserOptions.ssr && serverOptions.inspect) {
|
||||
const { host, port } = serverOptions.inspect;
|
||||
const { default: inspector } = await Promise.resolve().then(() => __importStar(require('node:inspector')));
|
||||
inspector.open(port, host, true);
|
||||
context.addTeardown(() => inspector.close());
|
||||
}
|
||||
const { root = '' } = await context.getProjectMetadata(projectName);
|
||||
const projectRoot = (0, node_path_1.join)(context.workspaceRoot, root);
|
||||
const browsers = (0, internal_1.getSupportedBrowsers)(projectRoot, context.logger);
|
||||
const target = (0, internal_1.transformSupportedBrowsersToTargets)(browsers);
|
||||
// Needed for browser-esbuild as polyfills can be a string.
|
||||
const polyfills = Array.isArray((browserOptions.polyfills ??= []))
|
||||
? browserOptions.polyfills
|
||||
: [browserOptions.polyfills];
|
||||
let ssrMode = plugins_1.ServerSsrMode.NoSsr;
|
||||
if (browserOptions.outputMode &&
|
||||
typeof browserOptions.ssr === 'object' &&
|
||||
browserOptions.ssr.entry) {
|
||||
ssrMode = plugins_1.ServerSsrMode.ExternalSsrMiddleware;
|
||||
}
|
||||
else if (browserOptions.ssr) {
|
||||
ssrMode = plugins_1.ServerSsrMode.InternalSsrMiddleware;
|
||||
}
|
||||
if (browserOptions.progress !== false && ssrMode !== plugins_1.ServerSsrMode.NoSsr) {
|
||||
// This is a workaround for https://github.com/angular/angular-cli/issues/28336, which is caused by the interaction between `zone.js` and `listr2`.
|
||||
process.once('SIGINT', () => {
|
||||
process.kill(process.pid);
|
||||
});
|
||||
}
|
||||
// Setup server and start listening
|
||||
const serverConfiguration = await (0, server_1.setupServer)(serverOptions, generatedFiles, assetFiles, browserOptions.preserveSymlinks, externalMetadata, ssrMode, prebundleTransformer, target, (0, internal_1.isZonelessApp)(polyfills), componentStyles, templateUpdates, browserOptions.loader, {
|
||||
...browserOptions.define,
|
||||
'ngJitMode': browserOptions.aot ? 'false' : 'true',
|
||||
'ngHmrMode': browserOptions.templateUpdates ? 'true' : 'false',
|
||||
}, extensions?.middleware, transformers?.indexHtml, thirdPartySourcemaps);
|
||||
server = await createServer(serverConfiguration);
|
||||
await server.listen();
|
||||
// Setup builder context logging for browser clients
|
||||
server.hot.on('angular:log', (data) => {
|
||||
if (typeof data?.text !== 'string') {
|
||||
context.logger.warn('Development server client sent invalid internal log event.');
|
||||
}
|
||||
switch (data.kind) {
|
||||
case 'error':
|
||||
context.logger.error(`[CLIENT ERROR]: ${data.text}`);
|
||||
break;
|
||||
case 'warning':
|
||||
context.logger.warn(`[CLIENT WARNING]: ${data.text}`);
|
||||
break;
|
||||
default:
|
||||
context.logger.info(`[CLIENT INFO]: ${data.text}`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
// Setup component HMR invalidation
|
||||
// Invalidation occurs when the runtime cannot update a component
|
||||
server.hot.on('angular:invalidate', (data) => {
|
||||
if (typeof data?.id !== 'string') {
|
||||
context.logger.warn('Development server client sent invalid internal invalidate event.');
|
||||
}
|
||||
// Clear invalid template update
|
||||
templateUpdates.delete(data.id);
|
||||
// Some cases are expected unsupported update scenarios but some may be errors.
|
||||
// If an error occurred, log the error in addition to the invalidation.
|
||||
if (data.error) {
|
||||
context.logger.error(`Component update failed${data.message ? `: ${data.message}` : '.'}` +
|
||||
'\nPlease consider reporting the error at https://github.com/angular/angular-cli/issues');
|
||||
}
|
||||
else {
|
||||
context.logger.warn(`Component update unsupported${data.message ? `: ${data.message}` : '.'}`);
|
||||
}
|
||||
server?.ws.send({
|
||||
type: 'full-reload',
|
||||
path: '*',
|
||||
});
|
||||
context.logger.info('Page reload sent to client(s).');
|
||||
});
|
||||
const urls = server.resolvedUrls;
|
||||
if (urls && (urls.local.length || urls.network.length)) {
|
||||
serverUrl = new URL(urls.local[0] ?? urls.network[0]);
|
||||
}
|
||||
// log connection information
|
||||
server.printUrls();
|
||||
server.bindCLIShortcuts({
|
||||
print: true,
|
||||
customShortcuts: [
|
||||
{
|
||||
key: 'r',
|
||||
description: 'force reload browser',
|
||||
action(server) {
|
||||
componentStyles.forEach((record) => record.used?.clear());
|
||||
server.ws.send({
|
||||
type: 'full-reload',
|
||||
path: '*',
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
// TODO: adjust output typings to reflect both development servers
|
||||
yield {
|
||||
success: true,
|
||||
port: serverUrl?.port,
|
||||
baseUrl: serverUrl?.href,
|
||||
};
|
||||
}
|
||||
await new Promise((resolve) => (deferred = resolve));
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 { Connect, InlineConfig } from 'vite';
|
||||
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
|
||||
import { ServerSsrMode } from '../../../tools/vite/plugins';
|
||||
import { EsbuildLoaderOption } from '../../../tools/vite/utils';
|
||||
import { type ApplicationBuilderInternalOptions, JavaScriptTransformer } from '../internal';
|
||||
import type { NormalizedDevServerOptions } from '../options';
|
||||
import { DevServerExternalResultMetadata, OutputAssetRecord, OutputFileRecord } from './utils';
|
||||
export declare function setupServer(serverOptions: NormalizedDevServerOptions, outputFiles: Map<string, OutputFileRecord>, assets: Map<string, OutputAssetRecord>, preserveSymlinks: boolean | undefined, externalMetadata: DevServerExternalResultMetadata, ssrMode: ServerSsrMode, prebundleTransformer: JavaScriptTransformer, target: string[], zoneless: boolean, componentStyles: Map<string, ComponentStyleRecord>, templateUpdates: Map<string, string>, prebundleLoaderExtensions: EsbuildLoaderOption | undefined, define: ApplicationBuilderInternalOptions['define'], extensionMiddleware?: Connect.NextHandleFunction[], indexHtmlTransformer?: (content: string) => Promise<string>, thirdPartySourcemaps?: boolean): Promise<InlineConfig>;
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupServer = setupServer;
|
||||
const promises_1 = require("node:fs/promises");
|
||||
const node_path_1 = require("node:path");
|
||||
const plugins_1 = require("../../../tools/vite/plugins");
|
||||
const utils_1 = require("../../../tools/vite/utils");
|
||||
const utils_2 = require("../../../utils");
|
||||
async function createServerConfig(serverOptions, assets, ssrMode, preTransformRequests, cacheDir) {
|
||||
const proxy = await (0, utils_2.loadProxyConfiguration)(serverOptions.workspaceRoot, serverOptions.proxyConfig);
|
||||
// Files used for SSR warmup.
|
||||
let ssrFiles;
|
||||
switch (ssrMode) {
|
||||
case plugins_1.ServerSsrMode.InternalSsrMiddleware:
|
||||
ssrFiles = ['./main.server.mjs'];
|
||||
break;
|
||||
case plugins_1.ServerSsrMode.ExternalSsrMiddleware:
|
||||
ssrFiles = ['./main.server.mjs', './server.mjs'];
|
||||
break;
|
||||
}
|
||||
const server = {
|
||||
preTransformRequests,
|
||||
warmup: {
|
||||
ssrFiles,
|
||||
},
|
||||
port: serverOptions.port,
|
||||
strictPort: true,
|
||||
host: serverOptions.host,
|
||||
open: serverOptions.open,
|
||||
allowedHosts: serverOptions.allowedHosts,
|
||||
headers: serverOptions.headers,
|
||||
// Disable the websocket if live reload is disabled (false/undefined are the only valid values)
|
||||
ws: serverOptions.liveReload === false && serverOptions.hmr === false ? false : undefined,
|
||||
proxy,
|
||||
cors: {
|
||||
// This will add the header `Access-Control-Allow-Origin: http://example.com`,
|
||||
// where `http://example.com` is the requesting origin.
|
||||
origin: true,
|
||||
// Allow preflight requests to be proxied.
|
||||
preflightContinue: true,
|
||||
},
|
||||
// File watching is handled by the build directly. `null` disables file watching for Vite.
|
||||
watch: null,
|
||||
fs: {
|
||||
// Ensure cache directory, node modules, and all assets are accessible by the client.
|
||||
// The first two are required for Vite to function in prebundling mode (the default) and to load
|
||||
// the Vite client-side code for browser reloading. These would be available by default but when
|
||||
// the `allow` option is explicitly configured, they must be included manually.
|
||||
allow: [
|
||||
cacheDir,
|
||||
(0, node_path_1.join)(serverOptions.workspaceRoot, 'node_modules'),
|
||||
...[...assets.values()].map(({ source }) => source),
|
||||
],
|
||||
},
|
||||
};
|
||||
if (serverOptions.ssl) {
|
||||
if (serverOptions.sslCert && serverOptions.sslKey) {
|
||||
server.https = {
|
||||
cert: await (0, promises_1.readFile)(serverOptions.sslCert),
|
||||
key: await (0, promises_1.readFile)(serverOptions.sslKey),
|
||||
};
|
||||
}
|
||||
}
|
||||
return server;
|
||||
}
|
||||
function createSsrConfig(externalMetadata, serverOptions, prebundleTransformer, zoneless, target, prebundleLoaderExtensions, thirdPartySourcemaps, define) {
|
||||
return {
|
||||
// Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
|
||||
noExternal: /.*/,
|
||||
// Exclude any Node.js built in module and provided dependencies (currently build defined externals)
|
||||
external: externalMetadata.explicitServer,
|
||||
optimizeDeps: (0, utils_1.getDepOptimizationConfig)({
|
||||
// Only enable with caching since it causes prebundle dependencies to be cached
|
||||
disabled: serverOptions.prebundle === false,
|
||||
// Exclude any explicitly defined dependencies (currently build defined externals and node.js built-ins)
|
||||
exclude: externalMetadata.explicitServer,
|
||||
// Include all implict dependencies from the external packages internal option
|
||||
include: externalMetadata.implicitServer,
|
||||
ssr: true,
|
||||
prebundleTransformer,
|
||||
zoneless,
|
||||
target,
|
||||
loader: prebundleLoaderExtensions,
|
||||
thirdPartySourcemaps,
|
||||
define,
|
||||
}),
|
||||
};
|
||||
}
|
||||
async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks, externalMetadata, ssrMode, prebundleTransformer, target, zoneless, componentStyles, templateUpdates, prebundleLoaderExtensions, define, extensionMiddleware, indexHtmlTransformer, thirdPartySourcemaps = false) {
|
||||
const { normalizePath } = await Promise.resolve().then(() => __importStar(require('vite')));
|
||||
// Path will not exist on disk and only used to provide separate path for Vite requests
|
||||
const virtualProjectRoot = normalizePath((0, node_path_1.join)(serverOptions.workspaceRoot, `.angular/vite-root`, serverOptions.buildTarget.project));
|
||||
/**
|
||||
* Required when using `externalDependencies` to prevent Vite load errors.
|
||||
*
|
||||
* @note Can be removed if Vite introduces native support for externals.
|
||||
* @note Vite misresolves browser modules in SSR when accessing URLs with multiple segments
|
||||
* (e.g., 'foo/bar'), as they are not correctly re-based from the base href.
|
||||
*/
|
||||
const preTransformRequests = externalMetadata.explicitBrowser.length === 0 && ssrMode === plugins_1.ServerSsrMode.NoSsr;
|
||||
const cacheDir = (0, node_path_1.join)(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
|
||||
const configuration = {
|
||||
configFile: false,
|
||||
envFile: false,
|
||||
cacheDir,
|
||||
root: virtualProjectRoot,
|
||||
publicDir: false,
|
||||
esbuild: false,
|
||||
mode: 'development',
|
||||
// We use custom as we do not rely on Vite's htmlFallbackMiddleware and indexHtmlMiddleware.
|
||||
appType: 'custom',
|
||||
css: {
|
||||
devSourcemap: true,
|
||||
},
|
||||
// Ensure custom 'file' loader build option entries are handled by Vite in application code that
|
||||
// reference third-party libraries. Relative usage is handled directly by the build and not Vite.
|
||||
// Only 'file' loader entries are currently supported directly by Vite.
|
||||
assetsInclude: prebundleLoaderExtensions &&
|
||||
Object.entries(prebundleLoaderExtensions)
|
||||
.filter(([, value]) => value === 'file')
|
||||
// Create a file extension glob for each key
|
||||
.map(([key]) => '*' + key),
|
||||
// Vite will normalize the `base` option by adding a leading slash.
|
||||
base: serverOptions.servePath,
|
||||
resolve: {
|
||||
mainFields: ['es2020', 'browser', 'module', 'main'],
|
||||
preserveSymlinks,
|
||||
},
|
||||
dev: {
|
||||
preTransformRequests,
|
||||
},
|
||||
server: await createServerConfig(serverOptions, assets, ssrMode, preTransformRequests, cacheDir),
|
||||
ssr: ssrMode === plugins_1.ServerSsrMode.NoSsr
|
||||
? undefined
|
||||
: createSsrConfig(externalMetadata, serverOptions, prebundleTransformer, zoneless, target, prebundleLoaderExtensions, thirdPartySourcemaps, define),
|
||||
plugins: [
|
||||
(0, plugins_1.createAngularSetupMiddlewaresPlugin)({
|
||||
outputFiles,
|
||||
assets,
|
||||
indexHtmlTransformer,
|
||||
extensionMiddleware,
|
||||
componentStyles,
|
||||
templateUpdates,
|
||||
ssrMode,
|
||||
resetComponentUpdates: () => templateUpdates.clear(),
|
||||
projectRoot: serverOptions.projectRoot,
|
||||
}),
|
||||
(0, plugins_1.createRemoveIdPrefixPlugin)(externalMetadata.explicitBrowser),
|
||||
await (0, plugins_1.createAngularSsrTransformPlugin)(serverOptions.workspaceRoot),
|
||||
await (0, plugins_1.createAngularMemoryPlugin)({
|
||||
virtualProjectRoot,
|
||||
outputFiles,
|
||||
templateUpdates,
|
||||
external: externalMetadata.explicitBrowser,
|
||||
disableViteTransport: !serverOptions.liveReload,
|
||||
}),
|
||||
],
|
||||
// Browser only optimizeDeps. (This does not run for SSR dependencies).
|
||||
optimizeDeps: (0, utils_1.getDepOptimizationConfig)({
|
||||
// Only enable with caching since it causes prebundle dependencies to be cached
|
||||
disabled: serverOptions.prebundle === false,
|
||||
// Exclude any explicitly defined dependencies (currently build defined externals)
|
||||
exclude: externalMetadata.explicitBrowser,
|
||||
// Include all implict dependencies from the external packages internal option
|
||||
include: externalMetadata.implicitBrowser,
|
||||
ssr: false,
|
||||
prebundleTransformer,
|
||||
target,
|
||||
zoneless,
|
||||
loader: prebundleLoaderExtensions,
|
||||
thirdPartySourcemaps,
|
||||
define,
|
||||
}),
|
||||
};
|
||||
if (serverOptions.ssl) {
|
||||
configuration.plugins ??= [];
|
||||
if (!serverOptions.sslCert || !serverOptions.sslKey) {
|
||||
const { default: basicSslPlugin } = await Promise.resolve().then(() => __importStar(require('@vitejs/plugin-basic-ssl')));
|
||||
configuration.plugins.push(basicSslPlugin());
|
||||
}
|
||||
if (ssrMode !== plugins_1.ServerSsrMode.NoSsr) {
|
||||
configuration.plugins?.push((0, plugins_1.createAngularServerSideSSLPlugin)());
|
||||
}
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
//# sourceMappingURL=server.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @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 { ComponentStyleRecord } from '../../../tools/vite/middlewares';
|
||||
import type { ResultFile } from '../../application/results';
|
||||
import { BuildOutputFileType, type ExternalResultMetadata } from '../internal';
|
||||
export interface OutputFileRecord {
|
||||
contents: Uint8Array;
|
||||
size: number;
|
||||
hash: string;
|
||||
updated: boolean;
|
||||
servable: boolean;
|
||||
type: BuildOutputFileType;
|
||||
}
|
||||
export interface OutputAssetRecord {
|
||||
source: string;
|
||||
updated: boolean;
|
||||
}
|
||||
export interface DevServerExternalResultMetadata extends Omit<ExternalResultMetadata, 'explicit'> {
|
||||
explicitBrowser: string[];
|
||||
explicitServer: string[];
|
||||
}
|
||||
export declare function updateResultRecord(outputPath: string, file: ResultFile, normalizePath: (id: string) => string, htmlIndexPath: string, generatedFiles: Map<string, OutputFileRecord>, assetFiles: Map<string, OutputAssetRecord>, componentStyles: Map<string, ComponentStyleRecord>, initial?: boolean): void;
|
||||
/**
|
||||
* Checks if the given value is an absolute URL.
|
||||
*
|
||||
* This function helps in avoiding Vite's prebundling from processing absolute URLs (http://, https://, //) as files.
|
||||
*
|
||||
* @param value - The URL or path to check.
|
||||
* @returns `true` if the value is not an absolute URL; otherwise, `false`.
|
||||
*/
|
||||
export declare function isAbsoluteUrl(value: string): boolean;
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateResultRecord = updateResultRecord;
|
||||
exports.isAbsoluteUrl = isAbsoluteUrl;
|
||||
const internal_1 = require("../internal");
|
||||
function updateResultRecord(outputPath, file, normalizePath, htmlIndexPath, generatedFiles, assetFiles, componentStyles, initial = false) {
|
||||
if (file.origin === 'disk') {
|
||||
assetFiles.set('/' + normalizePath(outputPath), {
|
||||
source: normalizePath(file.inputPath),
|
||||
updated: !initial,
|
||||
});
|
||||
return;
|
||||
}
|
||||
let filePath;
|
||||
if (outputPath === htmlIndexPath) {
|
||||
// Convert custom index output path to standard index path for dev-server usage.
|
||||
// This mimics the Webpack dev-server behavior.
|
||||
filePath = '/index.html';
|
||||
}
|
||||
else {
|
||||
filePath = '/' + normalizePath(outputPath);
|
||||
}
|
||||
const servable = file.type === internal_1.BuildOutputFileType.Browser || file.type === internal_1.BuildOutputFileType.Media;
|
||||
// Skip analysis of sourcemaps
|
||||
if (filePath.endsWith('.map')) {
|
||||
generatedFiles.set(filePath, {
|
||||
contents: file.contents,
|
||||
servable,
|
||||
size: file.contents.byteLength,
|
||||
hash: file.hash,
|
||||
type: file.type,
|
||||
updated: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
// New or updated file
|
||||
generatedFiles.set(filePath, {
|
||||
contents: file.contents,
|
||||
size: file.contents.byteLength,
|
||||
hash: file.hash,
|
||||
// Consider the files updated except on the initial build result
|
||||
updated: !initial,
|
||||
type: file.type,
|
||||
servable,
|
||||
});
|
||||
// Record any external component styles
|
||||
if (filePath.endsWith('.css') && /^\/[a-f0-9]{64}\.css$/.test(filePath)) {
|
||||
const componentStyle = componentStyles.get(filePath);
|
||||
if (componentStyle) {
|
||||
componentStyle.rawContent = file.contents;
|
||||
}
|
||||
else {
|
||||
componentStyles.set(filePath, {
|
||||
rawContent: file.contents,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if the given value is an absolute URL.
|
||||
*
|
||||
* This function helps in avoiding Vite's prebundling from processing absolute URLs (http://, https://, //) as files.
|
||||
*
|
||||
* @param value - The URL or path to check.
|
||||
* @returns `true` if the value is not an absolute URL; otherwise, `false`.
|
||||
*/
|
||||
function isAbsoluteUrl(value) {
|
||||
return /^(?:https?:)?\/\//.test(value);
|
||||
}
|
||||
//# sourceMappingURL=utils.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAyBH,gDAmEC;AAUD,sCAEC;AApGD,0CAA+E;AAqB/E,SAAgB,kBAAkB,CAChC,UAAkB,EAClB,IAAgB,EAChB,aAAqC,EACrC,aAAqB,EACrB,cAA6C,EAC7C,UAA0C,EAC1C,eAAkD,EAClD,OAAO,GAAG,KAAK;IAEf,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;YACrC,OAAO,EAAE,CAAC,OAAO;SAClB,CAAC,CAAC;QAEH,OAAO;IACT,CAAC;IAED,IAAI,QAAQ,CAAC;IACb,IAAI,UAAU,KAAK,aAAa,EAAE,CAAC;QACjC,gFAAgF;QAChF,+CAA+C;QAC/C,QAAQ,GAAG,aAAa,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,QAAQ,GACZ,IAAI,CAAC,IAAI,KAAK,8BAAmB,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I,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC"}
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @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 { ɵParsedMessage as LocalizeMessage } from '@angular/localize';
|
||||
import type { MessageExtractor } from '@angular/localize/tools';
|
||||
import type { BuilderContext } from '@angular-devkit/architect';
|
||||
import type { ApplicationBuilderExtensions } from '../application/options';
|
||||
import type { NormalizedExtractI18nOptions } from './options';
|
||||
export declare function extractMessages(options: NormalizedExtractI18nOptions, builderName: string, context: BuilderContext, extractorConstructor: typeof MessageExtractor, extensions?: ApplicationBuilderExtensions): Promise<{
|
||||
success: boolean;
|
||||
basePath: string;
|
||||
messages: LocalizeMessage[];
|
||||
useLegacyIds: boolean;
|
||||
}>;
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extractMessages = extractMessages;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const application_1 = require("../application");
|
||||
const results_1 = require("../application/results");
|
||||
const schema_1 = require("../application/schema");
|
||||
async function extractMessages(options, builderName, context, extractorConstructor, extensions) {
|
||||
const messages = [];
|
||||
// Setup the build options for the application based on the buildTarget option
|
||||
const buildOptions = (await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName));
|
||||
buildOptions.optimization = false;
|
||||
buildOptions.sourceMap = { scripts: true, vendor: true, styles: false };
|
||||
buildOptions.localize = false;
|
||||
buildOptions.budgets = undefined;
|
||||
buildOptions.index = false;
|
||||
buildOptions.serviceWorker = false;
|
||||
buildOptions.outputMode = schema_1.OutputMode.Static;
|
||||
buildOptions.appShell = undefined;
|
||||
buildOptions.ssr = undefined;
|
||||
buildOptions.prerender = undefined;
|
||||
buildOptions.server = undefined;
|
||||
// Build the application with the build options
|
||||
const builderResult = await first((0, application_1.buildApplicationInternal)(buildOptions, context, extensions));
|
||||
let success = false;
|
||||
if (!builderResult || builderResult.kind === results_1.ResultKind.Failure) {
|
||||
context.logger.error('Application build failed.');
|
||||
}
|
||||
else if (builderResult.kind !== results_1.ResultKind.Full) {
|
||||
context.logger.error('Application build did not provide a full output.');
|
||||
}
|
||||
else {
|
||||
// Setup the localize message extractor based on the in-memory files
|
||||
const extractor = setupLocalizeExtractor(extractorConstructor, builderResult.files, context);
|
||||
// Extract messages from each output JavaScript file.
|
||||
// Output files are only present on a successful build.
|
||||
for (const filePath of Object.keys(builderResult.files)) {
|
||||
if (!filePath.endsWith('.js')) {
|
||||
continue;
|
||||
}
|
||||
const fileMessages = extractor.extractMessages(filePath);
|
||||
messages.push(...fileMessages);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
return {
|
||||
success,
|
||||
basePath: context.workspaceRoot,
|
||||
messages,
|
||||
// Legacy i18n identifiers are not supported with the new application builder
|
||||
useLegacyIds: false,
|
||||
};
|
||||
}
|
||||
function setupLocalizeExtractor(extractorConstructor, files, context) {
|
||||
const textDecoder = new TextDecoder();
|
||||
// Setup a virtual file system instance for the extractor
|
||||
// * MessageExtractor itself uses readFile, relative and resolve
|
||||
// * Internal SourceFileLoader (sourcemap support) uses dirname, exists, readFile, and resolve
|
||||
const filesystem = {
|
||||
readFile(path) {
|
||||
// Output files are stored as relative to the workspace root
|
||||
const requestedPath = node_path_1.default.relative(context.workspaceRoot, path);
|
||||
const file = files[requestedPath];
|
||||
let content;
|
||||
if (file?.origin === 'memory') {
|
||||
content = textDecoder.decode(file.contents);
|
||||
}
|
||||
else if (file?.origin === 'disk') {
|
||||
content = (0, node_fs_1.readFileSync)(file.inputPath, 'utf-8');
|
||||
}
|
||||
if (content === undefined) {
|
||||
throw new Error('Unknown file requested: ' + requestedPath);
|
||||
}
|
||||
return content;
|
||||
},
|
||||
relative(from, to) {
|
||||
return node_path_1.default.relative(from, to);
|
||||
},
|
||||
resolve(...paths) {
|
||||
return node_path_1.default.resolve(...paths);
|
||||
},
|
||||
exists(path) {
|
||||
// Output files are stored as relative to the workspace root
|
||||
const requestedPath = node_path_1.default.relative(context.workspaceRoot, path);
|
||||
return files[requestedPath] !== undefined;
|
||||
},
|
||||
dirname(path) {
|
||||
return node_path_1.default.dirname(path);
|
||||
},
|
||||
};
|
||||
const logger = {
|
||||
// level 2 is warnings
|
||||
level: 2,
|
||||
debug(...args) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(...args);
|
||||
},
|
||||
info(...args) {
|
||||
context.logger.info(args.join(''));
|
||||
},
|
||||
warn(...args) {
|
||||
context.logger.warn(args.join(''));
|
||||
},
|
||||
error(...args) {
|
||||
context.logger.error(args.join(''));
|
||||
},
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const extractor = new extractorConstructor(filesystem, logger, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
basePath: context.workspaceRoot,
|
||||
useSourceMaps: true,
|
||||
});
|
||||
return extractor;
|
||||
}
|
||||
async function first(iterable) {
|
||||
for await (const value of iterable) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=application-extraction.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"application-extraction.js","sourceRoot":"","sources":["application-extraction.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAgBH,0CAgEC;AA3ED,qCAAuC;AACvC,0DAAiC;AACjC,gDAA0D;AAK1D,oDAAgE;AAChE,kDA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,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,CAAC,GAAG,IAAc;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;IAEF,8DAA8D;IAC9D,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,UAAiB,EAAE,MAAM,EAAE;QACpE,8DAA8D;QAC9D,QAAQ,EAAE,OAAO,CAAC,aAAoB;QACtC,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,KAAK,CAAI,QAA0B;IAChD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @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 { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
||||
import type { ApplicationBuilderExtensions } from '../application/options';
|
||||
import { Schema as ExtractI18nBuilderOptions } from './schema';
|
||||
/**
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*/
|
||||
export declare function execute(options: ExtractI18nBuilderOptions, context: BuilderContext, extensions?: ApplicationBuilderExtensions): Promise<BuilderOutput>;
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.execute = execute;
|
||||
const node_fs_1 = __importDefault(require("node:fs"));
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const version_1 = require("../../utils/version");
|
||||
const options_1 = require("./options");
|
||||
const schema_1 = require("./schema");
|
||||
/**
|
||||
* @experimental Direct usage of this function is considered experimental.
|
||||
*/
|
||||
async function execute(options, context, extensions) {
|
||||
// Determine project name from builder context target
|
||||
const projectName = context.target?.project;
|
||||
if (!projectName) {
|
||||
context.logger.error(`The 'extract-i18n' builder requires a target to be specified.`);
|
||||
return { success: false };
|
||||
}
|
||||
const { projectType } = (await context.getProjectMetadata(projectName));
|
||||
if (projectType !== 'application') {
|
||||
context.logger.error(`Tried to extract from ${projectName} with 'projectType' ${projectType}, which is not supported.` +
|
||||
` The 'extract-i18n' builder can only extract from applications.`);
|
||||
return { success: false };
|
||||
}
|
||||
// Check Angular version.
|
||||
(0, version_1.assertCompatibleAngularVersion)(context.workspaceRoot);
|
||||
// Load the Angular localize package.
|
||||
// The package is a peer dependency and might not be present
|
||||
let localizeToolsModule;
|
||||
try {
|
||||
localizeToolsModule = await Promise.resolve().then(() => __importStar(require('@angular/localize/tools')));
|
||||
}
|
||||
catch {
|
||||
return {
|
||||
success: false,
|
||||
error: `i18n extraction requires the '@angular/localize' package.` +
|
||||
` You can add it by using 'ng add @angular/localize'.`,
|
||||
};
|
||||
}
|
||||
// Normalize options
|
||||
const normalizedOptions = await (0, options_1.normalizeOptions)(context, projectName, options);
|
||||
const builderName = await context.getBuilderNameForTarget(normalizedOptions.buildTarget);
|
||||
// Extract messages based on configured builder
|
||||
const { extractMessages } = await Promise.resolve().then(() => __importStar(require('./application-extraction')));
|
||||
const extractionResult = await extractMessages(normalizedOptions, builderName, context, localizeToolsModule.MessageExtractor, extensions);
|
||||
if (!extractionResult.success) {
|
||||
return { success: false };
|
||||
}
|
||||
// Perform duplicate message checks
|
||||
const { checkDuplicateMessages } = localizeToolsModule;
|
||||
// The filesystem is used to create a relative path for each file
|
||||
// from the basePath. This relative path is then used in the error message.
|
||||
const checkFileSystem = {
|
||||
relative(from, to) {
|
||||
return node_path_1.default.relative(from, to);
|
||||
},
|
||||
};
|
||||
const duplicateTranslationBehavior = normalizedOptions.i18nOptions.duplicateTranslationBehavior;
|
||||
const diagnostics = checkDuplicateMessages(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
checkFileSystem, extractionResult.messages, duplicateTranslationBehavior,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
extractionResult.basePath);
|
||||
if (diagnostics.messages.length > 0 && duplicateTranslationBehavior !== 'ignore') {
|
||||
if (duplicateTranslationBehavior === 'error') {
|
||||
context.logger.error(`Extraction Failed: ${diagnostics.formatDiagnostics('')}`);
|
||||
return { success: false };
|
||||
}
|
||||
else {
|
||||
context.logger.warn(diagnostics.formatDiagnostics(''));
|
||||
}
|
||||
}
|
||||
// Serialize all extracted messages
|
||||
const serializer = await createSerializer(localizeToolsModule, normalizedOptions.format, normalizedOptions.i18nOptions.sourceLocale, extractionResult.basePath, extractionResult.useLegacyIds, diagnostics);
|
||||
const content = serializer.serialize(extractionResult.messages);
|
||||
// Ensure directory exists
|
||||
const outputPath = node_path_1.default.dirname(normalizedOptions.outFile);
|
||||
if (!node_fs_1.default.existsSync(outputPath)) {
|
||||
node_fs_1.default.mkdirSync(outputPath, { recursive: true });
|
||||
}
|
||||
// Write translation file
|
||||
node_fs_1.default.writeFileSync(normalizedOptions.outFile, content);
|
||||
if (normalizedOptions.progress) {
|
||||
context.logger.info(`Extraction Complete. (Messages: ${extractionResult.messages.length})`);
|
||||
}
|
||||
return { success: true, outputPath: normalizedOptions.outFile };
|
||||
}
|
||||
async function createSerializer(localizeToolsModule, format, sourceLocale, basePath, useLegacyIds, diagnostics) {
|
||||
const { XmbTranslationSerializer, LegacyMessageIdMigrationSerializer, ArbTranslationSerializer, Xliff1TranslationSerializer, Xliff2TranslationSerializer, SimpleJsonTranslationSerializer, } = localizeToolsModule;
|
||||
switch (format) {
|
||||
case schema_1.Format.Xmb:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return new XmbTranslationSerializer(basePath, useLegacyIds);
|
||||
case schema_1.Format.Xlf:
|
||||
case schema_1.Format.Xlif:
|
||||
case schema_1.Format.Xliff:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return new Xliff1TranslationSerializer(sourceLocale, basePath, useLegacyIds, {});
|
||||
case schema_1.Format.Xlf2:
|
||||
case schema_1.Format.Xliff2:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return new Xliff2TranslationSerializer(sourceLocale, basePath, useLegacyIds, {});
|
||||
case schema_1.Format.Json:
|
||||
return new SimpleJsonTranslationSerializer(sourceLocale);
|
||||
case schema_1.Format.LegacyMigrate:
|
||||
return new LegacyMessageIdMigrationSerializer(diagnostics);
|
||||
case schema_1.Format.Arb:
|
||||
return new ArbTranslationSerializer(sourceLocale,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
basePath, {
|
||||
relative(from, to) {
|
||||
return node_path_1.default.relative(from, to);
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=builder.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"builder.js","sourceRoot":"","sources":["builder.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcH,0BAkHC;AA5HD,sDAAyB;AACzB,0DAA6B;AAC7B,iDAAqE;AAErE,uCAA6C;AAC7C,qCAAuE;AAEvE;;GAEG;AACI,KAAK,UAAU,OAAO,CAC3B,OAAkC,EAClC,OAAuB,EACvB,UAAyC;IAEzC,qDAAqD;IACrD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;QAEtF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAErE,CAAC;IACF,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yB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KAAK,eAAM,CAAC,GAAG;YACb,OAAO,IAAI,wBAAwB,CACjC,YAAY;YACZ,8DAA8D;YAC9D,QAAe,EACf;gBACE,QAAQ,CAAC,IAAY,EAAE,EAAU;oBAC/B,OAAO,mBAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjC,CAAC;gBACD,8DAA8D;aACxD,CACT,CAAC;IACN,CAAC;AACH,CAAC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @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 { Builder } from '@angular-devkit/architect';
|
||||
import { execute } from './builder';
|
||||
import type { Schema as ExtractI18nBuilderOptions } from './schema';
|
||||
export { ExtractI18nBuilderOptions, execute };
|
||||
declare const builder: Builder<ExtractI18nBuilderOptions>;
|
||||
export default builder;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.execute = void 0;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const builder_1 = require("./builder");
|
||||
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return builder_1.execute; } });
|
||||
const builder = (0, architect_1.createBuilder)(builder_1.execute);
|
||||
exports.default = builder;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,yDAAmE;AACnE,uCAAoC;AAGA,wFAH3B,iBAAO,OAG2B;AAE3C,MAAM,OAAO,GACX,IAAA,yBAAa,EAA4B,iBAAO,CAAC,CAAC;AAEpD,kBAAe,OAAO,CAAC"}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @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 DiagnosticHandlingStrategy } from '@angular/localize/tools';
|
||||
import { BuilderContext } from '@angular-devkit/architect';
|
||||
import { type I18nOptions } from '../../utils/i18n-options';
|
||||
import { Schema as ExtractI18nOptions, Format } from './schema';
|
||||
export type NormalizedExtractI18nOptions = Awaited<ReturnType<typeof normalizeOptions>>;
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
export declare function normalizeOptions(context: BuilderContext, projectName: string, options: ExtractI18nOptions): Promise<{
|
||||
workspaceRoot: string;
|
||||
projectRoot: string;
|
||||
buildTarget: import("@angular-devkit/architect").Target;
|
||||
i18nOptions: I18nOptions & {
|
||||
duplicateTranslationBehavior: DiagnosticHandlingStrategy;
|
||||
};
|
||||
format: Format.Arb | Format.Json | Format.LegacyMigrate | Format.Xliff | Format.Xliff2 | Format.Xmb;
|
||||
outFile: string;
|
||||
progress: boolean;
|
||||
}>;
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeOptions = normalizeOptions;
|
||||
const architect_1 = require("@angular-devkit/architect");
|
||||
const node_assert_1 = require("node:assert");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const i18n_options_1 = require("../../utils/i18n-options");
|
||||
const schema_1 = require("./schema");
|
||||
/**
|
||||
* Normalize the user provided options by creating full paths for all path based options
|
||||
* and converting multi-form options into a single form that can be directly used
|
||||
* by the build process.
|
||||
*
|
||||
* @param context The context for current builder execution.
|
||||
* @param projectName The name of the project for the current execution.
|
||||
* @param options An object containing the options to use for the build.
|
||||
* @returns An object containing normalized options required to perform the build.
|
||||
*/
|
||||
async function normalizeOptions(context, projectName, options) {
|
||||
const workspaceRoot = context.workspaceRoot;
|
||||
const projectMetadata = await context.getProjectMetadata(projectName);
|
||||
const projectRoot = node_path_1.default.join(workspaceRoot, projectMetadata.root ?? '');
|
||||
// Target specifier defaults to the current project's build target with no specified configuration
|
||||
const buildTargetSpecifier = options.buildTarget ?? ':';
|
||||
const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
|
||||
const i18nOptions = {
|
||||
...(0, i18n_options_1.createI18nOptions)(projectMetadata, /** inline */ false, context.logger),
|
||||
duplicateTranslationBehavior: options.i18nDuplicateTranslation || 'warning',
|
||||
};
|
||||
// Normalize xliff format extensions
|
||||
let format = options.format;
|
||||
switch (format) {
|
||||
// Default format is xliff1
|
||||
case undefined:
|
||||
case schema_1.Format.Xlf:
|
||||
case schema_1.Format.Xlif:
|
||||
case schema_1.Format.Xliff:
|
||||
format = schema_1.Format.Xliff;
|
||||
break;
|
||||
case schema_1.Format.Xlf2:
|
||||
case schema_1.Format.Xliff2:
|
||||
format = schema_1.Format.Xliff2;
|
||||
break;
|
||||
}
|
||||
let outFile = options.outFile || getDefaultOutFile(format);
|
||||
if (options.outputPath) {
|
||||
outFile = node_path_1.default.join(options.outputPath, outFile);
|
||||
}
|
||||
outFile = node_path_1.default.resolve(context.workspaceRoot, outFile);
|
||||
return {
|
||||
workspaceRoot,
|
||||
projectRoot,
|
||||
buildTarget,
|
||||
i18nOptions,
|
||||
format,
|
||||
outFile,
|
||||
progress: options.progress ?? true,
|
||||
};
|
||||
}
|
||||
function getDefaultOutFile(format) {
|
||||
switch (format) {
|
||||
case schema_1.Format.Xmb:
|
||||
return 'messages.xmb';
|
||||
case schema_1.Format.Xliff:
|
||||
case schema_1.Format.Xliff2:
|
||||
return 'messages.xlf';
|
||||
case schema_1.Format.Json:
|
||||
case schema_1.Format.LegacyMigrate:
|
||||
return 'messages.json';
|
||||
case schema_1.Format.Arb:
|
||||
return 'messages.arb';
|
||||
default:
|
||||
(0, node_assert_1.fail)(`Invalid Format enum value: ${format}`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=options.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAqBH,4CAkDC;AApED,yDAAmF;AACnF,6CAAmC;AACnC,0DAA6B;AAC7B,2DAA+E;AAC/E,qCAAgE;AAIhE;;;;;;;;;GASG;AACI,KAAK,UAAU,gBAAgB,CACpC,OAAuB,EACvB,WAAmB,EACnB,OAA2B;IAE3B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC5C,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,aAAa,EAAG,eAAe,CAAC,IAA2B,IAAI,EAAE,CAAC,CAAC;IAEjG,kGAAkG;IAClG,MAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,IAAI,GAAG,CAAC;IACxD,MAAM,WAAW,GAAG,IAAA,kCAAsB,EAAC,oBAAoB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACvF,MAAM,WAAW,GAEb;QACF,GAAG,IAAA,gCAAiB,EAAC,eAAe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AAC;QACjB,KAAK,eAAM,CAAC,aAAa;YACvB,OAAO,eAAe,CAAC;QACzB,KAAK,eAAM,CAAC,GAAG;YACb,OAAO,cAAc,CAAC;QACxB;YACE,IAAA,kBAAI,EAAC,8BAA8B,MAAiB,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Extract i18n target options for Build Facade.
|
||||
*/
|
||||
export type Schema = {
|
||||
/**
|
||||
* A builder target to extract i18n messages in the format of
|
||||
* `project:target[:configuration]`. You can also pass in more than one configuration name
|
||||
* as a comma-separated list. Example: `project:target:production,staging`.
|
||||
*/
|
||||
buildTarget?: string;
|
||||
/**
|
||||
* Output format for the generated file.
|
||||
*/
|
||||
format?: Format;
|
||||
/**
|
||||
* How to handle duplicate translations.
|
||||
*/
|
||||
i18nDuplicateTranslation?: I18NDuplicateTranslation;
|
||||
/**
|
||||
* Name of the file to output.
|
||||
*/
|
||||
outFile?: string;
|
||||
/**
|
||||
* Path where output will be placed.
|
||||
*/
|
||||
outputPath?: string;
|
||||
/**
|
||||
* Log progress to the console.
|
||||
*/
|
||||
progress?: boolean;
|
||||
};
|
||||
/**
|
||||
* Output format for the generated file.
|
||||
*/
|
||||
export declare enum Format {
|
||||
Arb = "arb",
|
||||
Json = "json",
|
||||
LegacyMigrate = "legacy-migrate",
|
||||
Xlf = "xlf",
|
||||
Xlf2 = "xlf2",
|
||||
Xlif = "xlif",
|
||||
Xliff = "xliff",
|
||||
Xliff2 = "xliff2",
|
||||
Xmb = "xmb"
|
||||
}
|
||||
/**
|
||||
* How to handle duplicate translations.
|
||||
*/
|
||||
export declare enum I18NDuplicateTranslation {
|
||||
Error = "error",
|
||||
Ignore = "ignore",
|
||||
Warning = "warning"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
||||
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.I18NDuplicateTranslation = exports.Format = void 0;
|
||||
/**
|
||||
* Output format for the generated file.
|
||||
*/
|
||||
var Format;
|
||||
(function (Format) {
|
||||
Format["Arb"] = "arb";
|
||||
Format["Json"] = "json";
|
||||
Format["LegacyMigrate"] = "legacy-migrate";
|
||||
Format["Xlf"] = "xlf";
|
||||
Format["Xlf2"] = "xlf2";
|
||||
Format["Xlif"] = "xlif";
|
||||
Format["Xliff"] = "xliff";
|
||||
Format["Xliff2"] = "xliff2";
|
||||
Format["Xmb"] = "xmb";
|
||||
})(Format || (exports.Format = Format = {}));
|
||||
/**
|
||||
* How to handle duplicate translations.
|
||||
*/
|
||||
var I18NDuplicateTranslation;
|
||||
(function (I18NDuplicateTranslation) {
|
||||
I18NDuplicateTranslation["Error"] = "error";
|
||||
I18NDuplicateTranslation["Ignore"] = "ignore";
|
||||
I18NDuplicateTranslation["Warning"] = "warning";
|
||||
})(I18NDuplicateTranslation || (exports.I18NDuplicateTranslation = I18NDuplicateTranslation = {}));
|
||||
//# sourceMappingURL=schema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF;;;AAkCpF;;GAEG;AACH,IAAY,MAUX;AAVD,WAAY,MAAM;IACd,qBAAW,CAAA;IACX,uBAAa,CAAA;IACb,0CAAgC,CAAA;IAChC,qBAAW,CAAA;IACX,uBAAa,CAAA;IACb,uBAAa,CAAA;IACb,yBAAe,CAAA;IACf,2BAAiB,CAAA;IACjB,qBAAW,CAAA;AACf,CAAC,EAVW,MAAM,sBAAN,MAAM,QAUjB;AAED;;GAEG;AACH,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,2CAAe,CAAA;IACf,6CAAiB,CAAA;IACjB,+CAAmB,CAAA;AACvB,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC"}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "Extract i18n Target",
|
||||
"description": "Extract i18n target options for Build Facade.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"buildTarget": {
|
||||
"type": "string",
|
||||
"description": "A builder target to extract i18n messages in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
|
||||
"pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "Output format for the generated file.",
|
||||
"default": "xlf",
|
||||
"enum": ["xmb", "xlf", "xlif", "xliff", "xlf2", "xliff2", "json", "arb", "legacy-migrate"]
|
||||
},
|
||||
"progress": {
|
||||
"type": "boolean",
|
||||
"description": "Log progress to the console.",
|
||||
"default": true
|
||||
},
|
||||
"outputPath": {
|
||||
"type": "string",
|
||||
"description": "Path where output will be placed."
|
||||
},
|
||||
"outFile": {
|
||||
"type": "string",
|
||||
"description": "Name of the file to output."
|
||||
},
|
||||
"i18nDuplicateTranslation": {
|
||||
"type": "string",
|
||||
"description": "How to handle duplicate translations.",
|
||||
"enum": ["error", "warning", "ignore"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @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 { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
||||
import { Schema as KarmaBuilderOptions } from './schema';
|
||||
import type { KarmaBuilderTransformsOptions } from './index';
|
||||
export declare function execute(options: KarmaBuilderOptions, context: BuilderContext, transforms?: KarmaBuilderTransformsOptions): AsyncIterable<BuilderOutput>;
|
||||
+324
@@ -0,0 +1,324 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.execute = execute;
|
||||
const node_crypto_1 = require("node:crypto");
|
||||
const node_fs_1 = require("node:fs");
|
||||
const fs = __importStar(require("node:fs/promises"));
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const web_1 = require("node:stream/web");
|
||||
const virtual_module_plugin_1 = require("../../tools/esbuild/virtual-module-plugin");
|
||||
const test_files_1 = require("../../utils/test-files");
|
||||
const index_1 = require("../application/index");
|
||||
const results_1 = require("../application/results");
|
||||
const schema_1 = require("../application/schema");
|
||||
const assets_middleware_1 = require("./assets-middleware");
|
||||
const coverage_1 = require("./coverage");
|
||||
const karma_config_1 = require("./karma-config");
|
||||
const options_1 = require("./options");
|
||||
const polyfills_plugin_1 = require("./polyfills-plugin");
|
||||
const progress_reporter_1 = require("./progress-reporter");
|
||||
const utils_1 = require("./utils");
|
||||
class ApplicationBuildError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'ApplicationBuildError';
|
||||
}
|
||||
}
|
||||
function execute(options, context, transforms) {
|
||||
const normalizedOptions = (0, options_1.normalizeOptions)(context, options);
|
||||
const karmaOptions = (0, karma_config_1.getBaseKarmaOptions)(normalizedOptions, context);
|
||||
let karmaServer;
|
||||
return new web_1.ReadableStream({
|
||||
async start(controller) {
|
||||
let init;
|
||||
try {
|
||||
init = await initializeApplication(normalizedOptions, context, karmaOptions, transforms);
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof ApplicationBuildError) {
|
||||
controller.enqueue({ success: false, message: err.message });
|
||||
controller.close();
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
const [karma, karmaConfig, buildOptions, buildIterator] = init;
|
||||
// If `--watch` is explicitly enabled or if we are keeping the Karma
|
||||
// process running, we should hook Karma into the build.
|
||||
if (buildIterator) {
|
||||
(0, progress_reporter_1.injectKarmaReporter)(buildOptions, buildIterator, karmaConfig, controller);
|
||||
}
|
||||
// Close the stream once the Karma server returns.
|
||||
karmaServer = new karma.Server(karmaConfig, (exitCode) => {
|
||||
controller.enqueue({ success: exitCode === 0 });
|
||||
controller.close();
|
||||
});
|
||||
await karmaServer.start();
|
||||
},
|
||||
async cancel() {
|
||||
await karmaServer?.stop();
|
||||
},
|
||||
});
|
||||
}
|
||||
async function initializeApplication(options, context, karmaOptions, transforms) {
|
||||
const karma = await Promise.resolve().then(() => __importStar(require('karma')));
|
||||
const projectSourceRoot = await (0, utils_1.getProjectSourceRoot)(context);
|
||||
// Setup temporary output path and ensure it is empty
|
||||
const outputPath = node_path_1.default.join(context.workspaceRoot, 'dist/test-out', (0, node_crypto_1.randomUUID)());
|
||||
await fs.rm(outputPath, { recursive: true, force: true });
|
||||
// Setup exit cleanup for temporary directory
|
||||
const handleProcessExit = () => (0, node_fs_1.rmSync)(outputPath, { recursive: true, force: true });
|
||||
process.once('exit', handleProcessExit);
|
||||
process.once('SIGINT', handleProcessExit);
|
||||
process.once('uncaughtException', handleProcessExit);
|
||||
const { buildOptions, mainName } = await setupBuildOptions(options, context, projectSourceRoot, outputPath);
|
||||
const [buildOutput, buildIterator] = await runEsbuild(buildOptions, context, projectSourceRoot);
|
||||
const karmaConfig = await configureKarma(karma, context, karmaOptions, options, buildOptions, buildOutput, mainName, transforms);
|
||||
return [karma, karmaConfig, buildOptions, buildIterator];
|
||||
}
|
||||
async function setupBuildOptions(options, context, projectSourceRoot, outputPath) {
|
||||
const entryPoints = await (0, utils_1.collectEntrypoints)(options, context, projectSourceRoot);
|
||||
const mainName = 'test_main';
|
||||
if (options.main) {
|
||||
entryPoints.set(mainName, options.main);
|
||||
}
|
||||
else {
|
||||
entryPoints.set(mainName, 'angular:test-bed-init');
|
||||
}
|
||||
const instrumentForCoverage = options.codeCoverage
|
||||
? (0, coverage_1.createInstrumentationFilter)(projectSourceRoot, (0, coverage_1.getInstrumentationExcludedPaths)(context.workspaceRoot, options.codeCoverageExclude ?? []))
|
||||
: undefined;
|
||||
const [polyfills, jasmineCleanup] = (0, utils_1.normalizePolyfills)(options.polyfills);
|
||||
for (let idx = 0; idx < jasmineCleanup.length; ++idx) {
|
||||
entryPoints.set(`jasmine-cleanup-${idx}`, jasmineCleanup[idx]);
|
||||
}
|
||||
const buildOptions = {
|
||||
assets: options.assets,
|
||||
entryPoints,
|
||||
tsConfig: options.tsConfig,
|
||||
outputPath,
|
||||
preserveSymlinks: options.preserveSymlinks,
|
||||
aot: options.aot,
|
||||
index: false,
|
||||
outputHashing: schema_1.OutputHashing.None,
|
||||
optimization: false,
|
||||
sourceMap: options.sourceMap,
|
||||
instrumentForCoverage,
|
||||
styles: options.styles,
|
||||
scripts: options.scripts,
|
||||
polyfills,
|
||||
webWorkerTsConfig: options.webWorkerTsConfig,
|
||||
watch: options.watch,
|
||||
stylePreprocessorOptions: options.stylePreprocessorOptions,
|
||||
inlineStyleLanguage: options.inlineStyleLanguage,
|
||||
fileReplacements: options.fileReplacements,
|
||||
define: options.define,
|
||||
loader: options.loader,
|
||||
externalDependencies: options.externalDependencies,
|
||||
};
|
||||
return { buildOptions, mainName };
|
||||
}
|
||||
async function runEsbuild(buildOptions, context, projectSourceRoot) {
|
||||
const usesZoneJS = buildOptions.polyfills?.includes('zone.js');
|
||||
const virtualTestBedInit = (0, virtual_module_plugin_1.createVirtualModulePlugin)({
|
||||
namespace: 'angular:test-bed-init',
|
||||
loadContent: async () => {
|
||||
const contents = [
|
||||
// Initialize the Angular testing environment
|
||||
`import { NgModule${usesZoneJS ? ', provideZoneChangeDetection' : ''} } from '@angular/core';`,
|
||||
`import { getTestBed } from '@angular/core/testing';`,
|
||||
`import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';`,
|
||||
`@NgModule({ providers: [${usesZoneJS ? 'provideZoneChangeDetection(), ' : ''}], })`,
|
||||
`export class TestModule {}`,
|
||||
`getTestBed().initTestEnvironment([BrowserTestingModule, TestModule], platformBrowserTesting(), {`,
|
||||
` errorOnUnknownElements: true,`,
|
||||
` errorOnUnknownProperties: true,`,
|
||||
`});`,
|
||||
];
|
||||
return {
|
||||
contents: contents.join('\n'),
|
||||
loader: 'js',
|
||||
resolveDir: projectSourceRoot,
|
||||
};
|
||||
},
|
||||
});
|
||||
// Build tests with `application` builder, using test files as entry points.
|
||||
const [buildOutput, buildIterator] = await (0, utils_1.first)((0, index_1.buildApplicationInternal)(buildOptions, context, { codePlugins: [virtualTestBedInit] }), { cancel: !buildOptions.watch });
|
||||
if (buildOutput.kind === results_1.ResultKind.Failure) {
|
||||
throw new ApplicationBuildError('Build failed');
|
||||
}
|
||||
else if (buildOutput.kind !== results_1.ResultKind.Full) {
|
||||
throw new ApplicationBuildError('A full build result is required from the application builder.');
|
||||
}
|
||||
// Write test files
|
||||
await (0, test_files_1.writeTestFiles)(buildOutput.files, buildOptions.outputPath);
|
||||
return [buildOutput, buildIterator];
|
||||
}
|
||||
async function configureKarma(karma, context, karmaOptions, options, buildOptions, buildOutput, mainName, transforms) {
|
||||
const outputPath = buildOptions.outputPath;
|
||||
// We need to add this to the beginning *after* the testing framework has
|
||||
// prepended its files. The output path is required for each since they are
|
||||
// added later in the test process via a plugin.
|
||||
const polyfillsFile = {
|
||||
pattern: `${outputPath}/polyfills.js`,
|
||||
included: true,
|
||||
served: true,
|
||||
type: 'module',
|
||||
watched: false,
|
||||
};
|
||||
const jasmineCleanupFiles = {
|
||||
pattern: `${outputPath}/jasmine-cleanup-*.js`,
|
||||
included: true,
|
||||
served: true,
|
||||
type: 'module',
|
||||
watched: false,
|
||||
};
|
||||
karmaOptions.basePath = outputPath;
|
||||
const scriptsFiles = [];
|
||||
if (options.scripts?.length) {
|
||||
const outputScripts = new Set();
|
||||
for (const scriptEntry of options.scripts) {
|
||||
const outputName = typeof scriptEntry === 'string'
|
||||
? 'scripts.js'
|
||||
: `${scriptEntry.bundleName ?? 'scripts'}.js`;
|
||||
if (outputScripts.has(outputName)) {
|
||||
continue;
|
||||
}
|
||||
outputScripts.add(outputName);
|
||||
scriptsFiles.push({
|
||||
pattern: `${outputPath}/${outputName}`,
|
||||
watched: false,
|
||||
included: typeof scriptEntry === 'string' ? true : scriptEntry.inject !== false,
|
||||
type: 'js',
|
||||
});
|
||||
}
|
||||
}
|
||||
karmaOptions.files ??= [];
|
||||
karmaOptions.files.push(
|
||||
// Serve global setup script.
|
||||
{ pattern: `${mainName}.js`, type: 'module', watched: false },
|
||||
// Serve all source maps.
|
||||
{ pattern: `*.map`, included: false, watched: false },
|
||||
// These are the test entrypoints.
|
||||
{ pattern: `spec-*.js`, type: 'module', watched: false });
|
||||
if ((0, utils_1.hasChunkOrWorkerFiles)(buildOutput.files)) {
|
||||
karmaOptions.files.push(
|
||||
// Allow loading of chunk-* files but don't include them all on load.
|
||||
{
|
||||
pattern: `{chunk,worker}-*.js`,
|
||||
type: 'module',
|
||||
included: false,
|
||||
watched: false,
|
||||
});
|
||||
}
|
||||
if (options.styles?.length) {
|
||||
// Serve CSS outputs on page load, these are the global styles.
|
||||
karmaOptions.files.push({ pattern: `*.css`, type: 'css', watched: false });
|
||||
}
|
||||
const parsedKarmaConfig = await karma.config.parseConfig(options.karmaConfig, transforms?.karmaOptions ? await transforms.karmaOptions(karmaOptions) : karmaOptions, { promiseConfig: true, throwErrors: true });
|
||||
// Check for jsdom which does not support executing ESM scripts.
|
||||
// If present, remove jsdom and issue a warning.
|
||||
const updatedBrowsers = parsedKarmaConfig.browsers?.filter((browser) => browser !== 'jsdom');
|
||||
if (parsedKarmaConfig.browsers?.length !== updatedBrowsers?.length) {
|
||||
parsedKarmaConfig.browsers = updatedBrowsers;
|
||||
context.logger.warn(`'jsdom' does not support ESM code execution and cannot be used for karma testing.` +
|
||||
` The 'jsdom' entry has been removed from the 'browsers' option.`);
|
||||
}
|
||||
// Remove the webpack plugin/framework:
|
||||
// Alternative would be to make the Karma plugin "smart" but that's a tall order
|
||||
// with managing unneeded imports etc..
|
||||
parsedKarmaConfig.plugins ??= [];
|
||||
const pluginLengthBefore = parsedKarmaConfig.plugins.length;
|
||||
parsedKarmaConfig.plugins = parsedKarmaConfig.plugins.filter((plugin) => {
|
||||
if (typeof plugin === 'string') {
|
||||
return plugin !== 'framework:@angular-devkit/build-angular';
|
||||
}
|
||||
return !plugin['framework:@angular-devkit/build-angular'];
|
||||
});
|
||||
parsedKarmaConfig.frameworks ??= [];
|
||||
parsedKarmaConfig.frameworks = parsedKarmaConfig.frameworks.filter((framework) => framework !== '@angular-devkit/build-angular');
|
||||
const pluginLengthAfter = parsedKarmaConfig.plugins.length;
|
||||
if (pluginLengthBefore !== pluginLengthAfter) {
|
||||
context.logger.warn(`Ignoring framework "@angular-devkit/build-angular" from karma config file because it's not compatible with the application builder.`);
|
||||
}
|
||||
parsedKarmaConfig.plugins.push(assets_middleware_1.AngularAssetsMiddleware.createPlugin(buildOutput));
|
||||
parsedKarmaConfig.middleware ??= [];
|
||||
parsedKarmaConfig.middleware.push(assets_middleware_1.AngularAssetsMiddleware.NAME);
|
||||
parsedKarmaConfig.plugins.push(polyfills_plugin_1.AngularPolyfillsPlugin.createPlugin(polyfillsFile, jasmineCleanupFiles, scriptsFiles));
|
||||
parsedKarmaConfig.reporters ??= [];
|
||||
parsedKarmaConfig.reporters.push(polyfills_plugin_1.AngularPolyfillsPlugin.NAME);
|
||||
// Adjust karma junit reporter outDir location to maintain previous (devkit) behavior
|
||||
// The base path for the reporter was previously the workspace root.
|
||||
// To keep the files in the same location, the reporter's output directory is adjusted
|
||||
// to be relative to the workspace root when using junit.
|
||||
if (parsedKarmaConfig.reporters?.some((reporter) => reporter === 'junit')) {
|
||||
if ('junitReporter' in parsedKarmaConfig) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const junitReporterOptions = parsedKarmaConfig['junitReporter'];
|
||||
if (junitReporterOptions.outputDir == undefined) {
|
||||
junitReporterOptions.outputDir = context.workspaceRoot;
|
||||
}
|
||||
else if (typeof junitReporterOptions.outputDir === 'string' &&
|
||||
!node_path_1.default.isAbsolute(junitReporterOptions.outputDir)) {
|
||||
junitReporterOptions.outputDir = node_path_1.default.join(context.workspaceRoot, junitReporterOptions.outputDir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parsedKarmaConfig['junitReporter'] = {
|
||||
outputDir: context.workspaceRoot,
|
||||
};
|
||||
}
|
||||
}
|
||||
// When using code-coverage, auto-add karma-coverage.
|
||||
// This was done as part of the karma plugin for webpack.
|
||||
if (options.codeCoverage &&
|
||||
!parsedKarmaConfig.reporters?.some((r) => r === 'coverage' || r === 'coverage-istanbul')) {
|
||||
parsedKarmaConfig.reporters = (parsedKarmaConfig.reporters ?? []).concat(['coverage']);
|
||||
}
|
||||
return parsedKarmaConfig;
|
||||
}
|
||||
//# sourceMappingURL=application_builder.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @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 { InlinePluginDef } from 'karma';
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
import type { ResultFile } from '../application/results';
|
||||
interface ServeFileFunction {
|
||||
(filepath: string, rangeHeader: string | string[] | undefined, response: ServerResponse, transform?: (c: string | Uint8Array) => string | Uint8Array, content?: string | Uint8Array, doNotCache?: boolean): void;
|
||||
}
|
||||
export interface LatestBuildFiles {
|
||||
files: Record<string, ResultFile | undefined>;
|
||||
}
|
||||
export declare class AngularAssetsMiddleware {
|
||||
private readonly serveFile;
|
||||
private readonly latestBuildFiles;
|
||||
static readonly $inject: string[];
|
||||
static readonly NAME = "angular-test-assets";
|
||||
constructor(serveFile: ServeFileFunction, latestBuildFiles: LatestBuildFiles);
|
||||
handle(req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => unknown): void;
|
||||
static createPlugin(initialFiles: LatestBuildFiles): InlinePluginDef;
|
||||
}
|
||||
export {};
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AngularAssetsMiddleware = void 0;
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const isWindows = process.platform === 'win32';
|
||||
const LATEST_BUILD_FILES_TOKEN = 'angularLatestBuildFiles';
|
||||
class AngularAssetsMiddleware {
|
||||
serveFile;
|
||||
latestBuildFiles;
|
||||
static $inject = ['serveFile', LATEST_BUILD_FILES_TOKEN];
|
||||
static NAME = 'angular-test-assets';
|
||||
constructor(serveFile, latestBuildFiles) {
|
||||
this.serveFile = serveFile;
|
||||
this.latestBuildFiles = latestBuildFiles;
|
||||
}
|
||||
handle(req, res, next) {
|
||||
const url = new URL(`http://${req.headers['host'] ?? ''}${req.url ?? ''}`);
|
||||
// Remove the leading slash from the URL path and convert to platform specific.
|
||||
// The latest build files will use the platform path separator.
|
||||
let pathname = url.pathname.slice(1);
|
||||
if (isWindows) {
|
||||
pathname = pathname.replaceAll(node_path_1.default.posix.sep, node_path_1.default.win32.sep);
|
||||
}
|
||||
const file = this.latestBuildFiles.files[pathname];
|
||||
if (!file) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
// Implementation of serverFile can be found here:
|
||||
// https://github.com/karma-runner/karma/blob/84f85e7016efc2266fa6b3465f494a3fa151c85c/lib/middleware/common.js#L10
|
||||
switch (file.origin) {
|
||||
case 'disk':
|
||||
this.serveFile(file.inputPath, undefined, res, undefined, undefined, /* doNotCache */ true);
|
||||
break;
|
||||
case 'memory':
|
||||
// Include pathname to help with Content-Type headers.
|
||||
this.serveFile(`/unused/${url.pathname}`, undefined, res, undefined, file.contents,
|
||||
/* doNotCache */ false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static createPlugin(initialFiles) {
|
||||
return {
|
||||
[LATEST_BUILD_FILES_TOKEN]: ['value', { files: { ...initialFiles.files } }],
|
||||
[`middleware:${AngularAssetsMiddleware.NAME}`]: [
|
||||
'factory',
|
||||
Object.assign((...args) => {
|
||||
const inst = new AngularAssetsMiddleware(...args);
|
||||
return inst.handle.bind(inst);
|
||||
}, AngularAssetsMiddleware),
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.AngularAssetsMiddleware = AngularAssetsMiddleware;
|
||||
//# sourceMappingURL=assets-middleware.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"assets-middleware.js","sourceRoot":"","sources":["assets-middleware.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAIH,0DAA6B;AAG7B,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAiB/C,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D,MAAa,uBAAuB;IAMf;IACA;IANnB,MAAM,CAAU,OAAO,GAAG,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IAElE,MAAM,CAAU,IAAI,GAAG,qBAAqB,CAAC;IAE7C,YACmB,SAA4B,EAC5B,gBAAkC;QADlC,cAAS,GAAT,SAAS,CAAmB;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAkB;IAClD,CAAC;IAEJ,MAAM,CAAC,GAAoB,EAAE,GAAmB,EAAE,IAAgC;QAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3E,+EAA+E;QAC/E,+DAA+D;QAC/D,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,SAAS,EAAE,CAAC;YACd,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,mBAAI,CA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
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
export declare function createInstrumentationFilter(includedBasePath: string, excludedPaths: Set<string>): (request: string) => boolean;
|
||||
export declare function getInstrumentationExcludedPaths(root: string, excludedPaths: string[]): Set<string>;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createInstrumentationFilter = createInstrumentationFilter;
|
||||
exports.getInstrumentationExcludedPaths = getInstrumentationExcludedPaths;
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const tinyglobby_1 = require("tinyglobby");
|
||||
function createInstrumentationFilter(includedBasePath, excludedPaths) {
|
||||
return (request) => {
|
||||
return (!excludedPaths.has(request) &&
|
||||
!/\.(e2e|spec)\.tsx?$|[\\/]node_modules[\\/]|[\\/]\.angular[\\/]/.test(request) &&
|
||||
request.startsWith(includedBasePath));
|
||||
};
|
||||
}
|
||||
function getInstrumentationExcludedPaths(root, excludedPaths) {
|
||||
const excluded = new Set();
|
||||
for (const excludeGlob of excludedPaths) {
|
||||
const excludePath = excludeGlob[0] === '/' ? excludeGlob.slice(1) : excludeGlob;
|
||||
(0, tinyglobby_1.globSync)(excludePath, { cwd: root }).forEach((p) => excluded.add(node_path_1.default.join(root, p)));
|
||||
}
|
||||
return excluded;
|
||||
}
|
||||
//# sourceMappingURL=coverage.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["coverage.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAKH,kEAQC;AAED,0EAYC;AAzBD,0DAA6B;AAC7B,2CAAsC;AAEtC,SAAgB,2BAA2B,CAAC,gBAAwB,EAAE,aAA0B;IAC9F,OAAO,CAAC,OAAe,EAAW,EAAE;QAClC,OAAO,CACL,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;YAC3B,CAAC,gEAAgE,CAAC,IAAI,CAAC,OAAO,CAAC;YAC/E,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CACrC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,+BAA+B,CAC7C,IAAY,EACZ,aAAuB;IAEvB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,KAAK,MAAM,WAAW,IAAI,aAAa,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAChF,IAAA,qBAAQ,EAAC,WAAW,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,mBAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
export { getTestEntrypoints } from '../unit-test/test-discovery';
|
||||
export declare function findTests(include: string[], exclude: string[], workspaceRoot: string, projectSourceRoot: string): Promise<string[]>;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTestEntrypoints = void 0;
|
||||
exports.findTests = findTests;
|
||||
const test_discovery_1 = require("../unit-test/test-discovery");
|
||||
// This file is a compatibility layer that re-exports the test discovery logic from its new location.
|
||||
// This is necessary to avoid breaking the Karma builder, which still depends on this file.
|
||||
var test_discovery_2 = require("../unit-test/test-discovery");
|
||||
Object.defineProperty(exports, "getTestEntrypoints", { enumerable: true, get: function () { return test_discovery_2.getTestEntrypoints; } });
|
||||
const removeLeadingSlash = (path) => {
|
||||
return path.startsWith('/') ? path.substring(1) : path;
|
||||
};
|
||||
async function findTests(include, exclude, workspaceRoot, projectSourceRoot) {
|
||||
// Karma has legacy support for workspace "root-relative" file paths
|
||||
return (0, test_discovery_1.findTests)(include.map(removeLeadingSlash), exclude.map(removeLeadingSlash), workspaceRoot, projectSourceRoot);
|
||||
}
|
||||
//# sourceMappingURL=find-tests.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"find-tests.js","sourceRoot":"","sources":["find-tests.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAYH,8BAaC;AAvBD,gEAAyE;AAEzE,qGAAqG;AACrG,2FAA2F;AAC3F,8DAAiE;AAAxD,oHAAA,kBAAkB,OAAA;AAE3B,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAU,EAAE;IAClD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC,CAAC;AAEK,KAAK,UAAU,SAAS,CAC7B,OAAiB,EACjB,OAAiB,EACjB,aAAqB,EACrB,iBAAyB;IAEzB,oEAAoE;IACpE,OAAO,IAAA,0BAAa,EAClB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAC/B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAC/B,aAAa,EACb,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user