Skip to content

Commit c83805b

Browse files
author
Angular Builds
committed
c73e28e91 refactor(@angular-devkit/build-angular): export executeExtractI18nBuilder
1 parent 5350057 commit c83805b

File tree

9 files changed

+59
-34
lines changed

9 files changed

+59
-34
lines changed

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "0.900.0-next.19+200.713f95d",
3+
"version": "0.900.0-next.19+205.c73e28e",
44
"description": "Angular Webpack Build Facade",
55
"experimental": true,
66
"main": "src/index.js",
77
"typings": "src/index.d.ts",
88
"builders": "builders.json",
99
"dependencies": {
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#713f95d67",
11-
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#713f95d67",
12-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#713f95d67",
13-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#713f95d67",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#c73e28e91",
11+
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#c73e28e91",
12+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#c73e28e91",
13+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#c73e28e91",
1414
"@babel/core": "7.7.4",
1515
"@babel/generator": "7.7.4",
1616
"@babel/preset-env": "7.7.4",
17-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#713f95d67",
17+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#c73e28e91",
1818
"ajv": "6.10.2",
1919
"autoprefixer": "9.7.3",
2020
"babel-loader": "8.0.6",

src/angular-cli-files/models/webpack-configs/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ function getCommonConfig(wco) {
388388
alias,
389389
},
390390
resolveLoader: {
391+
symlinks: !buildOptions.preserveSymlinks,
391392
modules: loaderNodeModules,
392393
},
393394
context: projectRoot,

src/extract-i18n/index.d.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { BuilderContext } from '@angular-devkit/architect';
19
import { JsonObject } from '@angular-devkit/core';
2-
import { Schema as ExtractI18nBuilderOptions } from './schema';
3-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<JsonObject & ExtractI18nBuilderOptions>;
10+
import { Schema } from './schema';
11+
export declare type ExtractI18nBuilderOptions = Schema & JsonObject;
12+
export declare function execute(options: ExtractI18nBuilderOptions, context: BuilderContext): Promise<import("../../../build_webpack/src").BuildResult>;
13+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<JsonObject & Schema>;
414
export default _default;

src/extract-i18n/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@ async function execute(options, context) {
107107
webpackFactory: await Promise.resolve().then(() => require('webpack')),
108108
}).toPromise();
109109
}
110+
exports.execute = execute;
110111
exports.default = architect_1.createBuilder(execute);

src/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from './transforms';
99
export { AssetPattern, AssetPatternClass as AssetPatternObject, Budget, ExtraEntryPoint, ExtraEntryPointClass as ExtraEntryPointObject, FileReplacement, OptimizationClass as OptimizationObject, OptimizationUnion, OutputHashing, Schema as BrowserBuilderOptions, SourceMapClass as SourceMapObject, SourceMapUnion, StylePreprocessorOptions, Type, } from './browser/schema';
1010
export { buildWebpackBrowser as executeBrowserBuilder, BrowserBuilderOutput, } from './browser';
1111
export { serveWebpackBrowser as executeDevServerBuilder, DevServerBuilderOptions, DevServerBuilderOutput, } from './dev-server';
12+
export { execute as executeExtractI18nBuilder, ExtractI18nBuilderOptions, } from './extract-i18n';
1213
export { execute as executeKarmaBuilder, KarmaBuilderOptions, KarmaConfigOptions, } from './karma';
1314
export { execute as executeProtractorBuilder, ProtractorBuilderOptions, } from './protractor';
1415
export { execute as executeServerBuilder, ServerBuilderOptions, ServerBuilderOutput, } from './server';

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var browser_1 = require("./browser");
1414
exports.executeBrowserBuilder = browser_1.buildWebpackBrowser;
1515
var dev_server_1 = require("./dev-server");
1616
exports.executeDevServerBuilder = dev_server_1.serveWebpackBrowser;
17+
var extract_i18n_1 = require("./extract-i18n");
18+
exports.executeExtractI18nBuilder = extract_i18n_1.execute;
1719
var karma_1 = require("./karma");
1820
exports.executeKarmaBuilder = karma_1.execute;
1921
var protractor_1 = require("./protractor");

