Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@angular/compiler-cli

Package Overview
Dependencies
Maintainers
2
Versions
1008
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/compiler-cli - npm Package Compare versions

Comparing version
21.0.0
to
21.0.1
bundles/chunk-I3BPPTZC.js

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+373
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
// packages/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.js
var InvalidFileSystem = class {
exists(path) {
throw makeError();
}
readFile(path) {
throw makeError();
}
readFileBuffer(path) {
throw makeError();
}
writeFile(path, data, exclusive) {
throw makeError();
}
removeFile(path) {
throw makeError();
}
symlink(target, path) {
throw makeError();
}
readdir(path) {
throw makeError();
}
lstat(path) {
throw makeError();
}
stat(path) {
throw makeError();
}
pwd() {
throw makeError();
}
chdir(path) {
throw makeError();
}
extname(path) {
throw makeError();
}
copyFile(from, to) {
throw makeError();
}
moveFile(from, to) {
throw makeError();
}
ensureDir(path) {
throw makeError();
}
removeDeep(path) {
throw makeError();
}
isCaseSensitive() {
throw makeError();
}
resolve(...paths) {
throw makeError();
}
dirname(file) {
throw makeError();
}
join(basePath, ...paths) {
throw makeError();
}
isRoot(path) {
throw makeError();
}
isRooted(path) {
throw makeError();
}
relative(from, to) {
throw makeError();
}
basename(filePath, extension) {
throw makeError();
}
realpath(filePath) {
throw makeError();
}
getDefaultLibLocation() {
throw makeError();
}
normalize(path) {
throw makeError();
}
};
function makeError() {
return new Error("FileSystem has not been configured. Please call `setFileSystem()` before calling this method.");
}
// packages/compiler-cli/src/ngtsc/file_system/src/util.js
var TS_DTS_JS_EXTENSION = /(?:\.d)?\.ts$|\.js$/;
function normalizeSeparators(path) {
return path.replace(/\\/g, "/");
}
function stripExtension(path) {
return path.replace(TS_DTS_JS_EXTENSION, "");
}
function getSourceFileOrError(program, fileName) {
const sf = program.getSourceFile(fileName);
if (sf === void 0) {
throw new Error(`Program does not contain "${fileName}" - available files are ${program.getSourceFiles().map((sf2) => sf2.fileName).join(", ")}`);
}
return sf;
}
// packages/compiler-cli/src/ngtsc/file_system/src/helpers.js
var fs = new InvalidFileSystem();
function getFileSystem() {
return fs;
}
function setFileSystem(fileSystem) {
fs = fileSystem;
}
function absoluteFrom(path) {
if (!fs.isRooted(path)) {
throw new Error(`Internal Error: absoluteFrom(${path}): path is not absolute`);
}
return fs.resolve(path);
}
var ABSOLUTE_PATH = Symbol("AbsolutePath");
function absoluteFromSourceFile(sf) {
const sfWithPatch = sf;
if (sfWithPatch[ABSOLUTE_PATH] === void 0) {
sfWithPatch[ABSOLUTE_PATH] = fs.resolve(sfWithPatch.fileName);
}
return sfWithPatch[ABSOLUTE_PATH];
}
function relativeFrom(path) {
const normalized = normalizeSeparators(path);
if (fs.isRooted(normalized)) {
throw new Error(`Internal Error: relativeFrom(${path}): path is not relative`);
}
return normalized;
}
function dirname(file) {
return fs.dirname(file);
}
function join(basePath, ...paths) {
return fs.join(basePath, ...paths);
}
function resolve(basePath, ...paths) {
return fs.resolve(basePath, ...paths);
}
function isRoot(path) {
return fs.isRoot(path);
}
function isRooted(path) {
return fs.isRooted(path);
}
function relative(from, to) {
return fs.relative(from, to);
}
function basename(filePath, extension) {
return fs.basename(filePath, extension);
}
function isLocalRelativePath(relativePath) {
return !isRooted(relativePath) && !relativePath.startsWith("..");
}
function toRelativeImport(relativePath) {
return isLocalRelativePath(relativePath) ? `./${relativePath}` : relativePath;
}
// packages/compiler-cli/src/ngtsc/file_system/src/compiler_host.js
import * as os from "os";
import ts from "typescript";
var NgtscCompilerHost = class {
fs;
options;
constructor(fs2, options = {}) {
this.fs = fs2;
this.options = options;
}
getSourceFile(fileName, languageVersion) {
const text = this.readFile(fileName);
return text !== void 0 ? ts.createSourceFile(fileName, text, languageVersion, true) : void 0;
}
getDefaultLibFileName(options) {
return this.fs.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
}
getDefaultLibLocation() {
return this.fs.getDefaultLibLocation();
}
writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles) {
const path = absoluteFrom(fileName);
this.fs.ensureDir(this.fs.dirname(path));
this.fs.writeFile(path, data);
}
getCurrentDirectory() {
return this.fs.pwd();
}
getCanonicalFileName(fileName) {
return this.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
}
useCaseSensitiveFileNames() {
return this.fs.isCaseSensitive();
}
getNewLine() {
switch (this.options.newLine) {
case ts.NewLineKind.CarriageReturnLineFeed:
return "\r\n";
case ts.NewLineKind.LineFeed:
return "\n";
default:
return os.EOL;
}
}
fileExists(fileName) {
const absPath = this.fs.resolve(fileName);
return this.fs.exists(absPath) && this.fs.stat(absPath).isFile();
}
readFile(fileName) {
const absPath = this.fs.resolve(fileName);
if (!this.fileExists(absPath)) {
return void 0;
}
return this.fs.readFile(absPath);
}
realpath(path) {
return this.fs.realpath(this.fs.resolve(path));
}
};
// packages/compiler-cli/src/ngtsc/file_system/src/logical.js
var LogicalProjectPath = {
/**
* Get the relative path between two `LogicalProjectPath`s.
*
* This will return a `PathSegment` which would be a valid module specifier to use in `from` when
* importing from `to`.
*/
relativePathBetween: function(from, to) {
const relativePath = relative(dirname(resolve(from)), resolve(to));
return toRelativeImport(relativePath);
}
};
var LogicalFileSystem = class {
compilerHost;
/**
* The root directories of the project, sorted with the longest path first.
*/
rootDirs;
/**
* The same root directories as `rootDirs` but with each one converted to its
* canonical form for matching in case-insensitive file-systems.
*/
canonicalRootDirs;
/**
* A cache of file paths to project paths, because computation of these paths is slightly
* expensive.
*/
cache = /* @__PURE__ */ new Map();
constructor(rootDirs, compilerHost) {
this.compilerHost = compilerHost;
this.rootDirs = rootDirs.concat([]).sort((a, b) => b.length - a.length);
this.canonicalRootDirs = this.rootDirs.map((dir) => this.compilerHost.getCanonicalFileName(dir));
}
/**
* Get the logical path in the project of a `ts.SourceFile`.
*
* This method is provided as a convenient alternative to calling
* `logicalPathOfFile(absoluteFromSourceFile(sf))`.
*/
logicalPathOfSf(sf) {
return this.logicalPathOfFile(absoluteFromSourceFile(sf));
}
/**
* Get the logical path in the project of a source file.
*
* @returns A `LogicalProjectPath` to the source file, or `null` if the source file is not in any
* of the TS project's root directories.
*/
logicalPathOfFile(physicalFile) {
if (!this.cache.has(physicalFile)) {
const canonicalFilePath = this.compilerHost.getCanonicalFileName(physicalFile);
let logicalFile = null;
for (let i = 0; i < this.rootDirs.length; i++) {
const rootDir = this.rootDirs[i];
const canonicalRootDir = this.canonicalRootDirs[i];
if (isWithinBasePath(canonicalRootDir, canonicalFilePath)) {
logicalFile = this.createLogicalProjectPath(physicalFile, rootDir);
if (logicalFile.indexOf("/node_modules/") !== -1) {
logicalFile = null;
} else {
break;
}
}
}
this.cache.set(physicalFile, logicalFile);
}
return this.cache.get(physicalFile);
}
createLogicalProjectPath(file, rootDir) {
const logicalPath = stripExtension(file.slice(rootDir.length));
return logicalPath.startsWith("/") ? logicalPath : "/" + logicalPath;
}
};
function isWithinBasePath(base, path) {
return isLocalRelativePath(relative(base, path));
}
// packages/compiler-cli/src/ngtsc/file_system/src/ts_read_directory.js
import ts2 from "typescript";
function createFileSystemTsReadDirectoryFn(fs2) {
if (ts2.matchFiles === void 0) {
throw Error("Unable to read directory in configured file system. This means that TypeScript changed its file matching internals.\n\nPlease consider downgrading your TypeScript version, and report an issue in the Angular framework repository.");
}
const matchFilesFn = ts2.matchFiles.bind(ts2);
return (rootDir, extensions, excludes, includes, depth) => {
const directoryExists = (p) => {
const resolvedPath = fs2.resolve(p);
return fs2.exists(resolvedPath) && fs2.stat(resolvedPath).isDirectory();
};
return matchFilesFn(rootDir, extensions, excludes, includes, fs2.isCaseSensitive(), fs2.pwd(), depth, (p) => {
const resolvedPath = fs2.resolve(p);
if (!directoryExists(resolvedPath)) {
return { directories: [], files: [] };
}
const children = fs2.readdir(resolvedPath);
const files = [];
const directories = [];
for (const child of children) {
try {
if (fs2.stat(fs2.join(resolvedPath, child))?.isDirectory()) {
directories.push(child);
} else {
files.push(child);
}
} catch (error) {
if (error instanceof Error && error.message.includes("ENOENT")) {
continue;
}
throw error;
}
}
return { files, directories };
}, (p) => fs2.resolve(p), (p) => directoryExists(p));
};
}
export {
InvalidFileSystem,
stripExtension,
getSourceFileOrError,
getFileSystem,
setFileSystem,
absoluteFrom,
absoluteFromSourceFile,
relativeFrom,
dirname,
join,
resolve,
isRoot,
isRooted,
relative,
basename,
isLocalRelativePath,
toRelativeImport,
NgtscCompilerHost,
LogicalProjectPath,
LogicalFileSystem,
createFileSystemTsReadDirectoryFn
};
/**
* @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 {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
DEFAULT_ERROR_CODE,
EmitFlags,
SOURCE,
createCompilerHost,
createMessageDiagnostic,
exitCodeFromResult,
formatDiagnostics,
performCompilation,
readConfiguration
} from "./chunk-Z6AENWVT.js";
// packages/compiler-cli/src/main.js
import ts2 from "typescript";
import yargs from "yargs";
// packages/compiler-cli/src/perform_watch.js
import * as chokidar from "chokidar";
import * as path from "path";
import ts from "typescript";
function totalCompilationTimeDiagnostic(timeInMillis) {
let duration;
if (timeInMillis > 1e3) {
duration = `${(timeInMillis / 1e3).toPrecision(2)}s`;
} else {
duration = `${timeInMillis}ms`;
}
return {
category: ts.DiagnosticCategory.Message,
messageText: `Total time: ${duration}`,
code: DEFAULT_ERROR_CODE,
source: SOURCE,
file: void 0,
start: void 0,
length: void 0
};
}
var FileChangeEvent;
(function(FileChangeEvent2) {
FileChangeEvent2[FileChangeEvent2["Change"] = 0] = "Change";
FileChangeEvent2[FileChangeEvent2["CreateDelete"] = 1] = "CreateDelete";
FileChangeEvent2[FileChangeEvent2["CreateDeleteDir"] = 2] = "CreateDeleteDir";
})(FileChangeEvent || (FileChangeEvent = {}));
function createPerformWatchHost(configFileName, reportDiagnostics, existingOptions, createEmitCallback) {
return {
reportDiagnostics,
createCompilerHost: (options) => createCompilerHost({ options }),
readConfiguration: () => readConfiguration(configFileName, existingOptions),
createEmitCallback: (options) => createEmitCallback ? createEmitCallback(options) : void 0,
onFileChange: (options, listener, ready) => {
if (!options.basePath) {
reportDiagnostics([
{
category: ts.DiagnosticCategory.Error,
messageText: "Invalid configuration option. baseDir not specified",
source: SOURCE,
code: DEFAULT_ERROR_CODE,
file: void 0,
start: void 0,
length: void 0
}
]);
return { close: () => {
} };
}
const watcher = chokidar.watch(options.basePath, {
// ignore .dotfiles, .js and .map files.
// can't ignore other files as we e.g. want to recompile if an `.html` file changes as well.
ignored: (path2) => /((^[\/\\])\..)|(\.js$)|(\.map$)|(\.metadata\.json|node_modules)/.test(path2),
ignoreInitial: true,
persistent: true
});
watcher.on("all", (event, path2) => {
switch (event) {
case "change":
listener(FileChangeEvent.Change, path2);
break;
case "unlink":
case "add":
listener(FileChangeEvent.CreateDelete, path2);
break;
case "unlinkDir":
case "addDir":
listener(FileChangeEvent.CreateDeleteDir, path2);
break;
}
});
watcher.on("ready", ready);
return { close: () => watcher.close(), ready };
},
setTimeout: ts.sys.clearTimeout && ts.sys.setTimeout || setTimeout,
clearTimeout: ts.sys.setTimeout && ts.sys.clearTimeout || clearTimeout
};
}
function performWatchCompilation(host) {
let cachedProgram;
let cachedCompilerHost;
let cachedOptions;
let timerHandleForRecompilation;
const ignoreFilesForWatch = /* @__PURE__ */ new Set();
const fileCache = /* @__PURE__ */ new Map();
const firstCompileResult = doCompilation();
let resolveReadyPromise;
const readyPromise = new Promise((resolve) => resolveReadyPromise = resolve);
const fileWatcher = host.onFileChange(cachedOptions.options, watchedFileChanged, resolveReadyPromise);
return { close, ready: (cb) => readyPromise.then(cb), firstCompileResult };
function cacheEntry(fileName) {
fileName = path.normalize(fileName);
let entry = fileCache.get(fileName);
if (!entry) {
entry = {};
fileCache.set(fileName, entry);
}
return entry;
}
function close() {
fileWatcher.close();
if (timerHandleForRecompilation) {
host.clearTimeout(timerHandleForRecompilation.timerHandle);
timerHandleForRecompilation = void 0;
}
}
function doCompilation() {
if (!cachedOptions) {
cachedOptions = host.readConfiguration();
}
if (cachedOptions.errors && cachedOptions.errors.length) {
host.reportDiagnostics(cachedOptions.errors);
return cachedOptions.errors;
}
const startTime = Date.now();
if (!cachedCompilerHost) {
cachedCompilerHost = host.createCompilerHost(cachedOptions.options);
const originalWriteFileCallback = cachedCompilerHost.writeFile;
cachedCompilerHost.writeFile = function(fileName, data, writeByteOrderMark, onError, sourceFiles = []) {
ignoreFilesForWatch.add(path.normalize(fileName));
return originalWriteFileCallback(fileName, data, writeByteOrderMark, onError, sourceFiles);
};
const originalFileExists = cachedCompilerHost.fileExists;
cachedCompilerHost.fileExists = function(fileName) {
const ce = cacheEntry(fileName);
if (ce.exists == null) {
ce.exists = originalFileExists.call(this, fileName);
}
return ce.exists;
};
const originalGetSourceFile = cachedCompilerHost.getSourceFile;
cachedCompilerHost.getSourceFile = function(fileName, languageVersion) {
const ce = cacheEntry(fileName);
if (!ce.sf) {
ce.sf = originalGetSourceFile.call(this, fileName, languageVersion);
}
return ce.sf;
};
const originalReadFile = cachedCompilerHost.readFile;
cachedCompilerHost.readFile = function(fileName) {
const ce = cacheEntry(fileName);
if (ce.content == null) {
ce.content = originalReadFile.call(this, fileName);
}
return ce.content;
};
cachedCompilerHost.getModifiedResourceFiles = function() {
if (timerHandleForRecompilation === void 0) {
return void 0;
}
return timerHandleForRecompilation.modifiedResourceFiles;
};
}
ignoreFilesForWatch.clear();
const oldProgram = cachedProgram;
cachedProgram = void 0;
const compileResult = performCompilation({
rootNames: cachedOptions.rootNames,
options: cachedOptions.options,
host: cachedCompilerHost,
oldProgram,
emitCallback: host.createEmitCallback(cachedOptions.options)
});
if (compileResult.diagnostics.length) {
host.reportDiagnostics(compileResult.diagnostics);
}
const endTime = Date.now();
if (cachedOptions.options.diagnostics) {
const totalTime = (endTime - startTime) / 1e3;
host.reportDiagnostics([totalCompilationTimeDiagnostic(endTime - startTime)]);
}
const exitCode = exitCodeFromResult(compileResult.diagnostics);
if (exitCode == 0) {
cachedProgram = compileResult.program;
host.reportDiagnostics([
createMessageDiagnostic("Compilation complete. Watching for file changes.")
]);
} else {
host.reportDiagnostics([
createMessageDiagnostic("Compilation failed. Watching for file changes.")
]);
}
return compileResult.diagnostics;
}
function resetOptions() {
cachedProgram = void 0;
cachedCompilerHost = void 0;
cachedOptions = void 0;
}
function watchedFileChanged(event, fileName) {
const normalizedPath = path.normalize(fileName);
if (cachedOptions && event === FileChangeEvent.Change && // TODO(chuckj): validate that this is sufficient to skip files that were written.
// This assumes that the file path we write is the same file path we will receive in the
// change notification.
normalizedPath === path.normalize(cachedOptions.project)) {
resetOptions();
} else if (event === FileChangeEvent.CreateDelete || event === FileChangeEvent.CreateDeleteDir) {
cachedOptions = void 0;
}
if (event === FileChangeEvent.CreateDeleteDir) {
fileCache.clear();
} else {
fileCache.delete(normalizedPath);
}
if (!ignoreFilesForWatch.has(normalizedPath)) {
startTimerForRecompilation(normalizedPath);
}
}
function startTimerForRecompilation(changedPath) {
if (timerHandleForRecompilation) {
host.clearTimeout(timerHandleForRecompilation.timerHandle);
} else {
timerHandleForRecompilation = {
modifiedResourceFiles: /* @__PURE__ */ new Set(),
timerHandle: void 0
};
}
timerHandleForRecompilation.timerHandle = host.setTimeout(recompile, 250);
timerHandleForRecompilation.modifiedResourceFiles.add(changedPath);
}
function recompile() {
host.reportDiagnostics([
createMessageDiagnostic("File change detected. Starting incremental compilation.")
]);
doCompilation();
timerHandleForRecompilation = void 0;
}
}
// packages/compiler-cli/src/main.js
function main(args, consoleError = console.error, config, customTransformers, programReuse, modifiedResourceFiles) {
let { project, rootNames, options, errors: configErrors, watch: watch2, emitFlags } = config || readNgcCommandLineAndConfiguration(args);
if (configErrors.length) {
return reportErrorsAndExit(
configErrors,
/*options*/
void 0,
consoleError
);
}
if (watch2) {
const result = watchMode(project, options, consoleError);
return reportErrorsAndExit(result.firstCompileResult, options, consoleError);
}
let oldProgram;
if (programReuse !== void 0) {
oldProgram = programReuse.program;
}
const { diagnostics: compileDiags, program } = performCompilation({
rootNames,
options,
emitFlags,
oldProgram,
customTransformers,
modifiedResourceFiles
});
if (programReuse !== void 0) {
programReuse.program = program;
}
return reportErrorsAndExit(compileDiags, options, consoleError);
}
function readNgcCommandLineAndConfiguration(args) {
const options = {};
const parsedArgs = yargs(args).parserConfiguration({ "strip-aliased": true }).option("i18nFile", { type: "string" }).option("i18nFormat", { type: "string" }).option("locale", { type: "string" }).option("missingTranslation", { type: "string", choices: ["error", "warning", "ignore"] }).option("outFile", { type: "string" }).option("watch", { type: "boolean", alias: ["w"] }).parseSync();
if (parsedArgs.i18nFile)
options.i18nInFile = parsedArgs.i18nFile;
if (parsedArgs.i18nFormat)
options.i18nInFormat = parsedArgs.i18nFormat;
if (parsedArgs.locale)
options.i18nInLocale = parsedArgs.locale;
if (parsedArgs.missingTranslation)
options.i18nInMissingTranslations = parsedArgs.missingTranslation;
const config = readCommandLineAndConfiguration(args, options, [
"i18nFile",
"i18nFormat",
"locale",
"missingTranslation",
"watch"
]);
return { ...config, watch: parsedArgs.watch };
}
function readCommandLineAndConfiguration(args, existingOptions = {}, ngCmdLineOptions = []) {
let cmdConfig = ts2.parseCommandLine(args);
const project = cmdConfig.options.project || ".";
const cmdErrors = cmdConfig.errors.filter((e) => {
if (typeof e.messageText === "string") {
const msg = e.messageText;
return !ngCmdLineOptions.some((o) => msg.indexOf(o) >= 0);
}
return true;
});
if (cmdErrors.length) {
return {
project,
rootNames: [],
options: cmdConfig.options,
errors: cmdErrors,
emitFlags: EmitFlags.Default
};
}
const config = readConfiguration(project, cmdConfig.options);
const options = { ...config.options, ...existingOptions };
if (options.locale) {
options.i18nInLocale = options.locale;
}
return {
project,
rootNames: config.rootNames,
options,
errors: config.errors,
emitFlags: config.emitFlags
};
}
function getFormatDiagnosticsHost(options) {
const basePath = options ? options.basePath : void 0;
return {
getCurrentDirectory: () => basePath || ts2.sys.getCurrentDirectory(),
// We need to normalize the path separators here because by default, TypeScript
// compiler hosts use posix canonical paths. In order to print consistent diagnostics,
// we also normalize the paths.
getCanonicalFileName: (fileName) => fileName.replace(/\\/g, "/"),
getNewLine: () => {
if (options && options.newLine !== void 0) {
return options.newLine === ts2.NewLineKind.LineFeed ? "\n" : "\r\n";
}
return ts2.sys.newLine;
}
};
}
function reportErrorsAndExit(allDiagnostics, options, consoleError = console.error) {
const errorsAndWarnings = allDiagnostics.filter((d) => d.category !== ts2.DiagnosticCategory.Message);
printDiagnostics(errorsAndWarnings, options, consoleError);
return exitCodeFromResult(allDiagnostics);
}
function watchMode(project, options, consoleError) {
return performWatchCompilation(createPerformWatchHost(project, (diagnostics) => {
printDiagnostics(diagnostics, options, consoleError);
}, options, void 0));
}
function printDiagnostics(diagnostics, options, consoleError) {
if (diagnostics.length === 0) {
return;
}
const formatHost = getFormatDiagnosticsHost(options);
consoleError(formatDiagnostics(diagnostics, formatHost));
}
export {
main,
readCommandLineAndConfiguration
};
/**
* @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 {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
NgCompiler,
NgCompilerHost,
TrackedIncrementalBuildStrategy,
freshCompilationTicket,
incrementalFromCompilerTicket
} from "./chunk-I3BPPTZC.js";
import {
ActivePerfRecorder,
OptimizeFor,
PerfCheckpoint,
PerfEvent,
PerfPhase,
TsCreateProgramDriver,
replaceTsWithNgInErrors,
retagAllTsFiles
} from "./chunk-IJMZQ3RN.js";
import {
absoluteFrom,
createFileSystemTsReadDirectoryFn,
getFileSystem,
resolve
} from "./chunk-JEXAXD23.js";
// packages/compiler-cli/src/transformers/api.js
var DEFAULT_ERROR_CODE = 100;
var UNKNOWN_ERROR_CODE = 500;
var SOURCE = "angular";
function isTsDiagnostic(diagnostic) {
return diagnostic != null && diagnostic.source !== "angular";
}
var EmitFlags;
(function(EmitFlags2) {
EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
EmitFlags2[EmitFlags2["All"] = 31] = "All";
})(EmitFlags || (EmitFlags = {}));
// packages/compiler-cli/src/transformers/compiler_host.js
import ts from "typescript";
var wrapHostForTest = null;
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
if (wrapHostForTest !== null) {
tsHost = wrapHostForTest(tsHost);
}
return tsHost;
}
// packages/compiler-cli/src/ngtsc/program.js
import { HtmlParser, MessageBundle } from "@angular/compiler";
import ts3 from "typescript";
// packages/compiler-cli/src/transformers/i18n.js
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
import * as path from "path";
function i18nGetExtension(formatName) {
const format = formatName.toLowerCase();
switch (format) {
case "xmb":
return "xmb";
case "xlf":
case "xlif":
case "xliff":
case "xlf2":
case "xliff2":
return "xlf";
}
throw new Error(`Unsupported format "${formatName}"`);
}
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
formatName = formatName || "xlf";
const ext = i18nGetExtension(formatName);
const content = i18nSerialize(bundle, formatName, options);
const dstFile = outFile || `messages.${ext}`;
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
host.writeFile(dstPath, content, false, void 0, []);
return [dstPath];
}
function i18nSerialize(bundle, formatName, options) {
const format = formatName.toLowerCase();
let serializer;
switch (format) {
case "xmb":
serializer = new Xmb();
break;
case "xliff2":
case "xlf2":
serializer = new Xliff2();
break;
case "xlf":
case "xliff":
default:
serializer = new Xliff();
}
return bundle.write(serializer, getPathNormalizer(options.basePath));
}
function getPathNormalizer(basePath) {
return (sourcePath) => {
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
return sourcePath.split(path.sep).join("/");
};
}
// packages/compiler-cli/src/typescript_support.js
import ts2 from "typescript";
// packages/compiler-cli/src/version_helpers.js
function toNumbers(value) {
const suffixIndex = value.lastIndexOf("-");
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
const parsed = parseInt(segment, 10);
if (isNaN(parsed)) {
throw Error(`Unable to parse version string ${value}.`);
}
return parsed;
});
}
function compareNumbers(a, b) {
const max = Math.max(a.length, b.length);
const min = Math.min(a.length, b.length);
for (let i = 0; i < min; i++) {
if (a[i] > b[i])
return 1;
if (a[i] < b[i])
return -1;
}
if (min !== max) {
const longestArray = a.length === max ? a : b;
const comparisonResult = a.length === max ? 1 : -1;
for (let i = min; i < max; i++) {
if (longestArray[i] > 0) {
return comparisonResult;
}
}
}
return 0;
}
function compareVersions(v1, v2) {
return compareNumbers(toNumbers(v1), toNumbers(v2));
}
// packages/compiler-cli/src/typescript_support.js
var MIN_TS_VERSION = "5.9.0";
var MAX_TS_VERSION = "6.0.0";
var tsVersion = ts2.version;
function checkVersion(version, minVersion, maxVersion) {
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
}
}
function verifySupportedTypeScriptVersion() {
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
}
// packages/compiler-cli/src/ngtsc/program.js
var NgtscProgram = class {
options;
compiler;
/**
* The primary TypeScript program, which is used for analysis and emit.
*/
tsProgram;
host;
incrementalStrategy;
constructor(rootNames, options, delegateHost, oldProgram) {
this.options = options;
const perfRecorder = ActivePerfRecorder.zeroedToNow();
perfRecorder.phase(PerfPhase.Setup);
if (!options.disableTypeScriptVersionCheck) {
verifySupportedTypeScriptVersion();
}
if (options.compilationMode === "experimental-local") {
options.noEmitOnError = false;
}
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
if (reuseProgram !== void 0) {
retagAllTsFiles(reuseProgram);
}
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts3.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
perfRecorder.phase(PerfPhase.Unaccounted);
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
this.host.postProgramCreationCleanup();
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
const modifiedResourceFiles = /* @__PURE__ */ new Set();
if (this.host.getModifiedResourceFiles !== void 0) {
const strings = this.host.getModifiedResourceFiles();
if (strings !== void 0) {
for (const fileString of strings) {
modifiedResourceFiles.add(absoluteFrom(fileString));
}
}
}
let ticket;
if (oldProgram === void 0) {
ticket = freshCompilationTicket(
this.tsProgram,
options,
this.incrementalStrategy,
programDriver,
perfRecorder,
/* enableTemplateTypeChecker */
false,
/* usePoisonedData */
false
);
} else {
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
}
this.compiler = NgCompiler.fromTicket(ticket, this.host);
}
getTsProgram() {
return this.tsProgram;
}
getReuseTsProgram() {
return this.compiler.getCurrentProgram();
}
getTsOptionDiagnostics(cancellationToken) {
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
}
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
const ignoredFiles = this.compiler.ignoreForDiagnostics;
let res;
if (sourceFile !== void 0) {
if (ignoredFiles.has(sourceFile)) {
return [];
}
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
} else {
const diagnostics = [];
for (const sf of this.tsProgram.getSourceFiles()) {
if (!ignoredFiles.has(sf)) {
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
}
}
res = diagnostics;
}
return res;
});
}
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
if (this.options.compilationMode === "experimental-local") {
return [];
}
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
const ignoredFiles = this.compiler.ignoreForDiagnostics;
let res;
if (sourceFile !== void 0) {
if (ignoredFiles.has(sourceFile)) {
return [];
}
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
} else {
const diagnostics = [];
for (const sf of this.tsProgram.getSourceFiles()) {
if (!ignoredFiles.has(sf)) {
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
}
}
res = diagnostics;
}
return res;
});
}
getNgOptionDiagnostics(cancellationToken) {
return this.compiler.getOptionDiagnostics();
}
getNgStructuralDiagnostics(cancellationToken) {
return [];
}
getNgSemanticDiagnostics(fileName, cancellationToken) {
let sf = void 0;
if (fileName !== void 0) {
sf = this.tsProgram.getSourceFile(fileName);
if (sf === void 0) {
return [];
}
}
if (sf === void 0) {
return this.compiler.getDiagnostics();
} else {
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
}
}
/**
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
* loading of any resources during the process.
*
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
* like SASS files used in `styleUrls`.
*/
loadNgStructureAsync() {
return this.compiler.analyzeAsync();
}
listLazyRoutes(entryRoute) {
return [];
}
emitXi18n() {
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
this.compiler.xi18n(ctx);
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
}
emit(opts) {
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
this.emitXi18n();
if (!(opts.emitFlags & EmitFlags.JS)) {
return {
diagnostics: [],
emitSkipped: true,
emittedFiles: []
};
}
}
const forceEmit = opts?.forceEmit ?? false;
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
const { transformers } = this.compiler.prepareEmit();
const ignoreFiles = this.compiler.ignoreForEmit;
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
if (sourceFiles !== void 0) {
for (const writtenSf of sourceFiles) {
if (writtenSf.isDeclarationFile) {
continue;
}
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
}
}
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
};
const customTransforms = opts && opts.customTransformers;
const beforeTransforms = transformers.before || [];
const afterDeclarationsTransforms = transformers.afterDeclarations;
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
beforeTransforms.push(...customTransforms.beforeTs);
}
const emitResults = [];
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
continue;
}
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
continue;
}
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
emitResults.push(emitCallback({
targetSourceFile,
program: this.tsProgram,
host: this.host,
options: this.options,
emitOnlyDtsFiles: false,
writeFile,
customTransformers: {
before: beforeTransforms,
after: customTransforms && customTransforms.afterTs,
afterDeclarations: afterDeclarationsTransforms
}
}));
}
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
});
if (this.options.tracePerformance !== void 0) {
const perf = this.compiler.perfRecorder.finalize();
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
}
return res;
}
getIndexedComponents() {
return this.compiler.getIndexedComponents();
}
/**
* Gets information for the current program that may be used to generate API
* reference documentation. This includes Angular-specific information, such
* as component inputs and outputs.
*
* @param entryPoint Path to the entry point for the package for which API
* docs should be extracted.
*/
getApiDocumentation(entryPoint, privateModules) {
return this.compiler.getApiDocumentation(entryPoint, privateModules);
}
getEmittedSourceFiles() {
throw new Error("Method not implemented.");
}
};
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
function mergeEmitResults(emitResults) {
const diagnostics = [];
let emitSkipped = false;
const emittedFiles = [];
for (const er of emitResults) {
diagnostics.push(...er.diagnostics);
emitSkipped = emitSkipped || er.emitSkipped;
emittedFiles.push(...er.emittedFiles || []);
}
return { diagnostics, emitSkipped, emittedFiles };
}
// packages/compiler-cli/src/transformers/program.js
function createProgram({ rootNames, options, host, oldProgram }) {
return new NgtscProgram(rootNames, options, host, oldProgram);
}
// packages/compiler-cli/src/perform_compile.js
import ts5 from "typescript";
// packages/compiler-cli/src/transformers/util.js
import ts4 from "typescript";
function createMessageDiagnostic(messageText) {
return {
file: void 0,
start: void 0,
length: void 0,
category: ts4.DiagnosticCategory.Message,
messageText,
code: DEFAULT_ERROR_CODE,
source: SOURCE
};
}
// packages/compiler-cli/src/perform_compile.js
var defaultFormatHost = {
getCurrentDirectory: () => ts5.sys.getCurrentDirectory(),
getCanonicalFileName: (fileName) => fileName,
getNewLine: () => ts5.sys.newLine
};
function formatDiagnostics(diags, host = defaultFormatHost) {
if (diags && diags.length) {
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts5.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
} else {
return "";
}
}
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
const absProject = host.resolve(project);
const projectIsDir = host.lstat(absProject).isDirectory();
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
const basePath = host.resolve(projectDir);
return { projectFile, basePath };
}
function readConfiguration(project, existingOptions, host = getFileSystem()) {
try {
const fs = getFileSystem();
const readConfigFile = (configFile) => ts5.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
const { config: config2, error: error2 } = readConfigFile(configFile);
if (error2) {
return parentOptions;
}
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
if (!config2.extends) {
return existingNgCompilerOptions;
}
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
}, existingNgCompilerOptions);
};
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
const configFileName = host.resolve(host.pwd(), projectFile);
const { config, error } = readConfigFile(projectFile);
if (error) {
return {
project,
errors: [error],
rootNames: [],
options: {},
emitFlags: EmitFlags.Default
};
}
const existingCompilerOptions = {
genDir: basePath,
basePath,
...readAngularCompilerOptions(configFileName),
...existingOptions
};
const parseConfigHost = createParseConfigHost(host, fs);
const { options, errors, fileNames: rootNames, projectReferences } = ts5.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
let emitFlags = EmitFlags.Default;
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
emitFlags |= EmitFlags.Metadata;
}
if (options["skipTemplateCodegen"]) {
emitFlags = emitFlags & ~EmitFlags.Codegen;
}
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
} catch (e) {
const errors = [
{
category: ts5.DiagnosticCategory.Error,
messageText: e.stack ?? e.message,
file: void 0,
start: void 0,
length: void 0,
source: "angular",
code: UNKNOWN_ERROR_CODE
}
];
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
}
}
function createParseConfigHost(host, fs = getFileSystem()) {
return {
fileExists: host.exists.bind(host),
readDirectory: createFileSystemTsReadDirectoryFn(fs),
readFile: host.readFile.bind(host),
useCaseSensitiveFileNames: fs.isCaseSensitive()
};
}
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
if (result !== null) {
return result;
}
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
}
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
if (host.exists(extendedConfigPath)) {
return extendedConfigPath;
}
} else {
const parseConfigHost = createParseConfigHost(host, fs);
const { resolvedModule } = ts5.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts5.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
if (resolvedModule) {
return absoluteFrom(resolvedModule.resolvedFileName);
}
}
return null;
}
function exitCodeFromResult(diags) {
if (!diags)
return 0;
if (diags.every((diag) => diag.category !== ts5.DiagnosticCategory.Error)) {
return 0;
}
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
}
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
let program;
let emitResult;
let allDiagnostics = [];
try {
if (!host) {
host = createCompilerHost({ options });
}
if (modifiedResourceFiles) {
host.getModifiedResourceFiles = () => modifiedResourceFiles;
}
program = createProgram({ rootNames, host, options, oldProgram });
const beforeDiags = Date.now();
allDiagnostics.push(...gatherDiagnostics(program));
if (options.diagnostics) {
const afterDiags = Date.now();
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
}
if (!hasErrors(allDiagnostics)) {
emitResult = program.emit({
emitCallback,
mergeEmitResultsCallback,
customTransformers,
emitFlags,
forceEmit
});
allDiagnostics.push(...emitResult.diagnostics);
return { diagnostics: allDiagnostics, program, emitResult };
}
return { diagnostics: allDiagnostics, program };
} catch (e) {
program = void 0;
allDiagnostics.push({
category: ts5.DiagnosticCategory.Error,
messageText: e.stack ?? e.message,
code: UNKNOWN_ERROR_CODE,
file: void 0,
start: void 0,
length: void 0
});
return { diagnostics: allDiagnostics, program };
}
}
function defaultGatherDiagnostics(program) {
const allDiagnostics = [];
function checkDiagnostics(diags) {
if (diags) {
allDiagnostics.push(...diags);
return !hasErrors(diags);
}
return true;
}
let checkOtherDiagnostics = true;
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
...program.getTsSemanticDiagnostics(),
...program.getNgStructuralDiagnostics()
]);
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
return allDiagnostics;
}
function hasErrors(diags) {
return diags.some((d) => d.category === ts5.DiagnosticCategory.Error);
}
export {
DEFAULT_ERROR_CODE,
UNKNOWN_ERROR_CODE,
SOURCE,
isTsDiagnostic,
EmitFlags,
createCompilerHost,
NgtscProgram,
createProgram,
createMessageDiagnostic,
formatDiagnostics,
calcProjectFileAndBasePath,
readConfiguration,
exitCodeFromResult,
performCompilation,
defaultGatherDiagnostics
};
/**
* @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
*/
+1
-1

