Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions packages/angular/build/src/tools/angular/linker/oxc-linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { ConsoleLogger, LogLevel } from '@angular/compiler-cli';
import type { Logger } from '@angular/compiler-cli';
import { type DeclarationScope, FileLinker, LinkerEnvironment } from '@angular/compiler-cli/linker';
import type {
AbsoluteFsPath,
Expand Down Expand Up @@ -45,7 +45,34 @@ const noopFileSystem: ReadonlyFileSystem = {
relative: (_from: string, to: string) => to,
} as unknown as ReadonlyFileSystem;

let SHARED_LOGGER: ConsoleLogger;
const defaultLogger: Logger = {
level: 1, // LogLevel.info
debug(...args: string[]) {
if (this.level <= 0) {
// eslint-disable-next-line no-console
console.debug(...args);
}
},
info(...args: string[]) {
if (this.level <= 1) {
// eslint-disable-next-line no-console
console.info(...args);
}
},
warn(...args: string[]) {
if (this.level <= 2) {
// eslint-disable-next-line no-console
console.warn(...args);
}
},
error(...args: string[]) {
if (this.level <= 3) {
// eslint-disable-next-line no-console
console.error(...args);
}
},
};
Comment thread
clydin marked this conversation as resolved.

let SHARED_AST_HOST: OxcAstHost;
let SHARED_DECLARATION_SCOPE: InlineDeclarationScope;

Expand All @@ -56,14 +83,13 @@ export class OxcLinker {
readonly #fileLinker: FileLinker<unknown, string, unknown, string | undefined>;

constructor(filename: string, code: string, jit = false) {
SHARED_LOGGER ??= new ConsoleLogger(LogLevel.info);
SHARED_AST_HOST ??= new OxcAstHost();
SHARED_DECLARATION_SCOPE ??= new InlineDeclarationScope();

const astFactory = new StringAstFactory(code);
const linkerEnvironment = LinkerEnvironment.create(
noopFileSystem,
SHARED_LOGGER,
defaultLogger,
SHARED_AST_HOST,
astFactory,
{ linkerJitMode: jit, sourceMapping: false },
Expand Down
Loading