src/utils/i18n-options.js

+26-22
Original file line numberDiff line numberDiff line change
@@ -137,32 +137,36 @@ async function configureI18nBuild(context, options) {
137137
const loader = await load_translations_1.createTranslationLoader();
138138
const usedFormats = new Set();
139139
for (const [locale, desc] of Object.entries(i18n.locales)) {
140-
if (i18n.inlineLocales.has(locale) && desc.file) {
141-
const result = loader(path.join(context.workspaceRoot, desc.file));
142-
for (const diagnostics of result.diagnostics.messages) {
143-
if (diagnostics.type === 'error') {
144-
throw new Error(`Error parsing translation file '${desc.file}': ${diagnostics.message}`);
145-
}
146-
else {
147-
context.logger.warn(`WARNING [${desc.file}]: ${diagnostics.message}`);
148-
}
149-
}
150-
usedFormats.add(result.format);
151-
if (usedFormats.size > 1 && tsConfig.options.enableI18nLegacyMessageIdFormat !== false) {
152-
// This limitation is only for legacy message id support (defaults to true as of 9.0)
153-
throw new Error('Localization currently only supports using one type of translation file format for the entire application.');
154-
}
155-
desc.format = result.format;
156-
desc.translation = result.translation;
157-
desc.integrity = result.integrity;
158-
const localeDataPath = findLocaleDataPath(locale, localeDataBasePath);
159-
if (!localeDataPath) {
160-
context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
140+
if (!i18n.inlineLocales.has(locale)) {
141+
continue;
142+
}
143+
const localeDataPath = findLocaleDataPath(locale, localeDataBasePath);
144+
if (!localeDataPath) {
145+
context.logger.warn(`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`);
146+
}
147+
else {
148+
desc.dataPath = localeDataPath;
149+
}
150+
if (!desc.file) {
151+
continue;
152+
}
153+
const result = loader(path.join(context.workspaceRoot, desc.file));
154+
for (const diagnostics of result.diagnostics.messages) {
155+
if (diagnostics.type === 'error') {
156+
throw new Error(`Error parsing translation file '${desc.file}': ${diagnostics.message}`);
161157
}
162158
else {
163-
desc.dataPath = localeDataPath;
159+
context.logger.warn(`WARNING [${desc.file}]: ${diagnostics.message}`);
164160
}
165161
}
162+
usedFormats.add(result.format);
163+
if (usedFormats.size > 1 && tsConfig.options.enableI18nLegacyMessageIdFormat !== false) {
164+
// This limitation is only for legacy message id support (defaults to true as of 9.0)
165+
throw new Error('Localization currently only supports using one type of translation file format for the entire application.');
166+
}
167+
desc.format = result.format;
168+
desc.translation = result.translation;
169+
desc.integrity = result.integrity;
166170
}
167171
// Legacy message id's require the format of the translations
168172
if (usedFormats.size > 0) {

src/utils/process-bundle.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ async function process(options) {
6767
filename: options.filename,
6868
inputSourceMap: manualSourceMaps ? undefined : sourceMap,
6969
babelrc: false,
70-
// modules aren't needed since the bundles use webpack's custom module loading
71-
// 'transform-typeof-symbol' generates slower code
72-
presets: [['@babel/preset-env', { modules: false, exclude: ['transform-typeof-symbol'] }]],
70+
presets: [[
71+
require.resolve('@babel/preset-env'),
72+
{
73+
// modules aren't needed since the bundles use webpack's custom module loading
74+
modules: false,
75+
// 'transform-typeof-symbol' generates slower code
76+
exclude: ['transform-typeof-symbol'],
77+
},
78+
]],
7379
plugins: options.replacements ? [createReplacePlugin(options.replacements)] : [],
7480
minified: options.optimize,
7581
// `false` ensures it is disabled and prevents large file warnings

uniqueId

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mon Dec 09 2019 22:18:42 GMT+0000 (Coordinated Universal Time)
1+
Mon Dec 09 2019 22:22:03 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)