@angular-devkit/build-angular 12.1.0-next.3 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +40 -39
- package/src/app-shell/index.js +28 -8
- package/src/babel/plugins/adjust-static-class-members.d.ts +25 -0
- package/src/babel/plugins/adjust-static-class-members.js +251 -0
- package/src/babel/plugins/adjust-typescript-enums.d.ts +21 -0
- package/src/babel/plugins/adjust-typescript-enums.js +123 -0
- package/src/babel/plugins/elide-angular-metadata.d.ts +21 -0
- package/src/babel/plugins/elide-angular-metadata.js +68 -0
- package/src/babel/plugins/pure-toplevel-functions.d.ts +14 -0
- package/src/babel/plugins/pure-toplevel-functions.js +86 -0
- package/src/babel/presets/application.d.ts +1 -0
- package/src/babel/presets/application.js +23 -3
- package/src/babel/webpack-loader.js +39 -1
- package/src/browser/index.d.ts +1 -4
- package/src/browser/index.js +26 -36
- package/src/browser/schema.d.ts +1 -1
- package/src/browser/schema.json +1 -1
- package/src/dev-server/index.d.ts +1 -1
- package/src/dev-server/index.js +68 -47
- package/src/dev-server/tests/execute-fetch.js +4 -1
- package/src/extract-i18n/empty-loader.d.ts +8 -0
- package/src/extract-i18n/empty-loader.js +13 -0
- package/src/extract-i18n/index.d.ts +1 -1
- package/src/extract-i18n/index.js +46 -18
- package/src/extract-i18n/ivy-extract-loader.js +20 -1
- package/src/karma/find-tests.js +20 -1
- package/src/karma/index.js +21 -1
- package/src/karma/schema.d.ts +1 -1
- package/src/karma/schema.json +1 -1
- package/src/karma/tests/setup.d.ts +18 -0
- package/src/karma/tests/setup.js +29 -0
- package/src/ng-packagr/index.js +21 -2
- package/src/protractor/index.js +21 -2
- package/src/sass/sass-service.d.ts +0 -3
- package/src/sass/sass-service.js +8 -9
- package/src/sass/worker.js +4 -2
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +20 -1
- package/src/server/schema.d.ts +1 -1
- package/src/server/schema.json +1 -1
- package/src/tslint/index.js +22 -3
- package/src/typings.d.ts +6 -0
- package/src/utils/action-cache.js +21 -2
- package/src/utils/action-executor.js +21 -2
- package/src/utils/build-browser-features.js +25 -3
- package/src/utils/cache-path.js +5 -2
- package/src/utils/check-port.js +20 -1
- package/src/utils/color.js +20 -1
- package/src/utils/copy-assets.js +26 -4
- package/src/utils/copy-file.js +20 -1
- package/src/utils/delete-output-dir.js +2 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +26 -2
- package/src/utils/find-up.js +20 -1
- package/src/utils/i18n-inlining.js +21 -2
- package/src/utils/i18n-options.js +23 -5
- package/src/utils/index-file/html-rewriting-stream.js +20 -1
- package/src/utils/index-file/index-html-generator.js +20 -1
- package/src/utils/index-file/inline-critical-css.js +20 -1
- package/src/utils/index-file/inline-fonts.js +27 -5
- package/src/utils/is-directory.js +20 -1
- package/src/utils/load-translations.js +26 -7
- package/src/utils/process-bundle.js +34 -12
- package/src/utils/read-tsconfig.js +20 -1
- package/src/utils/service-worker.js +21 -2
- package/src/utils/spinner.d.ts +2 -0
- package/src/utils/spinner.js +18 -2
- package/src/utils/webpack-browser-config.js +21 -2
- package/src/webpack/configs/analytics.d.ts +11 -0
- package/src/webpack/configs/analytics.js +29 -0
- package/src/webpack/configs/common.js +96 -45
- package/src/webpack/configs/dev-server.js +20 -1
- package/src/webpack/configs/index.d.ts +1 -0
- package/src/webpack/configs/index.js +1 -0
- package/src/webpack/configs/server.js +8 -0
- package/src/webpack/configs/stats.d.ts +6 -14
- package/src/webpack/configs/stats.js +5 -8
- package/src/webpack/configs/styles.js +28 -2
- package/src/webpack/configs/test.js +32 -3
- package/src/webpack/configs/typescript.d.ts +2 -9
- package/src/webpack/configs/typescript.js +16 -14
- package/src/webpack/plugins/any-component-style-budget-checker.js +20 -1
- package/src/webpack/plugins/builder-watch-plugin.d.ts +0 -2
- package/src/webpack/plugins/builder-watch-plugin.js +2 -7
- package/src/webpack/plugins/index.js +4 -1
- package/src/webpack/plugins/karma/karma-context.html +1 -1
- package/src/webpack/plugins/karma/karma-debug.html +1 -1
- package/src/webpack/plugins/karma/karma.js +27 -5
- package/src/webpack/plugins/postcss-cli-resources.js +21 -2
- package/src/webpack/plugins/scripts-webpack-plugin.js +20 -1
- package/src/webpack/utils/async-chunks.js +9 -5
- package/src/webpack/utils/helpers.js +20 -1
- package/src/webpack/utils/stats.d.ts +2 -3
- package/src/webpack/utils/stats.js +50 -15
- package/src/extract-i18n/empty-export-default.js +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getKeywords = void 0;
|
|
11
|
+
const core_1 = require("@babel/core");
|
|
12
|
+
/**
|
|
13
|
+
* The name of the Angular class metadata function created by the Angular compiler.
|
|
14
|
+
*/
|
|
15
|
+
const SET_CLASS_METADATA_NAME = 'ɵsetClassMetadata';
|
|
16
|
+
/**
|
|
17
|
+
* Provides one or more keywords that if found within the content of a source file indicate
|
|
18
|
+
* that this plugin should be used with a source file.
|
|
19
|
+
*
|
|
20
|
+
* @returns An a string iterable containing one or more keywords.
|
|
21
|
+
*/
|
|
22
|
+
function getKeywords() {
|
|
23
|
+
return [SET_CLASS_METADATA_NAME];
|
|
24
|
+
}
|
|
25
|
+
exports.getKeywords = getKeywords;
|
|
26
|
+
/**
|
|
27
|
+
* A babel plugin factory function for eliding the Angular class metadata function (`ɵsetClassMetadata`).
|
|
28
|
+
*
|
|
29
|
+
* @returns A babel plugin object instance.
|
|
30
|
+
*/
|
|
31
|
+
function default_1() {
|
|
32
|
+
return {
|
|
33
|
+
visitor: {
|
|
34
|
+
CallExpression(path) {
|
|
35
|
+
var _a;
|
|
36
|
+
const callee = path.node.callee;
|
|
37
|
+
// The function being called must be the metadata function name
|
|
38
|
+
let calleeName;
|
|
39
|
+
if (core_1.types.isMemberExpression(callee) && core_1.types.isIdentifier(callee.property)) {
|
|
40
|
+
calleeName = callee.property.name;
|
|
41
|
+
}
|
|
42
|
+
else if (core_1.types.isIdentifier(callee)) {
|
|
43
|
+
calleeName = callee.name;
|
|
44
|
+
}
|
|
45
|
+
if (calleeName !== SET_CLASS_METADATA_NAME) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// There must be four arguments that meet the following criteria:
|
|
49
|
+
// * First must be an identifier
|
|
50
|
+
// * Second must be an array literal
|
|
51
|
+
const callArguments = path.node.arguments;
|
|
52
|
+
if (callArguments.length !== 4 ||
|
|
53
|
+
!core_1.types.isIdentifier(callArguments[0]) ||
|
|
54
|
+
!core_1.types.isArrayExpression(callArguments[1])) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// The metadata function is always emitted inside a function expression
|
|
58
|
+
if (!((_a = path.getFunctionParent()) === null || _a === void 0 ? void 0 : _a.isFunctionExpression())) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Replace the metadata function with `void 0` which is the equivalent return value
|
|
62
|
+
// of the metadata function.
|
|
63
|
+
path.replaceWith(path.scope.buildUndefinedNode());
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC 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 { PluginObj } from '@babel/core';
|
|
9
|
+
/**
|
|
10
|
+
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
|
|
11
|
+
*
|
|
12
|
+
* @returns A babel plugin object instance.
|
|
13
|
+
*/
|
|
14
|
+
export default function (): PluginObj;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
const core_1 = require("@babel/core");
|
|
33
|
+
const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
|
|
34
|
+
const tslib = __importStar(require("tslib"));
|
|
35
|
+
/**
|
|
36
|
+
* A cached set of TypeScript helper function names used by the helper name matcher utility function.
|
|
37
|
+
*/
|
|
38
|
+
const tslibHelpers = new Set(Object.keys(tslib).filter((h) => h.startsWith('__')));
|
|
39
|
+
/**
|
|
40
|
+
* Determinates whether an identifier name matches one of the TypeScript helper function names.
|
|
41
|
+
*
|
|
42
|
+
* @param name The identifier name to check.
|
|
43
|
+
* @returns True, if the name matches a TypeScript helper name; otherwise, false.
|
|
44
|
+
*/
|
|
45
|
+
function isTslibHelperName(name) {
|
|
46
|
+
const nameParts = name.split('$');
|
|
47
|
+
const originalName = nameParts[0];
|
|
48
|
+
if (nameParts.length > 2 || (nameParts.length === 2 && isNaN(+nameParts[1]))) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return tslibHelpers.has(originalName);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
|
|
55
|
+
*
|
|
56
|
+
* @returns A babel plugin object instance.
|
|
57
|
+
*/
|
|
58
|
+
function default_1() {
|
|
59
|
+
return {
|
|
60
|
+
visitor: {
|
|
61
|
+
CallExpression(path) {
|
|
62
|
+
// If the expression has a function parent, it is not top-level
|
|
63
|
+
if (path.getFunctionParent()) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const callee = path.node.callee;
|
|
67
|
+
if (core_1.types.isFunctionExpression(callee) && path.node.arguments.length !== 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Do not annotate TypeScript helpers emitted by the TypeScript compiler.
|
|
71
|
+
// TypeScript helpers are intended to cause side effects.
|
|
72
|
+
if (core_1.types.isIdentifier(callee) && isTslibHelperName(callee.name)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
helper_annotate_as_pure_1.default(path);
|
|
76
|
+
},
|
|
77
|
+
NewExpression(path) {
|
|
78
|
+
// If the expression has a function parent, it is not top-level
|
|
79
|
+
if (!path.getFunctionParent()) {
|
|
80
|
+
helper_annotate_as_pure_1.default(path);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.default = default_1;
|
|
@@ -6,9 +6,28 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const fs = require("fs");
|
|
11
|
-
const path = require("path");
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const path = __importStar(require("path"));
|
|
12
31
|
function createI18nDiagnostics(reporter) {
|
|
13
32
|
// Babel currently is synchronous so import cannot be used
|
|
14
33
|
const diagnostics = new (require('@angular/localize/src/tools/src/diagnostics').Diagnostics)();
|
|
@@ -80,9 +99,10 @@ function default_1(api, options) {
|
|
|
80
99
|
let needRuntimeTransform = false;
|
|
81
100
|
if ((_a = options.angularLinker) === null || _a === void 0 ? void 0 : _a.shouldLink) {
|
|
82
101
|
// Babel currently is synchronous so import cannot be used
|
|
83
|
-
const { createEs2015LinkerPlugin
|
|
102
|
+
const { createEs2015LinkerPlugin } = require('@angular/compiler-cli/linker/babel');
|
|
84
103
|
plugins.push(createEs2015LinkerPlugin({
|
|
85
104
|
linkerJitMode: options.angularLinker.jitMode,
|
|
105
|
+
sourceMapping: options.angularLinker.sourcemap,
|
|
86
106
|
logger: createNgtscLogger(options.diagnosticReporter),
|
|
87
107
|
fileSystem: {
|
|
88
108
|
resolve: path.resolve,
|
|
@@ -28,7 +28,8 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
28
28
|
inputSourceMap: false,
|
|
29
29
|
});
|
|
30
30
|
return {
|
|
31
|
-
async customOptions({ i18n, scriptTarget, aot, ...rawOptions }, { source }) {
|
|
31
|
+
async customOptions({ i18n, scriptTarget, aot, optimize, ...rawOptions }, { source }) {
|
|
32
|
+
var _a, _b;
|
|
32
33
|
// Must process file if plugins are added
|
|
33
34
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
34
35
|
const customOptions = {
|
|
@@ -42,6 +43,7 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
42
43
|
customOptions.angularLinker = {
|
|
43
44
|
shouldLink: true,
|
|
44
45
|
jitMode: aot !== true,
|
|
46
|
+
sourcemap: false,
|
|
45
47
|
};
|
|
46
48
|
shouldProcess = true;
|
|
47
49
|
}
|
|
@@ -65,6 +67,19 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
65
67
|
customOptions.i18n = i18n;
|
|
66
68
|
shouldProcess = true;
|
|
67
69
|
}
|
|
70
|
+
if (optimize) {
|
|
71
|
+
const angularPackage = /[\\\/]node_modules[\\\/]@angular[\\\/]/.test(this.resourcePath);
|
|
72
|
+
customOptions.optimize = {
|
|
73
|
+
// Angular packages provide additional tested side effects guarantees and can use
|
|
74
|
+
// otherwise unsafe optimizations.
|
|
75
|
+
looseEnums: angularPackage,
|
|
76
|
+
pureTopLevel: angularPackage,
|
|
77
|
+
// JavaScript modules that are marked as side effect free are considered to have
|
|
78
|
+
// no decorators that contain non-local effects.
|
|
79
|
+
wrapDecorators: !!((_b = (_a = this._module) === null || _a === void 0 ? void 0 : _a.factoryMeta) === null || _b === void 0 ? void 0 : _b.sideEffectFree),
|
|
80
|
+
};
|
|
81
|
+
shouldProcess = true;
|
|
82
|
+
}
|
|
68
83
|
// Add provided loader options to default base options
|
|
69
84
|
const loaderOptions = {
|
|
70
85
|
...baseOptions,
|
|
@@ -84,12 +99,35 @@ exports.default = babel_loader_1.custom(() => {
|
|
|
84
99
|
return { custom: customOptions, loader: loaderOptions };
|
|
85
100
|
},
|
|
86
101
|
config(configuration, { customOptions }) {
|
|
102
|
+
var _a;
|
|
103
|
+
const plugins = (_a = configuration.options.plugins) !== null && _a !== void 0 ? _a : [];
|
|
104
|
+
if (customOptions.optimize) {
|
|
105
|
+
if (customOptions.optimize.pureTopLevel) {
|
|
106
|
+
plugins.push(require('./plugins/pure-toplevel-functions').default);
|
|
107
|
+
}
|
|
108
|
+
plugins.push(require('./plugins/elide-angular-metadata').default, [
|
|
109
|
+
require('./plugins/adjust-typescript-enums').default,
|
|
110
|
+
{ loose: customOptions.optimize.looseEnums },
|
|
111
|
+
], [
|
|
112
|
+
require('./plugins/adjust-static-class-members').default,
|
|
113
|
+
{ wrapDecorators: customOptions.optimize.wrapDecorators },
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
// Only enable linker template sourcemapping if linker is enabled and Webpack provides
|
|
117
|
+
// a sourcemap. This logic allows the linker sourcemap behavior to be controlled by the
|
|
118
|
+
// Webpack sourcemap configuration. For example, if a vendor file is being processed
|
|
119
|
+
// and vendor sourcemaps are disabled, the `inputSourceMap` property will be `undefined`
|
|
120
|
+
// which will effectively disable linker sourcemapping for vendor files.
|
|
121
|
+
if (customOptions.angularLinker && configuration.options.inputSourceMap) {
|
|
122
|
+
customOptions.angularLinker.sourcemap = true;
|
|
123
|
+
}
|
|
87
124
|
return {
|
|
88
125
|
...configuration.options,
|
|
89
126
|
// Workaround for https://github.com/babel/babel-loader/pull/896 is available
|
|
90
127
|
// Delete once the above PR is released
|
|
91
128
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
129
|
inputSourceMap: configuration.options.inputSourceMap || false,
|
|
130
|
+
plugins,
|
|
93
131
|
presets: [
|
|
94
132
|
...(configuration.options.presets || []),
|
|
95
133
|
[
|
package/src/browser/index.d.ts
CHANGED
|
@@ -9,9 +9,8 @@ import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
|
9
9
|
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
|
|
10
10
|
import { json } from '@angular-devkit/core';
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
12
|
-
import
|
|
12
|
+
import webpack from 'webpack';
|
|
13
13
|
import { ExecutionTransformer } from '../transforms';
|
|
14
|
-
import { WebpackConfigOptions } from '../utils/build-options';
|
|
15
14
|
import { IndexHtmlTransform } from '../utils/index-file/index-html-generator';
|
|
16
15
|
import { Schema as BrowserBuilderSchema } from './schema';
|
|
17
16
|
/**
|
|
@@ -25,8 +24,6 @@ export declare type BrowserBuilderOutput = json.JsonObject & BuilderOutput & {
|
|
|
25
24
|
*/
|
|
26
25
|
outputPath: string;
|
|
27
26
|
};
|
|
28
|
-
export declare function getAnalyticsConfig(wco: WebpackConfigOptions, context: BuilderContext): webpack.Configuration;
|
|
29
|
-
export declare function getCompilerConfig(wco: WebpackConfigOptions): webpack.Configuration;
|
|
30
27
|
/**
|
|
31
28
|
* @experimental Direct usage of this function is considered experimental.
|
|
32
29
|
*/
|
package/src/browser/index.js
CHANGED
|
@@ -6,13 +6,32 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
9
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.buildWebpackBrowser =
|
|
29
|
+
exports.buildWebpackBrowser = void 0;
|
|
11
30
|
const architect_1 = require("@angular-devkit/architect");
|
|
12
31
|
const build_webpack_1 = require("@angular-devkit/build-webpack");
|
|
13
32
|
const core_1 = require("@angular-devkit/core");
|
|
14
|
-
const fs = require("fs");
|
|
15
|
-
const path = require("path");
|
|
33
|
+
const fs = __importStar(require("fs"));
|
|
34
|
+
const path = __importStar(require("path"));
|
|
16
35
|
const rxjs_1 = require("rxjs");
|
|
17
36
|
const operators_1 = require("rxjs/operators");
|
|
18
37
|
const typescript_1 = require("typescript");
|
|
@@ -33,49 +52,22 @@ const spinner_1 = require("../utils/spinner");
|
|
|
33
52
|
const version_1 = require("../utils/version");
|
|
34
53
|
const webpack_browser_config_1 = require("../utils/webpack-browser-config");
|
|
35
54
|
const configs_1 = require("../webpack/configs");
|
|
36
|
-
const analytics_1 = require("../webpack/plugins/analytics");
|
|
37
55
|
const async_chunks_1 = require("../webpack/utils/async-chunks");
|
|
38
56
|
const helpers_1 = require("../webpack/utils/helpers");
|
|
39
57
|
const stats_1 = require("../webpack/utils/stats");
|
|
40
58
|
const cacheDownlevelPath = environment_options_1.cachingDisabled ? undefined : cache_path_1.findCachePath('angular-build-dl');
|
|
41
|
-
function getAnalyticsConfig(wco, context) {
|
|
42
|
-
if (context.analytics) {
|
|
43
|
-
// If there's analytics, add our plugin. Otherwise no need to slow down the build.
|
|
44
|
-
let category = 'build';
|
|
45
|
-
if (context.builder) {
|
|
46
|
-
// We already vetted that this is a "safe" package, otherwise the analytics would be noop.
|
|
47
|
-
category =
|
|
48
|
-
context.builder.builderName.split(':')[1] || context.builder.builderName || 'build';
|
|
49
|
-
}
|
|
50
|
-
// The category is the builder name if it's an angular builder.
|
|
51
|
-
return {
|
|
52
|
-
plugins: [
|
|
53
|
-
new analytics_1.NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category, !!wco.tsConfig.options.enableIvy),
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
exports.getAnalyticsConfig = getAnalyticsConfig;
|
|
60
|
-
function getCompilerConfig(wco) {
|
|
61
|
-
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
|
|
62
|
-
return configs_1.getTypeScriptConfig(wco);
|
|
63
|
-
}
|
|
64
|
-
return {};
|
|
65
|
-
}
|
|
66
|
-
exports.getCompilerConfig = getCompilerConfig;
|
|
67
59
|
async function initialize(options, context, differentialLoadingNeeded, webpackConfigurationTransform) {
|
|
68
60
|
var _a, _b;
|
|
69
61
|
const originalOutputPath = options.outputPath;
|
|
70
62
|
// Assets are processed directly by the builder except when watching
|
|
71
63
|
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
|
72
|
-
const { config, projectRoot, projectSourceRoot, i18n
|
|
64
|
+
const { config, projectRoot, projectSourceRoot, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext(adjustedOptions, context, (wco) => [
|
|
73
65
|
configs_1.getCommonConfig(wco),
|
|
74
66
|
configs_1.getBrowserConfig(wco),
|
|
75
67
|
configs_1.getStylesConfig(wco),
|
|
76
68
|
configs_1.getStatsConfig(wco),
|
|
77
|
-
getAnalyticsConfig(wco, context),
|
|
78
|
-
|
|
69
|
+
configs_1.getAnalyticsConfig(wco, context),
|
|
70
|
+
configs_1.getTypeScriptConfig(wco),
|
|
79
71
|
wco.buildOptions.webWorkerTsConfig ? configs_1.getWorkerConfig(wco) : {},
|
|
80
72
|
], { differentialLoadingNeeded });
|
|
81
73
|
// Validate asset option values if processed directly
|
|
@@ -310,7 +302,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
310
302
|
runtimeData: processResults,
|
|
311
303
|
supportedBrowsers: buildBrowserFeatures.supportedBrowsers,
|
|
312
304
|
};
|
|
313
|
-
processResults.push(await Promise.resolve().then(() => require('../utils/process-bundle')).then((m) => m.process(runtimeOptions)));
|
|
305
|
+
processResults.push(await Promise.resolve().then(() => __importStar(require('../utils/process-bundle'))).then((m) => m.process(runtimeOptions)));
|
|
314
306
|
}
|
|
315
307
|
spinner.succeed('ES5 bundle generation complete.');
|
|
316
308
|
if (i18n.shouldInline) {
|
|
@@ -544,12 +536,10 @@ function assertNever(input) {
|
|
|
544
536
|
throw new Error(`Unexpected call to assertNever() with input: ${JSON.stringify(input, null /* replacer */, 4 /* tabSize */)}`);
|
|
545
537
|
}
|
|
546
538
|
function generateBundleInfoStats(bundle, chunk, chunkType) {
|
|
547
|
-
var _a;
|
|
548
539
|
return stats_1.generateBundleStats({
|
|
549
540
|
size: bundle.size,
|
|
550
541
|
files: bundle.map ? [bundle.filename, bundle.map.filename] : [bundle.filename],
|
|
551
542
|
names: chunk === null || chunk === void 0 ? void 0 : chunk.names,
|
|
552
|
-
entry: !!((_a = chunk === null || chunk === void 0 ? void 0 : chunk.names) === null || _a === void 0 ? void 0 : _a.includes('runtime')),
|
|
553
543
|
initial: !!(chunk === null || chunk === void 0 ? void 0 : chunk.initial),
|
|
554
544
|
rendered: true,
|
|
555
545
|
chunkType,
|
package/src/browser/schema.d.ts
CHANGED
|
@@ -407,7 +407,7 @@ export interface SourceMapClass {
|
|
|
407
407
|
*/
|
|
408
408
|
export interface StylePreprocessorOptions {
|
|
409
409
|
/**
|
|
410
|
-
* Paths to include. Paths will be resolved to
|
|
410
|
+
* Paths to include. Paths will be resolved to workspace root.
|
|
411
411
|
*/
|
|
412
412
|
includePaths?: string[];
|
|
413
413
|
}
|
package/src/browser/schema.json
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"type": "object",
|
|
52
52
|
"properties": {
|
|
53
53
|
"includePaths": {
|
|
54
|
-
"description": "Paths to include. Paths will be resolved to
|
|
54
|
+
"description": "Paths to include. Paths will be resolved to workspace root.",
|
|
55
55
|
"type": "array",
|
|
56
56
|
"items": {
|
|
57
57
|
"type": "string"
|
|
@@ -9,7 +9,7 @@ import { BuilderContext } from '@angular-devkit/architect';
|
|
|
9
9
|
import { DevServerBuildOutput, WebpackLoggingCallback } from '@angular-devkit/build-webpack';
|
|
10
10
|
import { json } from '@angular-devkit/core';
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
12
|
-
import
|
|
12
|
+
import webpack from 'webpack';
|
|
13
13
|
import { ExecutionTransformer } from '../transforms';
|
|
14
14
|
import { IndexHtmlTransform } from '../utils/index-file/index-html-generator';
|
|
15
15
|
import { Schema } from './schema';
|
package/src/dev-server/index.js
CHANGED
|
@@ -6,18 +6,39 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
9
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
32
|
exports.serveWebpackBrowser = void 0;
|
|
11
33
|
const architect_1 = require("@angular-devkit/architect");
|
|
12
34
|
const build_webpack_1 = require("@angular-devkit/build-webpack");
|
|
13
35
|
const core_1 = require("@angular-devkit/core");
|
|
14
|
-
const path = require("path");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
15
37
|
const rxjs_1 = require("rxjs");
|
|
16
38
|
const operators_1 = require("rxjs/operators");
|
|
17
|
-
const ts = require("typescript");
|
|
18
|
-
const url = require("url");
|
|
19
|
-
const
|
|
20
|
-
const browser_1 = require("../browser");
|
|
39
|
+
const ts = __importStar(require("typescript"));
|
|
40
|
+
const url = __importStar(require("url"));
|
|
41
|
+
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
21
42
|
const schema_1 = require("../browser/schema");
|
|
22
43
|
const utils_1 = require("../utils");
|
|
23
44
|
const cache_path_1 = require("../utils/cache-path");
|
|
@@ -84,19 +105,55 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
84
105
|
overrides.outputHashing = schema_1.OutputHashing.None;
|
|
85
106
|
logger.warn(`Warning: 'outputHashing' option is disabled when using the dev-server.`);
|
|
86
107
|
}
|
|
108
|
+
if (options.hmr) {
|
|
109
|
+
logger.warn(core_1.tags.stripIndents `NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
|
|
110
|
+
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
|
|
111
|
+
}
|
|
112
|
+
if (!options.disableHostCheck &&
|
|
113
|
+
options.host &&
|
|
114
|
+
!/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
|
|
115
|
+
options.host !== 'localhost') {
|
|
116
|
+
logger.warn(core_1.tags.stripIndent `
|
|
117
|
+
Warning: This is a simple server for use in testing or debugging Angular applications
|
|
118
|
+
locally. It hasn't been reviewed for security issues.
|
|
119
|
+
|
|
120
|
+
Binding this server to an open connection can result in compromising your application or
|
|
121
|
+
computer. Using a different host than the one passed to the "--host" flag might result in
|
|
122
|
+
websocket connection issues. You might need to use "--disableHostCheck" if that's the
|
|
123
|
+
case.
|
|
124
|
+
`);
|
|
125
|
+
}
|
|
126
|
+
if (options.disableHostCheck) {
|
|
127
|
+
logger.warn(core_1.tags.oneLine `
|
|
128
|
+
Warning: Running a server with --disable-host-check is a security risk.
|
|
129
|
+
See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
|
130
|
+
for more information.
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
87
133
|
// Webpack's live reload functionality adds the `strip-ansi` package which is commonJS
|
|
88
134
|
(_b = rawBrowserOptions.allowedCommonJsDependencies) !== null && _b !== void 0 ? _b : (rawBrowserOptions.allowedCommonJsDependencies = []);
|
|
89
135
|
rawBrowserOptions.allowedCommonJsDependencies.push('strip-ansi');
|
|
90
136
|
const browserName = await context.getBuilderNameForTarget(browserTarget);
|
|
91
137
|
const browserOptions = (await context.validateOptions({ ...rawBrowserOptions, ...overrides }, browserName));
|
|
138
|
+
const { styles, scripts } = utils_1.normalizeOptimization(browserOptions.optimization);
|
|
139
|
+
if (scripts || styles.minify) {
|
|
140
|
+
logger.error(core_1.tags.stripIndents `
|
|
141
|
+
****************************************************************************************
|
|
142
|
+
This is a simple server for use in testing or debugging Angular applications locally.
|
|
143
|
+
It hasn't been reviewed for security issues.
|
|
144
|
+
|
|
145
|
+
DON'T USE IT FOR PRODUCTION!
|
|
146
|
+
****************************************************************************************
|
|
147
|
+
`);
|
|
148
|
+
}
|
|
92
149
|
const { config, projectRoot, i18n } = await webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext(browserOptions, context, (wco) => [
|
|
93
150
|
configs_1.getDevServerConfig(wco),
|
|
94
151
|
configs_1.getCommonConfig(wco),
|
|
95
152
|
configs_1.getBrowserConfig(wco),
|
|
96
153
|
configs_1.getStylesConfig(wco),
|
|
97
154
|
configs_1.getStatsConfig(wco),
|
|
98
|
-
|
|
99
|
-
|
|
155
|
+
configs_1.getAnalyticsConfig(wco, context),
|
|
156
|
+
configs_1.getTypeScriptConfig(wco),
|
|
100
157
|
browserOptions.webWorkerTsConfig ? configs_1.getWorkerConfig(wco) : {},
|
|
101
158
|
], devServerOptions);
|
|
102
159
|
if (!config.devServer) {
|
|
@@ -106,7 +163,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
106
163
|
// This is needed because we cannot use the inline option directly in the config
|
|
107
164
|
// because of the SuppressExtractedTextChunksWebpackPlugin
|
|
108
165
|
// Consider not using SuppressExtractedTextChunksWebpackPlugin when liveReload is enable.
|
|
109
|
-
|
|
166
|
+
webpack_dev_server_1.default.addDevServerEntrypoints(config, {
|
|
110
167
|
...config.devServer,
|
|
111
168
|
inline: true,
|
|
112
169
|
});
|
|
@@ -129,31 +186,6 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
129
186
|
}
|
|
130
187
|
}
|
|
131
188
|
}
|
|
132
|
-
if (options.hmr) {
|
|
133
|
-
logger.warn(core_1.tags.stripIndents `NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
|
|
134
|
-
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
|
|
135
|
-
}
|
|
136
|
-
if (!options.disableHostCheck &&
|
|
137
|
-
options.host &&
|
|
138
|
-
!/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
|
|
139
|
-
options.host !== 'localhost') {
|
|
140
|
-
logger.warn(core_1.tags.stripIndent `
|
|
141
|
-
Warning: This is a simple server for use in testing or debugging Angular applications
|
|
142
|
-
locally. It hasn't been reviewed for security issues.
|
|
143
|
-
|
|
144
|
-
Binding this server to an open connection can result in compromising your application or
|
|
145
|
-
computer. Using a different host than the one passed to the "--host" flag might result in
|
|
146
|
-
websocket connection issues. You might need to use "--disableHostCheck" if that's the
|
|
147
|
-
case.
|
|
148
|
-
`);
|
|
149
|
-
}
|
|
150
|
-
if (options.disableHostCheck) {
|
|
151
|
-
logger.warn(core_1.tags.oneLine `
|
|
152
|
-
Warning: Running a server with --disable-host-check is a security risk.
|
|
153
|
-
See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
|
154
|
-
for more information.
|
|
155
|
-
`);
|
|
156
|
-
}
|
|
157
189
|
let locale;
|
|
158
190
|
if (i18n.shouldInline) {
|
|
159
191
|
// Dev-server only supports one locale
|
|
@@ -186,7 +218,6 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
186
218
|
};
|
|
187
219
|
}
|
|
188
220
|
return rxjs_1.from(setup()).pipe(operators_1.switchMap(({ browserOptions, webpackConfig, projectRoot, locale }) => {
|
|
189
|
-
const normalizedOptimization = utils_1.normalizeOptimization(browserOptions.optimization);
|
|
190
221
|
if (browserOptions.index) {
|
|
191
222
|
const { scripts = [], styles = [], baseHref, tsConfig } = browserOptions;
|
|
192
223
|
const { options: compilerOptions } = read_tsconfig_1.readTsconfig(tsConfig, workspaceRoot);
|
|
@@ -207,24 +238,14 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
207
238
|
deployUrl: browserOptions.deployUrl,
|
|
208
239
|
sri: browserOptions.subresourceIntegrity,
|
|
209
240
|
postTransform: transforms.indexHtml,
|
|
210
|
-
optimization:
|
|
241
|
+
optimization: utils_1.normalizeOptimization(browserOptions.optimization),
|
|
211
242
|
WOFFSupportNeeded: !buildBrowserFeatures.isFeatureSupported('woff2'),
|
|
212
243
|
crossOrigin: browserOptions.crossOrigin,
|
|
213
244
|
lang: locale,
|
|
214
245
|
}));
|
|
215
246
|
}
|
|
216
|
-
if (normalizedOptimization.scripts || normalizedOptimization.styles.minify) {
|
|
217
|
-
logger.error(core_1.tags.stripIndents `
|
|
218
|
-
****************************************************************************************
|
|
219
|
-
This is a simple server for use in testing or debugging Angular applications locally.
|
|
220
|
-
It hasn't been reviewed for security issues.
|
|
221
|
-
|
|
222
|
-
DON'T USE IT FOR PRODUCTION!
|
|
223
|
-
****************************************************************************************
|
|
224
|
-
`);
|
|
225
|
-
}
|
|
226
247
|
return build_webpack_1.runWebpackDevServer(webpackConfig, context, {
|
|
227
|
-
logging: transforms.logging || stats_1.createWebpackLoggingCallback(
|
|
248
|
+
logging: transforms.logging || stats_1.createWebpackLoggingCallback(browserOptions, logger),
|
|
228
249
|
webpackFactory: require('webpack'),
|
|
229
250
|
webpackDevServerFactory: require('webpack-dev-server'),
|
|
230
251
|
}).pipe(operators_1.concatMap(async (buildEvent, index) => {
|
|
@@ -246,7 +267,7 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
246
267
|
` +
|
|
247
268
|
'\n');
|
|
248
269
|
if (options.open) {
|
|
249
|
-
const open = await Promise.resolve().then(() => require('open'));
|
|
270
|
+
const open = (await Promise.resolve().then(() => __importStar(require('open')))).default;
|
|
250
271
|
await open(serverAddress);
|
|
251
272
|
}
|
|
252
273
|
}
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
9
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
13
|
exports.executeOnceAndFetch = void 0;
|
|
11
|
-
const node_fetch_1 = require("node-fetch"); // eslint-disable-line import/no-extraneous-dependencies
|
|
14
|
+
const node_fetch_1 = __importDefault(require("node-fetch")); // eslint-disable-line import/no-extraneous-dependencies
|
|
12
15
|
const operators_1 = require("rxjs/operators");
|
|
13
16
|
const url_1 = require("url");
|
|
14
17
|
async function executeOnceAndFetch(harness, url, options) {
|