mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
fix(@angular/build): support reading on-disk files during i18n extraction
If an application has JavaScript files that are sourced directly from disk, the extraction would previously fail due to the i18n extractor only able to access the in-memory generated JavaScript files. The extractor can now access both memory and disk-based JavaScript files.
This commit is contained in:
parent
83b7343ec2
commit
6b544f70e7
@ -9,6 +9,7 @@
|
||||
import type { ɵParsedMessage as LocalizeMessage } from '@angular/localize';
|
||||
import type { MessageExtractor } from '@angular/localize/tools';
|
||||
import type { BuilderContext } from '@angular-devkit/architect';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import nodePath from 'node:path';
|
||||
import { buildApplicationInternal } from '../application';
|
||||
import type {
|
||||
@ -101,6 +102,8 @@ function setupLocalizeExtractor(
|
||||
let content;
|
||||
if (file?.origin === 'memory') {
|
||||
content = textDecoder.decode(file.contents);
|
||||
} else if (file?.origin === 'disk') {
|
||||
content = readFileSync(file.inputPath, 'utf-8');
|
||||
}
|
||||
if (content === undefined) {
|
||||
throw new Error('Unknown file requested: ' + requestedPath);
|
||||
|
@ -11,6 +11,7 @@ import { ResultFile, ResultKind, buildApplicationInternal } from '@angular/build
|
||||
import type { ɵParsedMessage as LocalizeMessage } from '@angular/localize';
|
||||
import type { MessageExtractor } from '@angular/localize/tools';
|
||||
import type { BuilderContext } from '@angular-devkit/architect';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import nodePath from 'node:path';
|
||||
import { BrowserBuilderOptions, convertBrowserOptions } from '../browser-esbuild';
|
||||
import type { NormalizedExtractI18nOptions } from './options';
|
||||
@ -106,6 +107,8 @@ function setupLocalizeExtractor(
|
||||
let content;
|
||||
if (file?.origin === 'memory') {
|
||||
content = textDecoder.decode(file.contents);
|
||||
} else if (file?.origin === 'disk') {
|
||||
content = readFileSync(file.inputPath, 'utf-8');
|
||||
}
|
||||
if (content === undefined) {
|
||||
throw new Error('Unknown file requested: ' + requestedPath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user