@@ -458,3 +458,3 @@

import semver from "semver";
var PLACEHOLDER_VERSION = "21.0.0";
var PLACEHOLDER_VERSION = "21.0.1";
function wrapReference(wrapped) {

@@ -461,0 +461,0 @@ return { value: wrapped, type: wrapped };

@@ -20,3 +20,3 @@

readConfiguration
} from "./chunk-EZPRBQ4S.js";
} from "./chunk-Z6AENWVT.js";
import {

@@ -38,3 +38,3 @@ ConsoleLogger,

isDocEntryWithSourceInfo
} from "./chunk-3UWOVJPM.js";
} from "./chunk-I3BPPTZC.js";
import {

@@ -51,3 +51,3 @@ ActivePerfRecorder,

ngErrorCode
} from "./chunk-67N3I5R2.js";
} from "./chunk-IJMZQ3RN.js";
import "./chunk-LS5RJ5CS.js";

@@ -75,3 +75,3 @@ import {

toRelativeImport
} from "./chunk-GWZQLAGK.js";
} from "./chunk-JEXAXD23.js";
import {

@@ -84,3 +84,3 @@ NodeJSFileSystem

import { Version } from "@angular/compiler";
var VERSION = new Version("21.0.0");
var VERSION = new Version("21.0.1");

@@ -87,0 +87,0 @@ // packages/compiler-cli/private/tooling.js

@@ -34,3 +34,3 @@

toRelativeImport
} from "../chunk-GWZQLAGK.js";
} from "../chunk-JEXAXD23.js";
import {

@@ -37,0 +37,0 @@ NodeJSFileSystem

@@ -8,3 +8,3 @@

NgCompiler
} from "../chunk-3UWOVJPM.js";
} from "../chunk-I3BPPTZC.js";
import {

@@ -36,3 +36,3 @@ CompilationMode,

unwrapExpression
} from "../chunk-67N3I5R2.js";
} from "../chunk-IJMZQ3RN.js";
import "../chunk-LS5RJ5CS.js";

