Skip to content

Commit 28526c6

Browse files
author
Angular Builds
committed
3bf929f build: update browserslist to version 4.6.0
1 parent b2d0dfc commit 28526c6

File tree

15 files changed

+64
-83
lines changed

15 files changed

+64
-83
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "0.800.0-beta.18+94.e333450",
3+
"version": "0.800.0-beta.18+93.3bf929f",
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#e333450",
11-
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#e333450",
12-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#e333450",
13-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#e333450",
14-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#e333450",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#3bf929f",
11+
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#3bf929f",
12+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#3bf929f",
13+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#3bf929f",
14+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#3bf929f",
1515
"ajv": "6.10.0",
1616
"autoprefixer": "9.5.1",
1717
"browserslist": "4.6.0",

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
88
* found in the LICENSE file at https://angular.io/license
99
*/
1010
const license_webpack_plugin_1 = require("license-webpack-plugin");
11+
const path = require("path");
12+
const index_html_webpack_plugin_1 = require("../../plugins/index-html-webpack-plugin");
13+
const package_chunk_sort_1 = require("../../utilities/package-chunk-sort");
1114
const utils_1 = require("./utils");
1215
const SubresourceIntegrityPlugin = require('webpack-subresource-integrity');
1316
function getBrowserConfig(wco) {
14-
const { buildOptions } = wco;
17+
const { root, buildOptions } = wco;
1518
const extraPlugins = [];
1619
let isEval = false;
1720
const { styles: stylesOptimization, scripts: scriptsOptimization } = buildOptions.optimization;
@@ -24,6 +27,17 @@ function getBrowserConfig(wco) {
2427
// Produce eval sourcemaps for development with serve, which are faster.
2528
isEval = true;
2629
}
30+
if (buildOptions.index) {
31+
extraPlugins.push(new index_html_webpack_plugin_1.IndexHtmlWebpackPlugin({
32+
input: path.resolve(root, buildOptions.index),
33+
output: path.basename(buildOptions.index),
34+
baseHref: buildOptions.baseHref,
35+
entrypoints: package_chunk_sort_1.generateEntryPoints(buildOptions),
36+
deployUrl: buildOptions.deployUrl,
37+
sri: buildOptions.subresourceIntegrity,
38+
noModuleEntrypoints: ['polyfills-es5'],
39+
}));
40+
}
2741
if (buildOptions.subresourceIntegrity) {
2842
extraPlugins.push(new SubresourceIntegrityPlugin({
2943
hashFuncNames: ['sha384'],

src/angular-cli-files/plugins/index-html-webpack-plugin.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Compiler } from 'webpack';
2-
import { IndexHtmlTransform } from '../utilities/index-file/write-index-html';
32
export interface IndexHtmlWebpackPluginOptions {
43
input: string;
54
output: string;
@@ -8,7 +7,6 @@ export interface IndexHtmlWebpackPluginOptions {
87
deployUrl?: string;
98
sri: boolean;
109
noModuleEntrypoints: string[];
11-
postTransform?: IndexHtmlTransform;
1210
}
1311
export declare class IndexHtmlWebpackPlugin {
1412
private _options;

src/angular-cli-files/plugins/index-html-webpack-plugin.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
88
* found in the LICENSE file at https://angular.io/license
99
*/
1010
const path = require("path");
11-
const webpack_sources_1 = require("webpack-sources");
1211
const augment_index_html_1 = require("../utilities/index-file/augment-index-html");
13-
const strip_bom_1 = require("../utilities/strip-bom");
1412
function readFile(filename, compilation) {
1513
return new Promise((resolve, reject) => {
1614
compilation.inputFileSystem.readFile(filename, (err, data) => {
1715
if (err) {
1816
reject(err);
1917
return;
2018
}
21-
resolve(strip_bom_1.stripBom(data.toString()));
19+
let content;
20+
if (data.length >= 3 && data[0] === 0xEF && data[1] === 0xBB && data[2] === 0xBF) {
21+
// Strip UTF-8 BOM
22+
content = data.toString('utf8', 3);
23+
}
24+
else if (data.length >= 2 && data[0] === 0xFF && data[1] === 0xFE) {
25+
// Strip UTF-16 LE BOM
26+
content = data.toString('utf16le', 2);
27+
}
28+
else {
29+
content = data.toString();
30+
}
31+
resolve(content);
2232
});
2333
});
2434
}
@@ -57,7 +67,7 @@ class IndexHtmlWebpackPlugin {
5767
}
5868
}
5969
const loadOutputFile = (name) => compilation.assets[name].source();
60-
let indexSource = await augment_index_html_1.augmentIndexHtml({
70+
const indexSource = await augment_index_html_1.augmentIndexHtml({
6171
input: this._options.input,
6272
inputContent,
6373
baseHref: this._options.baseHref,
@@ -68,11 +78,8 @@ class IndexHtmlWebpackPlugin {
6878
loadOutputFile,
6979
entrypoints: this._options.entrypoints,
7080
});
71-
if (this._options.postTransform) {
72-
indexSource = await this._options.postTransform(indexSource);
73-
}
7481
// Add to compilation assets
75-
compilation.assets[this._options.output] = new webpack_sources_1.RawSource(indexSource);
82+
compilation.assets[this._options.output] = indexSource;
7683
});
7784
}
7885
}

src/angular-cli-files/utilities/index-file/augment-index-html.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
import { Source } from 'webpack-sources';
89
export declare type LoadOutputFileFunctionType = (file: string) => Promise<string>;
910
export interface AugmentIndexHtmlOptions {
1011
input: string;
@@ -26,4 +27,4 @@ export interface FileInfo {
2627
name: string;
2728
extension: string;
2829
}
29-
export declare function augmentIndexHtml(params: AugmentIndexHtmlOptions): Promise<string>;
30+
export declare function augmentIndexHtml(params: AugmentIndexHtmlOptions): Promise<Source>;

src/angular-cli-files/utilities/index-file/augment-index-html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async function augmentIndexHtml(params) {
156156
treeAdapter.appendChild(styleElements, element);
157157
}
158158
indexSource.insert(styleInsertionPoint, parse5.serialize(styleElements, { treeAdapter }));
159-
return indexSource.source();
159+
return indexSource;
160160
}
161161
exports.augmentIndexHtml = augmentIndexHtml;
162162
function _generateSriAttributes(content) {

src/angular-cli-files/utilities/index-file/write-index-html.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ export interface WriteIndexHtmlOptions {
1313
host: virtualFs.Host;
1414
outputPath: Path;
1515
indexPath: Path;
16-
files?: EmittedFiles[];
17-
noModuleFiles?: EmittedFiles[];
18-
moduleFiles?: EmittedFiles[];
16+
ES5BuildFiles: EmittedFiles[];
17+
ES2015BuildFiles: EmittedFiles[];
1918
baseHref?: string;
2019
deployUrl?: string;
2120
sri?: boolean;
2221
scripts?: ExtraEntryPoint[];
2322
styles?: ExtraEntryPoint[];
24-
postTransform?: IndexHtmlTransform;
2523
}
26-
export declare type IndexHtmlTransform = (content: string) => Promise<string>;
27-
export declare function writeIndexHtml({ host, outputPath, indexPath, files, noModuleFiles, moduleFiles, baseHref, deployUrl, sri, scripts, styles, postTransform, }: WriteIndexHtmlOptions): Observable<void>;
24+
export declare function writeIndexHtml({ host, outputPath, indexPath, ES5BuildFiles, ES2015BuildFiles, baseHref, deployUrl, sri, scripts, styles, }: WriteIndexHtmlOptions): Observable<void>;

src/angular-cli-files/utilities/index-file/write-index-html.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
const core_1 = require("@angular-devkit/core");
11-
const rxjs_1 = require("rxjs");
1211
const operators_1 = require("rxjs/operators");
1312
const package_chunk_sort_1 = require("../package-chunk-sort");
1413
const strip_bom_1 = require("../strip-bom");
1514
const augment_index_html_1 = require("./augment-index-html");
16-
function writeIndexHtml({ host, outputPath, indexPath, files = [], noModuleFiles = [], moduleFiles = [], baseHref, deployUrl, sri = false, scripts = [], styles = [], postTransform, }) {
15+
function writeIndexHtml({ host, outputPath, indexPath, ES5BuildFiles, ES2015BuildFiles, baseHref, deployUrl, sri = false, scripts = [], styles = [], }) {
1716
return host.read(indexPath)
1817
.pipe(operators_1.map(content => strip_bom_1.stripBom(core_1.virtualFs.fileBufferToString(content))), operators_1.switchMap(content => augment_index_html_1.augmentIndexHtml({
1918
input: core_1.getSystemPath(outputPath),
@@ -22,24 +21,21 @@ function writeIndexHtml({ host, outputPath, indexPath, files = [], noModuleFiles
2221
deployUrl,
2322
sri,
2423
entrypoints: package_chunk_sort_1.generateEntryPoints({ scripts, styles }),
25-
files: filterAndMapBuildFiles(files, ['.js', '.css']),
26-
noModuleFiles: filterAndMapBuildFiles(noModuleFiles, '.js'),
27-
moduleFiles: filterAndMapBuildFiles(moduleFiles, '.js'),
24+
files: filterAndMapBuildFiles(ES5BuildFiles, '.css'),
25+
noModuleFiles: filterAndMapBuildFiles(ES5BuildFiles, '.js'),
26+
moduleFiles: filterAndMapBuildFiles(ES2015BuildFiles, '.js'),
2827
loadOutputFile: async (filePath) => {
2928
return host.read(core_1.join(outputPath, filePath))
3029
.pipe(operators_1.map(data => core_1.virtualFs.fileBufferToString(data)))
3130
.toPromise();
3231
},
33-
})), operators_1.switchMap(content => postTransform ? postTransform(content) : rxjs_1.of(content)), operators_1.map(content => core_1.virtualFs.stringToFileBuffer(content)), operators_1.switchMap(content => host.write(core_1.join(outputPath, core_1.basename(indexPath)), content)));
32+
})), operators_1.map(content => core_1.virtualFs.stringToFileBuffer(content.source())), operators_1.switchMap(content => host.write(core_1.join(outputPath, core_1.basename(indexPath)), content)));
3433
}
3534
exports.writeIndexHtml = writeIndexHtml;
3635
function filterAndMapBuildFiles(files, extensionFilter) {
3736
const filteredFiles = [];
38-
const validExtensions = Array.isArray(extensionFilter)
39-
? extensionFilter
40-
: [extensionFilter];
4137
for (const { file, name, extension, initial } of files) {
42-
if (name && initial && validExtensions.includes(extension)) {
38+
if (name && initial && extension === extensionFilter) {
4339
filteredFiles.push({ file, extension, name });
4440
}
4541
}

src/browser/index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
1111
import { experimental, json, logging, virtualFs } from '@angular-devkit/core';
1212
import * as fs from 'fs';
1313
import * as webpack from 'webpack';
14-
import { IndexHtmlTransform } from '../angular-cli-files/utilities/index-file/write-index-html';
1514
import { ExecutionTransformer } from '../transforms';
1615
import { Schema as BrowserBuilderSchema } from './schema';
1716
export declare type BrowserBuilderOutput = json.JsonObject & BuilderOutput & {
@@ -25,7 +24,6 @@ export declare function buildBrowserWebpackConfigFromContext(options: BrowserBui
2524
export declare function buildWebpackBrowser(options: BrowserBuilderSchema, context: BuilderContext, transforms?: {
2625
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
2726
logging?: WebpackLoggingCallback;
28-
indexHtml?: IndexHtmlTransform;
2927
}): import("rxjs").Observable<BrowserBuilderOutput>;
3028
declare const _default: import("@angular-devkit/architect/src/internal").Builder<json.JsonObject & BrowserBuilderSchema>;
3129
export default _default;

src/browser/index.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,34 +130,20 @@ function buildWebpackBrowser(options, context, transforms = {}) {
130130
}
131131
}, { success: true }, 1), operators_1.bufferCount(configs.length), operators_1.switchMap(buildEvents => {
132132
const success = buildEvents.every(r => r.success);
133-
if (success && options.index) {
134-
let noModuleFiles;
135-
let moduleFiles;
136-
let files;
137-
const [ES5Result, ES2015Result] = buildEvents;
138-
if (buildEvents.length === 2) {
139-
noModuleFiles = ES5Result.emittedFiles;
140-
moduleFiles = ES2015Result.emittedFiles || [];
141-
files = moduleFiles.filter(x => x.extension === '.css');
142-
}
143-
else {
144-
const { emittedFiles = [] } = ES5Result;
145-
files = emittedFiles.filter(x => x.name !== 'polyfills-es5');
146-
noModuleFiles = emittedFiles.filter(x => x.name === 'polyfills-es5');
147-
}
133+
if (success && buildEvents.length === 2 && options.index) {
134+
const { emittedFiles: ES5BuildFiles = [] } = buildEvents[0];
135+
const { emittedFiles: ES2015BuildFiles = [] } = buildEvents[1];
148136
return write_index_html_1.writeIndexHtml({
149137
host,
150138
outputPath: core_1.join(root, options.outputPath),
151139
indexPath: core_1.join(root, options.index),
152-
files,
153-
noModuleFiles,
154-
moduleFiles,
140+
ES5BuildFiles,
141+
ES2015BuildFiles,
155142
baseHref: options.baseHref,
156143
deployUrl: options.deployUrl,
157144
sri: options.subresourceIntegrity,
158145
scripts: options.scripts,
159146
styles: options.styles,
160-
postTransform: transforms.indexHtml,
161147
})
162148
.pipe(operators_1.map(() => ({ success: true })), operators_1.catchError(() => rxjs_1.of({ success: false })));
163149
}

0 commit comments

Comments
 (0)