@@ -42,3 +42,3 @@ import {

isLocalRelativePath
} from "../chunk-GWZQLAGK.js";
} from "../chunk-JEXAXD23.js";
import {

@@ -45,0 +45,0 @@ NodeJSFileSystem

@@ -9,3 +9,3 @@

getInitializerApiJitTransform
} from "../chunk-67N3I5R2.js";
} from "../chunk-IJMZQ3RN.js";
import "../chunk-LS5RJ5CS.js";

@@ -19,3 +19,3 @@ import {

setFileSystem
} from "../chunk-GWZQLAGK.js";
} from "../chunk-JEXAXD23.js";
import {

@@ -22,0 +22,0 @@ NodeJSFileSystem

@@ -7,5 +7,5 @@

angularJitApplicationTransform
} from "../chunk-67N3I5R2.js";
} from "../chunk-IJMZQ3RN.js";
import "../chunk-LS5RJ5CS.js";
import "../chunk-GWZQLAGK.js";
import "../chunk-JEXAXD23.js";
import "../chunk-XYYEESKY.js";

@@ -12,0 +12,0 @@ import "../chunk-G7GFT6BU.js";

@@ -9,12 +9,12 @@ #!/usr/bin/env node

readCommandLineAndConfiguration
} from "../../chunk-IUWOX36C.js";
} from "../../chunk-TQDACBKM.js";
import {
EmitFlags
} from "../../chunk-EZPRBQ4S.js";
import "../../chunk-3UWOVJPM.js";
import "../../chunk-67N3I5R2.js";
} from "../../chunk-Z6AENWVT.js";
import "../../chunk-I3BPPTZC.js";
import "../../chunk-IJMZQ3RN.js";
import "../../chunk-LS5RJ5CS.js";
import {
setFileSystem
} from "../../chunk-GWZQLAGK.js";
} from "../../chunk-JEXAXD23.js";
import {

@@ -21,0 +21,0 @@ NodeJSFileSystem

@@ -8,10 +8,10 @@ #!/usr/bin/env node

main
} from "../../chunk-IUWOX36C.js";
import "../../chunk-EZPRBQ4S.js";
import "../../chunk-3UWOVJPM.js";
import "../../chunk-67N3I5R2.js";
} from "../../chunk-TQDACBKM.js";
import "../../chunk-Z6AENWVT.js";
import "../../chunk-I3BPPTZC.js";
import "../../chunk-IJMZQ3RN.js";
import "../../chunk-LS5RJ5CS.js";
import {
setFileSystem
} from "../../chunk-GWZQLAGK.js";
} from "../../chunk-JEXAXD23.js";
import {

@@ -18,0 +18,0 @@ NodeJSFileSystem

@@ -10,3 +10,3 @@ /**

import { AstObject, AstValue } from '../../ast/ast_value';
export declare const PLACEHOLDER_VERSION = "21.0.0";
export declare const PLACEHOLDER_VERSION = "21.0.1";
export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;

@@ -13,0 +13,0 @@ /**

{
"name": "@angular/compiler-cli",
"version": "21.0.0",
"version": "21.0.1",
"description": "Angular - the compiler CLI for Node.js",

@@ -43,3 +43,3 @@ "typings": "index.d.ts",

"peerDependencies": {
"@angular/compiler": "21.0.0",
"@angular/compiler": "21.0.1",
"typescript": ">=5.9 <6.0"

@@ -46,0 +46,0 @@ },

@@ -97,2 +97,4 @@ /**

undeclaredInputFields: Set<ClassPropertyName>;
/** Names of the public methods of the class. */
publicMethods: Set<string>;
/**

@@ -99,0 +101,0 @@ * Whether the Directive's class is generic, i.e. `class MyDir<T> {...}`.

@@ -8,3 +8,3 @@ /*!

*/
import { DirectiveOwner, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstTemplate } from '@angular/compiler';
import { DirectiveOwner, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstNode, TmplAstTemplate } from '@angular/compiler';
import { TcbOp } from './base';

@@ -40,3 +40,5 @@ import type { Context } from './context';

export declare function getCustomFieldDirectiveType(meta: TypeCheckableDirectiveMeta): CustomFieldType | null;
/** Determines if a directive usage is on a native field. */
export declare function isNativeField(dir: TypeCheckableDirectiveMeta, node: TmplAstNode, allDirectiveMatches: TypeCheckableDirectiveMeta[]): boolean;
/** Checks whether a node has bindings that aren't supported on fields. */
export declare function checkUnsupportedFieldBindings(node: DirectiveOwner, unsupportedBindingFields: Set<string>, tcb: Context): void;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
NgCompiler,
NgCompilerHost,
TrackedIncrementalBuildStrategy,
freshCompilationTicket,
incrementalFromCompilerTicket
} from "./chunk-3UWOVJPM.js";
import {
ActivePerfRecorder,
OptimizeFor,
PerfCheckpoint,
PerfEvent,
PerfPhase,
TsCreateProgramDriver,
replaceTsWithNgInErrors,
retagAllTsFiles
} from "./chunk-67N3I5R2.js";
import {
absoluteFrom,
createFileSystemTsReadDirectoryFn,
getFileSystem,
resolve
} from "./chunk-GWZQLAGK.js";
// packages/compiler-cli/src/transformers/api.js
var DEFAULT_ERROR_CODE = 100;
var UNKNOWN_ERROR_CODE = 500;
var SOURCE = "angular";
function isTsDiagnostic(diagnostic) {
return diagnostic != null && diagnostic.source !== "angular";
}
var EmitFlags;
(function(EmitFlags2) {
EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
EmitFlags2[EmitFlags2["All"] = 31] = "All";
})(EmitFlags || (EmitFlags = {}));
// packages/compiler-cli/src/transformers/compiler_host.js
import ts from "typescript";
var wrapHostForTest = null;
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
if (wrapHostForTest !== null) {
tsHost = wrapHostForTest(tsHost);
}
return tsHost;
}
// packages/compiler-cli/src/ngtsc/program.js
import { HtmlParser, MessageBundle } from "@angular/compiler";
import ts3 from "typescript";
// packages/compiler-cli/src/transformers/i18n.js
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
import * as path from "path";
function i18nGetExtension(formatName) {
const format = formatName.toLowerCase();
switch (format) {
case "xmb":
return "xmb";
case "xlf":
case "xlif":
case "xliff":
case "xlf2":
case "xliff2":
return "xlf";
}
throw new Error(`Unsupported format "${formatName}"`);
}
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
formatName = formatName || "xlf";
const ext = i18nGetExtension(formatName);
const content = i18nSerialize(bundle, formatName, options);
const dstFile = outFile || `messages.${ext}`;
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
host.writeFile(dstPath, content, false, void 0, []);
return [dstPath];
}
function i18nSerialize(bundle, formatName, options) {
const format = formatName.toLowerCase();
let serializer;
switch (format) {
case "xmb":
serializer = new Xmb();
break;
case "xliff2":
case "xlf2":
serializer = new Xliff2();
break;
case "xlf":
case "xliff":
default:
serializer = new Xliff();
}
return bundle.write(serializer, getPathNormalizer(options.basePath));
}
function getPathNormalizer(basePath) {
return (sourcePath) => {
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
return sourcePath.split(path.sep).join("/");
};
}
// packages/compiler-cli/src/typescript_support.js
import ts2 from "typescript";
// packages/compiler-cli/src/version_helpers.js
function toNumbers(value) {
const suffixIndex = value.lastIndexOf("-");
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
const parsed = parseInt(segment, 10);
if (isNaN(parsed)) {
throw Error(`Unable to parse version string ${value}.`);
}
return parsed;
});
}
function compareNumbers(a, b) {
const max = Math.max(a.length, b.length);
const min = Math.min(a.length, b.length);
for (let i = 0; i < min; i++) {
if (a[i] > b[i])
return 1;
if (a[i] < b[i])
return -1;
}
if (min !== max) {
const longestArray = a.length === max ? a : b;
const comparisonResult = a.length === max ? 1 : -1;
for (let i = min; i < max; i++) {
if (longestArray[i] > 0) {
return comparisonResult;
}
}
}
return 0;
}
function compareVersions(v1, v2) {
return compareNumbers(toNumbers(v1), toNumbers(v2));
}
// packages/compiler-cli/src/typescript_support.js
var MIN_TS_VERSION = "5.9.0";
var MAX_TS_VERSION = "6.0.0";
var tsVersion = ts2.version;
function checkVersion(version, minVersion, maxVersion) {
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
}
}
function verifySupportedTypeScriptVersion() {
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
}
// packages/compiler-cli/src/ngtsc/program.js
var NgtscProgram = class {
options;
compiler;
/**
* The primary TypeScript program, which is used for analysis and emit.
*/
tsProgram;
host;
incrementalStrategy;
constructor(rootNames, options, delegateHost, oldProgram) {
this.options = options;
const perfRecorder = ActivePerfRecorder.zeroedToNow();
perfRecorder.phase(PerfPhase.Setup);
if (!options.disableTypeScriptVersionCheck) {
verifySupportedTypeScriptVersion();
}
if (options.compilationMode === "experimental-local") {
options.noEmitOnError = false;
}
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
if (reuseProgram !== void 0) {
retagAllTsFiles(reuseProgram);
}
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts3.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
perfRecorder.phase(PerfPhase.Unaccounted);
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
this.host.postProgramCreationCleanup();
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
const modifiedResourceFiles = /* @__PURE__ */ new Set();
if (this.host.getModifiedResourceFiles !== void 0) {
const strings = this.host.getModifiedResourceFiles();
if (strings !== void 0) {
for (const fileString of strings) {
modifiedResourceFiles.add(absoluteFrom(fileString));
}
}
}
let ticket;
if (oldProgram === void 0) {
ticket = freshCompilationTicket(
this.tsProgram,
options,
this.incrementalStrategy,
programDriver,
perfRecorder,
/* enableTemplateTypeChecker */
false,
/* usePoisonedData */
false
);
} else {
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
}
this.compiler = NgCompiler.fromTicket(ticket, this.host);
}
getTsProgram() {
return this.tsProgram;
}
getReuseTsProgram() {
return this.compiler.getCurrentProgram();
}
getTsOptionDiagnostics(cancellationToken) {
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
}
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
const ignoredFiles = this.compiler.ignoreForDiagnostics;
let res;
if (sourceFile !== void 0) {
if (ignoredFiles.has(sourceFile)) {
return [];
}
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
} else {
const diagnostics = [];
for (const sf of this.tsProgram.getSourceFiles()) {
if (!ignoredFiles.has(sf)) {
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
}
}
res = diagnostics;
}
return res;
});
}
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
if (this.options.compilationMode === "experimental-local") {
return [];
}
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
const ignoredFiles = this.compiler.ignoreForDiagnostics;
let res;
if (sourceFile !== void 0) {
if (ignoredFiles.has(sourceFile)) {
return [];
}
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
} else {
const diagnostics = [];
for (const sf of this.tsProgram.getSourceFiles()) {
if (!ignoredFiles.has(sf)) {
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
}
}
res = diagnostics;
}
return res;
});
}
getNgOptionDiagnostics(cancellationToken) {
return this.compiler.getOptionDiagnostics();
}
getNgStructuralDiagnostics(cancellationToken) {
return [];
}
getNgSemanticDiagnostics(fileName, cancellationToken) {
let sf = void 0;
if (fileName !== void 0) {
sf = this.tsProgram.getSourceFile(fileName);
if (sf === void 0) {
return [];
}
}
if (sf === void 0) {
return this.compiler.getDiagnostics();
} else {
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
}
}
/**
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
* loading of any resources during the process.
*
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
* like SASS files used in `styleUrls`.
*/
loadNgStructureAsync() {
return this.compiler.analyzeAsync();
}
listLazyRoutes(entryRoute) {
return [];
}
emitXi18n() {
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
this.compiler.xi18n(ctx);
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
}
emit(opts) {
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
this.emitXi18n();
if (!(opts.emitFlags & EmitFlags.JS)) {
return {
diagnostics: [],
emitSkipped: true,
emittedFiles: []
};
}
}
const forceEmit = opts?.forceEmit ?? false;
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
const { transformers } = this.compiler.prepareEmit();
const ignoreFiles = this.compiler.ignoreForEmit;
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
if (sourceFiles !== void 0) {
for (const writtenSf of sourceFiles) {
if (writtenSf.isDeclarationFile) {
continue;
}
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
}
}
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
};
const customTransforms = opts && opts.customTransformers;
const beforeTransforms = transformers.before || [];
const afterDeclarationsTransforms = transformers.afterDeclarations;
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
beforeTransforms.push(...customTransforms.beforeTs);
}
const emitResults = [];
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
continue;
}
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
continue;
}
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
emitResults.push(emitCallback({
targetSourceFile,
program: this.tsProgram,
host: this.host,
options: this.options,
emitOnlyDtsFiles: false,
writeFile,
customTransformers: {
before: beforeTransforms,
after: customTransforms && customTransforms.afterTs,
afterDeclarations: afterDeclarationsTransforms
}
}));
}
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
});
if (this.options.tracePerformance !== void 0) {
const perf = this.compiler.perfRecorder.finalize();
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
}
return res;
}
getIndexedComponents() {
return this.compiler.getIndexedComponents();
}
/**
* Gets information for the current program that may be used to generate API
* reference documentation. This includes Angular-specific information, such
* as component inputs and outputs.
*
* @param entryPoint Path to the entry point for the package for which API
* docs should be extracted.
*/
getApiDocumentation(entryPoint, privateModules) {
return this.compiler.getApiDocumentation(entryPoint, privateModules);
}
getEmittedSourceFiles() {
throw new Error("Method not implemented.");
}
};
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
function mergeEmitResults(emitResults) {
const diagnostics = [];
let emitSkipped = false;
const emittedFiles = [];
for (const er of emitResults) {
diagnostics.push(...er.diagnostics);
emitSkipped = emitSkipped || er.emitSkipped;
emittedFiles.push(...er.emittedFiles || []);
}
return { diagnostics, emitSkipped, emittedFiles };
}
// packages/compiler-cli/src/transformers/program.js
function createProgram({ rootNames, options, host, oldProgram }) {
return new NgtscProgram(rootNames, options, host, oldProgram);
}
// packages/compiler-cli/src/perform_compile.js
import ts5 from "typescript";
// packages/compiler-cli/src/transformers/util.js
import ts4 from "typescript";
function createMessageDiagnostic(messageText) {
return {
file: void 0,
start: void 0,
length: void 0,
category: ts4.DiagnosticCategory.Message,
messageText,
code: DEFAULT_ERROR_CODE,
source: SOURCE
};
}
// packages/compiler-cli/src/perform_compile.js
var defaultFormatHost = {
getCurrentDirectory: () => ts5.sys.getCurrentDirectory(),
getCanonicalFileName: (fileName) => fileName,
getNewLine: () => ts5.sys.newLine
};
function formatDiagnostics(diags, host = defaultFormatHost) {
if (diags && diags.length) {
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts5.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
} else {
return "";
}
}
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
const absProject = host.resolve(project);
const projectIsDir = host.lstat(absProject).isDirectory();
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
const basePath = host.resolve(projectDir);
return { projectFile, basePath };
}
function readConfiguration(project, existingOptions, host = getFileSystem()) {
try {
const fs = getFileSystem();
const readConfigFile = (configFile) => ts5.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
const { config: config2, error: error2 } = readConfigFile(configFile);
if (error2) {
return parentOptions;
}
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
if (!config2.extends) {
return existingNgCompilerOptions;
}
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
}, existingNgCompilerOptions);
};
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
const configFileName = host.resolve(host.pwd(), projectFile);
const { config, error } = readConfigFile(projectFile);
if (error) {
return {
project,
errors: [error],
rootNames: [],
options: {},
emitFlags: EmitFlags.Default
};
}
const existingCompilerOptions = {
genDir: basePath,
basePath,
...readAngularCompilerOptions(configFileName),
...existingOptions
};
const parseConfigHost = createParseConfigHost(host, fs);
const { options, errors, fileNames: rootNames, projectReferences } = ts5.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
let emitFlags = EmitFlags.Default;
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
emitFlags |= EmitFlags.Metadata;
}
if (options["skipTemplateCodegen"]) {
emitFlags = emitFlags & ~EmitFlags.Codegen;
}
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
} catch (e) {
const errors = [
{
category: ts5.DiagnosticCategory.Error,
messageText: e.stack ?? e.message,
file: void 0,
start: void 0,
length: void 0,
source: "angular",
code: UNKNOWN_ERROR_CODE
}
];
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
}
}
function createParseConfigHost(host, fs = getFileSystem()) {
return {
fileExists: host.exists.bind(host),
readDirectory: createFileSystemTsReadDirectoryFn(fs),
readFile: host.readFile.bind(host),
useCaseSensitiveFileNames: fs.isCaseSensitive()
};
}
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
if (result !== null) {
return result;
}
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
}
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
if (host.exists(extendedConfigPath)) {
return extendedConfigPath;
}
} else {
const parseConfigHost = createParseConfigHost(host, fs);
const { resolvedModule } = ts5.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts5.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
if (resolvedModule) {
return absoluteFrom(resolvedModule.resolvedFileName);
}
}
return null;
}
function exitCodeFromResult(diags) {
if (!diags)
return 0;
if (diags.every((diag) => diag.category !== ts5.DiagnosticCategory.Error)) {
return 0;
}
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
}
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
let program;
let emitResult;
let allDiagnostics = [];
try {
if (!host) {
host = createCompilerHost({ options });
}
if (modifiedResourceFiles) {
host.getModifiedResourceFiles = () => modifiedResourceFiles;
}
program = createProgram({ rootNames, host, options, oldProgram });
const beforeDiags = Date.now();
allDiagnostics.push(...gatherDiagnostics(program));
if (options.diagnostics) {
const afterDiags = Date.now();
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
}
if (!hasErrors(allDiagnostics)) {
emitResult = program.emit({
emitCallback,
mergeEmitResultsCallback,
customTransformers,
emitFlags,
forceEmit
});
allDiagnostics.push(...emitResult.diagnostics);
return { diagnostics: allDiagnostics, program, emitResult };
}
return { diagnostics: allDiagnostics, program };
} catch (e) {
program = void 0;
allDiagnostics.push({
category: ts5.DiagnosticCategory.Error,
messageText: e.stack ?? e.message,
code: UNKNOWN_ERROR_CODE,
file: void 0,
start: void 0,
length: void 0
});
return { diagnostics: allDiagnostics, program };
}
}
function defaultGatherDiagnostics(program) {
const allDiagnostics = [];
function checkDiagnostics(diags) {
if (diags) {
allDiagnostics.push(...diags);
return !hasErrors(diags);
}
return true;
}
let checkOtherDiagnostics = true;
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
...program.getTsSemanticDiagnostics(),
...program.getNgStructuralDiagnostics()
]);
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
return allDiagnostics;
}
function hasErrors(diags) {
return diags.some((d) => d.category === ts5.DiagnosticCategory.Error);
}
export {
DEFAULT_ERROR_CODE,
UNKNOWN_ERROR_CODE,
SOURCE,
isTsDiagnostic,
EmitFlags,
createCompilerHost,
NgtscProgram,
createProgram,
createMessageDiagnostic,
formatDiagnostics,
calcProjectFileAndBasePath,
readConfiguration,
exitCodeFromResult,
performCompilation,
defaultGatherDiagnostics
};
/**
* @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 {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
// packages/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.js
var InvalidFileSystem = class {
exists(path) {
throw makeError();
}
readFile(path) {
throw makeError();
}
readFileBuffer(path) {
throw makeError();
}
writeFile(path, data, exclusive) {
throw makeError();
}
removeFile(path) {
throw makeError();
}
symlink(target, path) {
throw makeError();
}
readdir(path) {
throw makeError();
}
lstat(path) {
throw makeError();
}
stat(path) {
throw makeError();
}
pwd() {
throw makeError();
}
chdir(path) {
throw makeError();
}
extname(path) {
throw makeError();
}
copyFile(from, to) {
throw makeError();
}
moveFile(from, to) {
throw makeError();
}
ensureDir(path) {
throw makeError();
}
removeDeep(path) {
throw makeError();
}
isCaseSensitive() {
throw makeError();
}
resolve(...paths) {
throw makeError();
}
dirname(file) {
throw makeError();
}
join(basePath, ...paths) {
throw makeError();
}
isRoot(path) {
throw makeError();
}
isRooted(path) {
throw makeError();
}
relative(from, to) {
throw makeError();
}
basename(filePath, extension) {
throw makeError();
}
realpath(filePath) {
throw makeError();
}
getDefaultLibLocation() {
throw makeError();
}
normalize(path) {
throw makeError();
}
};
function makeError() {
return new Error("FileSystem has not been configured. Please call `setFileSystem()` before calling this method.");
}
// packages/compiler-cli/src/ngtsc/file_system/src/util.js
var TS_DTS_JS_EXTENSION = /(?:\.d)?\.ts$|\.js$/;
function normalizeSeparators(path) {
return path.replace(/\\/g, "/");
}
function stripExtension(path) {
return path.replace(TS_DTS_JS_EXTENSION, "");
}
function getSourceFileOrError(program, fileName) {
const sf = program.getSourceFile(fileName);
if (sf === void 0) {
throw new Error(`Program does not contain "${fileName}" - available files are ${program.getSourceFiles().map((sf2) => sf2.fileName).join(", ")}`);
}
return sf;
}
// packages/compiler-cli/src/ngtsc/file_system/src/helpers.js
var fs = new InvalidFileSystem();
function getFileSystem() {
return fs;
}
function setFileSystem(fileSystem) {
fs = fileSystem;
}
function absoluteFrom(path) {
if (!fs.isRooted(path)) {
throw new Error(`Internal Error: absoluteFrom(${path}): path is not absolute`);
}
return fs.resolve(path);
}
var ABSOLUTE_PATH = Symbol("AbsolutePath");
function absoluteFromSourceFile(sf) {
const sfWithPatch = sf;
if (sfWithPatch[ABSOLUTE_PATH] === void 0) {
sfWithPatch[ABSOLUTE_PATH] = fs.resolve(sfWithPatch.fileName);
}
return sfWithPatch[ABSOLUTE_PATH];
}
function relativeFrom(path) {
const normalized = normalizeSeparators(path);
if (fs.isRooted(normalized)) {
throw new Error(`Internal Error: relativeFrom(${path}): path is not relative`);
}
return normalized;
}
function dirname(file) {
return fs.dirname(file);
}
function join(basePath, ...paths) {
return fs.join(basePath, ...paths);
}
function resolve(basePath, ...paths) {
return fs.resolve(basePath, ...paths);
}
function isRoot(path) {
return fs.isRoot(path);
}
function isRooted(path) {
return fs.isRooted(path);
}
function relative(from, to) {
return fs.relative(from, to);
}
function basename(filePath, extension) {
return fs.basename(filePath, extension);
}
function isLocalRelativePath(relativePath) {
return !isRooted(relativePath) && !relativePath.startsWith("..");
}
function toRelativeImport(relativePath) {
return isLocalRelativePath(relativePath) ? `./${relativePath}` : relativePath;
}
// packages/compiler-cli/src/ngtsc/file_system/src/compiler_host.js
import * as os from "os";
import ts from "typescript";
var NgtscCompilerHost = class {
fs;
options;
constructor(fs2, options = {}) {
this.fs = fs2;
this.options = options;
}
getSourceFile(fileName, languageVersion) {
const text = this.readFile(fileName);
return text !== void 0 ? ts.createSourceFile(fileName, text, languageVersion, true) : void 0;
}
getDefaultLibFileName(options) {
return this.fs.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
}
getDefaultLibLocation() {
return this.fs.getDefaultLibLocation();
}
writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles) {
const path = absoluteFrom(fileName);
this.fs.ensureDir(this.fs.dirname(path));
this.fs.writeFile(path, data);
}
getCurrentDirectory() {
return this.fs.pwd();
}
getCanonicalFileName(fileName) {
return this.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
}
useCaseSensitiveFileNames() {
return this.fs.isCaseSensitive();
}
getNewLine() {
switch (this.options.newLine) {
case ts.NewLineKind.CarriageReturnLineFeed:
return "\r\n";
case ts.NewLineKind.LineFeed:
return "\n";
default:
return os.EOL;
}
}
fileExists(fileName) {
const absPath = this.fs.resolve(fileName);
return this.fs.exists(absPath) && this.fs.stat(absPath).isFile();
}
readFile(fileName) {
const absPath = this.fs.resolve(fileName);
if (!this.fileExists(absPath)) {
return void 0;
}
return this.fs.readFile(absPath);
}
realpath(path) {
return this.fs.realpath(this.fs.resolve(path));
}
};
// packages/compiler-cli/src/ngtsc/file_system/src/logical.js
var LogicalProjectPath = {
/**
* Get the relative path between two `LogicalProjectPath`s.
*
* This will return a `PathSegment` which would be a valid module specifier to use in `from` when
* importing from `to`.
*/
relativePathBetween: function(from, to) {
const relativePath = relative(dirname(resolve(from)), resolve(to));
return toRelativeImport(relativePath);
}
};
var LogicalFileSystem = class {
compilerHost;
/**
* The root directories of the project, sorted with the longest path first.
*/
rootDirs;
/**
* The same root directories as `rootDirs` but with each one converted to its
* canonical form for matching in case-insensitive file-systems.
*/
canonicalRootDirs;
/**
* A cache of file paths to project paths, because computation of these paths is slightly
* expensive.
*/
cache = /* @__PURE__ */ new Map();
constructor(rootDirs, compilerHost) {
this.compilerHost = compilerHost;
this.rootDirs = rootDirs.concat([]).sort((a, b) => b.length - a.length);
this.canonicalRootDirs = this.rootDirs.map((dir) => this.compilerHost.getCanonicalFileName(dir));
}
/**
* Get the logical path in the project of a `ts.SourceFile`.
*
* This method is provided as a convenient alternative to calling
* `logicalPathOfFile(absoluteFromSourceFile(sf))`.
*/
logicalPathOfSf(sf) {
return this.logicalPathOfFile(absoluteFromSourceFile(sf));
}
/**
* Get the logical path in the project of a source file.
*
* @returns A `LogicalProjectPath` to the source file, or `null` if the source file is not in any
* of the TS project's root directories.
*/
logicalPathOfFile(physicalFile) {
if (!this.cache.has(physicalFile)) {
const canonicalFilePath = this.compilerHost.getCanonicalFileName(physicalFile);
let logicalFile = null;
for (let i = 0; i < this.rootDirs.length; i++) {
const rootDir = this.rootDirs[i];
const canonicalRootDir = this.canonicalRootDirs[i];
if (isWithinBasePath(canonicalRootDir, canonicalFilePath)) {
logicalFile = this.createLogicalProjectPath(physicalFile, rootDir);
if (logicalFile.indexOf("/node_modules/") !== -1) {
logicalFile = null;
} else {
break;
}
}
}
this.cache.set(physicalFile, logicalFile);
}
return this.cache.get(physicalFile);
}
createLogicalProjectPath(file, rootDir) {
const logicalPath = stripExtension(file.slice(rootDir.length));
return logicalPath.startsWith("/") ? logicalPath : "/" + logicalPath;
}
};
function isWithinBasePath(base, path) {
return isLocalRelativePath(relative(base, path));
}
// packages/compiler-cli/src/ngtsc/file_system/src/ts_read_directory.js
import ts2 from "typescript";
function createFileSystemTsReadDirectoryFn(fs2) {
if (ts2.matchFiles === void 0) {
throw Error("Unable to read directory in configured file system. This means that TypeScript changed its file matching internals.\n\nPlease consider downgrading your TypeScript version, and report an issue in the Angular framework repository.");
}
const matchFilesFn = ts2.matchFiles.bind(ts2);
return (rootDir, extensions, excludes, includes, depth) => {
const directoryExists = (p) => {
const resolvedPath = fs2.resolve(p);
return fs2.exists(resolvedPath) && fs2.stat(resolvedPath).isDirectory();
};
return matchFilesFn(rootDir, extensions, excludes, includes, fs2.isCaseSensitive(), fs2.pwd(), depth, (p) => {
const resolvedPath = fs2.resolve(p);
if (!directoryExists(resolvedPath)) {
return { directories: [], files: [] };
}
const children = fs2.readdir(resolvedPath);
const files = [];
const directories = [];
for (const child of children) {
if (fs2.stat(fs2.join(resolvedPath, child))?.isDirectory()) {
directories.push(child);
} else {
files.push(child);
}
}
return { files, directories };
}, (p) => fs2.resolve(p), (p) => directoryExists(p));
};
}
export {
InvalidFileSystem,
stripExtension,
getSourceFileOrError,
getFileSystem,
setFileSystem,
absoluteFrom,
absoluteFromSourceFile,
relativeFrom,
dirname,
join,
resolve,
isRoot,
isRooted,
relative,
basename,
isLocalRelativePath,
toRelativeImport,
NgtscCompilerHost,
LogicalProjectPath,
LogicalFileSystem,
createFileSystemTsReadDirectoryFn
};
/**
* @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 {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
DEFAULT_ERROR_CODE,
EmitFlags,
SOURCE,
createCompilerHost,
createMessageDiagnostic,
exitCodeFromResult,
formatDiagnostics,
performCompilation,
readConfiguration
} from "./chunk-EZPRBQ4S.js";
// packages/compiler-cli/src/main.js
import ts2 from "typescript";
import yargs from "yargs";
// packages/compiler-cli/src/perform_watch.js
import * as chokidar from "chokidar";
import * as path from "path";
import ts from "typescript";
function totalCompilationTimeDiagnostic(timeInMillis) {
let duration;
if (timeInMillis > 1e3) {
duration = `${(timeInMillis / 1e3).toPrecision(2)}s`;
} else {
duration = `${timeInMillis}ms`;
}
return {
category: ts.DiagnosticCategory.Message,
messageText: `Total time: ${duration}`,
code: DEFAULT_ERROR_CODE,
source: SOURCE,
file: void 0,
start: void 0,
length: void 0
};
}
var FileChangeEvent;
(function(FileChangeEvent2) {
FileChangeEvent2[FileChangeEvent2["Change"] = 0] = "Change";
FileChangeEvent2[FileChangeEvent2["CreateDelete"] = 1] = "CreateDelete";
FileChangeEvent2[FileChangeEvent2["CreateDeleteDir"] = 2] = "CreateDeleteDir";
})(FileChangeEvent || (FileChangeEvent = {}));
function createPerformWatchHost(configFileName, reportDiagnostics, existingOptions, createEmitCallback) {
return {
reportDiagnostics,
createCompilerHost: (options) => createCompilerHost({ options }),
readConfiguration: () => readConfiguration(configFileName, existingOptions),
createEmitCallback: (options) => createEmitCallback ? createEmitCallback(options) : void 0,
onFileChange: (options, listener, ready) => {
if (!options.basePath) {
reportDiagnostics([
{
category: ts.DiagnosticCategory.Error,
messageText: "Invalid configuration option. baseDir not specified",
source: SOURCE,
code: DEFAULT_ERROR_CODE,
file: void 0,
start: void 0,
length: void 0
}
]);
return { close: () => {
} };
}
const watcher = chokidar.watch(options.basePath, {
// ignore .dotfiles, .js and .map files.
// can't ignore other files as we e.g. want to recompile if an `.html` file changes as well.
ignored: (path2) => /((^[\/\\])\..)|(\.js$)|(\.map$)|(\.metadata\.json|node_modules)/.test(path2),
ignoreInitial: true,
persistent: true
});
watcher.on("all", (event, path2) => {
switch (event) {
case "change":
listener(FileChangeEvent.Change, path2);
break;
case "unlink":
case "add":
listener(FileChangeEvent.CreateDelete, path2);
break;
case "unlinkDir":
case "addDir":
listener(FileChangeEvent.CreateDeleteDir, path2);
break;
}
});
watcher.on("ready", ready);
return { close: () => watcher.close(), ready };
},
setTimeout: ts.sys.clearTimeout && ts.sys.setTimeout || setTimeout,
clearTimeout: ts.sys.setTimeout && ts.sys.clearTimeout || clearTimeout
};
}
function performWatchCompilation(host) {
let cachedProgram;
let cachedCompilerHost;
let cachedOptions;
let timerHandleForRecompilation;
const ignoreFilesForWatch = /* @__PURE__ */ new Set();
const fileCache = /* @__PURE__ */ new Map();
const firstCompileResult = doCompilation();
let resolveReadyPromise;
const readyPromise = new Promise((resolve) => resolveReadyPromise = resolve);
const fileWatcher = host.onFileChange(cachedOptions.options, watchedFileChanged, resolveReadyPromise);
return { close, ready: (cb) => readyPromise.then(cb), firstCompileResult };
function cacheEntry(fileName) {
fileName = path.normalize(fileName);
let entry = fileCache.get(fileName);
if (!entry) {
entry = {};
fileCache.set(fileName, entry);
}
return entry;
}
function close() {
fileWatcher.close();
if (timerHandleForRecompilation) {
host.clearTimeout(timerHandleForRecompilation.timerHandle);
timerHandleForRecompilation = void 0;
}
}
function doCompilation() {
if (!cachedOptions) {
cachedOptions = host.readConfiguration();
}
if (cachedOptions.errors && cachedOptions.errors.length) {
host.reportDiagnostics(cachedOptions.errors);
return cachedOptions.errors;
}
const startTime = Date.now();
if (!cachedCompilerHost) {
cachedCompilerHost = host.createCompilerHost(cachedOptions.options);
const originalWriteFileCallback = cachedCompilerHost.writeFile;
cachedCompilerHost.writeFile = function(fileName, data, writeByteOrderMark, onError, sourceFiles = []) {
ignoreFilesForWatch.add(path.normalize(fileName));
return originalWriteFileCallback(fileName, data, writeByteOrderMark, onError, sourceFiles);
};
const originalFileExists = cachedCompilerHost.fileExists;
cachedCompilerHost.fileExists = function(fileName) {
const ce = cacheEntry(fileName);
if (ce.exists == null) {
ce.exists = originalFileExists.call(this, fileName);
}
return ce.exists;
};
const originalGetSourceFile = cachedCompilerHost.getSourceFile;
cachedCompilerHost.getSourceFile = function(fileName, languageVersion) {
const ce = cacheEntry(fileName);
if (!ce.sf) {
ce.sf = originalGetSourceFile.call(this, fileName, languageVersion);
}
return ce.sf;
};
const originalReadFile = cachedCompilerHost.readFile;
cachedCompilerHost.readFile = function(fileName) {
const ce = cacheEntry(fileName);
if (ce.content == null) {
ce.content = originalReadFile.call(this, fileName);
}
return ce.content;
};
cachedCompilerHost.getModifiedResourceFiles = function() {
if (timerHandleForRecompilation === void 0) {
return void 0;
}
return timerHandleForRecompilation.modifiedResourceFiles;
};
}
ignoreFilesForWatch.clear();
const oldProgram = cachedProgram;
cachedProgram = void 0;
const compileResult = performCompilation({
rootNames: cachedOptions.rootNames,
options: cachedOptions.options,
host: cachedCompilerHost,
oldProgram,
emitCallback: host.createEmitCallback(cachedOptions.options)
});
if (compileResult.diagnostics.length) {
host.reportDiagnostics(compileResult.diagnostics);
}
const endTime = Date.now();
if (cachedOptions.options.diagnostics) {
const totalTime = (endTime - startTime) / 1e3;
host.reportDiagnostics([totalCompilationTimeDiagnostic(endTime - startTime)]);
}
const exitCode = exitCodeFromResult(compileResult.diagnostics);
if (exitCode == 0) {
cachedProgram = compileResult.program;
host.reportDiagnostics([
createMessageDiagnostic("Compilation complete. Watching for file changes.")
]);
} else {
host.reportDiagnostics([
createMessageDiagnostic("Compilation failed. Watching for file changes.")
]);
}
return compileResult.diagnostics;
}
function resetOptions() {
cachedProgram = void 0;
cachedCompilerHost = void 0;
cachedOptions = void 0;
}
function watchedFileChanged(event, fileName) {
const normalizedPath = path.normalize(fileName);
if (cachedOptions && event === FileChangeEvent.Change && // TODO(chuckj): validate that this is sufficient to skip files that were written.
// This assumes that the file path we write is the same file path we will receive in the
// change notification.
normalizedPath === path.normalize(cachedOptions.project)) {
resetOptions();
} else if (event === FileChangeEvent.CreateDelete || event === FileChangeEvent.CreateDeleteDir) {
cachedOptions = void 0;
}
if (event === FileChangeEvent.CreateDeleteDir) {
fileCache.clear();
} else {
fileCache.delete(normalizedPath);
}
if (!ignoreFilesForWatch.has(normalizedPath)) {
startTimerForRecompilation(normalizedPath);
}
}
function startTimerForRecompilation(changedPath) {
if (timerHandleForRecompilation) {
host.clearTimeout(timerHandleForRecompilation.timerHandle);
} else {
timerHandleForRecompilation = {
modifiedResourceFiles: /* @__PURE__ */ new Set(),
timerHandle: void 0
};
}
timerHandleForRecompilation.timerHandle = host.setTimeout(recompile, 250);
timerHandleForRecompilation.modifiedResourceFiles.add(changedPath);
}
function recompile() {
host.reportDiagnostics([
createMessageDiagnostic("File change detected. Starting incremental compilation.")
]);
doCompilation();
timerHandleForRecompilation = void 0;
}
}
// packages/compiler-cli/src/main.js
function main(args, consoleError = console.error, config, customTransformers, programReuse, modifiedResourceFiles) {
let { project, rootNames, options, errors: configErrors, watch: watch2, emitFlags } = config || readNgcCommandLineAndConfiguration(args);
if (configErrors.length) {
return reportErrorsAndExit(
configErrors,
/*options*/
void 0,
consoleError
);
}
if (watch2) {
const result = watchMode(project, options, consoleError);
return reportErrorsAndExit(result.firstCompileResult, options, consoleError);
}
let oldProgram;
if (programReuse !== void 0) {
oldProgram = programReuse.program;
}
const { diagnostics: compileDiags, program } = performCompilation({
rootNames,
options,
emitFlags,
oldProgram,
customTransformers,
modifiedResourceFiles
});
if (programReuse !== void 0) {
programReuse.program = program;
}
return reportErrorsAndExit(compileDiags, options, consoleError);
}
function readNgcCommandLineAndConfiguration(args) {
const options = {};
const parsedArgs = yargs(args).parserConfiguration({ "strip-aliased": true }).option("i18nFile", { type: "string" }).option("i18nFormat", { type: "string" }).option("locale", { type: "string" }).option("missingTranslation", { type: "string", choices: ["error", "warning", "ignore"] }).option("outFile", { type: "string" }).option("watch", { type: "boolean", alias: ["w"] }).parseSync();
if (parsedArgs.i18nFile)
options.i18nInFile = parsedArgs.i18nFile;
if (parsedArgs.i18nFormat)
options.i18nInFormat = parsedArgs.i18nFormat;
if (parsedArgs.locale)
options.i18nInLocale = parsedArgs.locale;
if (parsedArgs.missingTranslation)
options.i18nInMissingTranslations = parsedArgs.missingTranslation;
const config = readCommandLineAndConfiguration(args, options, [
"i18nFile",
"i18nFormat",
"locale",
"missingTranslation",
"watch"
]);
return { ...config, watch: parsedArgs.watch };
}
function readCommandLineAndConfiguration(args, existingOptions = {}, ngCmdLineOptions = []) {
let cmdConfig = ts2.parseCommandLine(args);
const project = cmdConfig.options.project || ".";
const cmdErrors = cmdConfig.errors.filter((e) => {
if (typeof e.messageText === "string") {
const msg = e.messageText;
return !ngCmdLineOptions.some((o) => msg.indexOf(o) >= 0);
}
return true;
});
if (cmdErrors.length) {
return {
project,
rootNames: [],
options: cmdConfig.options,
errors: cmdErrors,
emitFlags: EmitFlags.Default
};
}
const config = readConfiguration(project, cmdConfig.options);
const options = { ...config.options, ...existingOptions };
if (options.locale) {
options.i18nInLocale = options.locale;
}
return {
project,
rootNames: config.rootNames,
options,
errors: config.errors,
emitFlags: config.emitFlags
};
}
function getFormatDiagnosticsHost(options) {
const basePath = options ? options.basePath : void 0;
return {
getCurrentDirectory: () => basePath || ts2.sys.getCurrentDirectory(),
// We need to normalize the path separators here because by default, TypeScript
// compiler hosts use posix canonical paths. In order to print consistent diagnostics,
// we also normalize the paths.
getCanonicalFileName: (fileName) => fileName.replace(/\\/g, "/"),
getNewLine: () => {
if (options && options.newLine !== void 0) {
return options.newLine === ts2.NewLineKind.LineFeed ? "\n" : "\r\n";
}
return ts2.sys.newLine;
}
};
}
function reportErrorsAndExit(allDiagnostics, options, consoleError = console.error) {
const errorsAndWarnings = allDiagnostics.filter((d) => d.category !== ts2.DiagnosticCategory.Message);
printDiagnostics(errorsAndWarnings, options, consoleError);
return exitCodeFromResult(allDiagnostics);
}
function watchMode(project, options, consoleError) {
return performWatchCompilation(createPerformWatchHost(project, (diagnostics) => {
printDiagnostics(diagnostics, options, consoleError);
}, options, void 0));
}
function printDiagnostics(diagnostics, options, consoleError) {
if (diagnostics.length === 0) {
return;
}
const formatHost = getFormatDiagnosticsHost(options);
consoleError(formatDiagnostics(diagnostics, formatHost));
}
export {
main,
readCommandLineAndConfiguration
};
/**
* @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
*/