@angular-devkit/build-angular 13.0.0-rc.1 → 13.1.0-next.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 +30 -30
- package/src/babel/presets/application.d.ts +8 -0
- package/src/babel/presets/application.js +18 -0
- package/src/babel/webpack-loader.d.ts +9 -0
- package/src/babel/webpack-loader.js +15 -24
- package/src/builders/browser/index.js +0 -4
- package/src/builders/browser/schema.json +1 -1
- package/src/builders/dev-server/index.js +0 -4
- package/src/builders/extract-i18n/index.js +11 -14
- package/src/builders/karma/index.d.ts +2 -2
- package/src/builders/karma/index.js +1 -7
- package/src/builders/server/index.js +1 -7
- package/src/sass/sass-service.js +2 -2
- package/src/sass/worker.js +0 -1
- package/src/utils/action-executor.js +4 -5
- package/src/utils/build-options.d.ts +0 -2
- package/src/utils/i18n-inlining.js +18 -2
- package/src/utils/normalize-optimization.js +2 -4
- package/src/webpack/configs/common.js +133 -156
- package/src/webpack/configs/dev-server.d.ts +2 -2
- package/src/webpack/configs/index.d.ts +0 -6
- package/src/webpack/configs/index.js +0 -6
- package/src/webpack/configs/styles.d.ts +2 -2
- package/src/webpack/plugins/index.d.ts +2 -0
- package/src/webpack/plugins/index.js +5 -1
- package/src/webpack/plugins/json-stats-plugin.d.ts +13 -0
- package/src/webpack/plugins/json-stats-plugin.js +54 -0
- package/src/webpack/{configs/worker.d.ts → plugins/progress-plugin.d.ts} +4 -3
- package/src/webpack/plugins/progress-plugin.js +38 -0
- package/src/webpack/{configs/browser.d.ts → plugins/typescript.d.ts} +2 -2
- package/src/webpack/{configs → plugins}/typescript.js +5 -24
- package/src/webpack/utils/helpers.d.ts +16 -5
- package/src/webpack/utils/helpers.js +174 -34
- package/src/webpack/utils/stats.js +1 -2
- package/src/webpack/configs/browser.js +0 -81
- package/src/webpack/configs/server.d.ts +0 -14
- package/src/webpack/configs/server.js +0 -72
- package/src/webpack/configs/stats.d.ts +0 -38
- package/src/webpack/configs/stats.js +0 -53
- package/src/webpack/configs/test.d.ts +0 -10
- package/src/webpack/configs/test.js +0 -98
- package/src/webpack/configs/typescript.d.ts +0 -12
- package/src/webpack/configs/worker.js +0 -22
package/package.json
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.0-next.0",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "1.0.1",
|
|
10
|
-
"@angular-devkit/architect": "0.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.
|
|
12
|
-
"@angular-devkit/core": "13.
|
|
13
|
-
"@babel/core": "7.
|
|
14
|
-
"@babel/generator": "7.
|
|
15
|
-
"@babel/helper-annotate-as-pure": "7.
|
|
16
|
-
"@babel/plugin-proposal-async-generator-functions": "7.
|
|
17
|
-
"@babel/plugin-transform-async-to-generator": "7.
|
|
18
|
-
"@babel/plugin-transform-runtime": "7.
|
|
19
|
-
"@babel/preset-env": "7.
|
|
20
|
-
"@babel/runtime": "7.
|
|
21
|
-
"@babel/template": "7.
|
|
10
|
+
"@angular-devkit/architect": "0.1301.0-next.0",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1301.0-next.0",
|
|
12
|
+
"@angular-devkit/core": "13.1.0-next.0",
|
|
13
|
+
"@babel/core": "7.16.0",
|
|
14
|
+
"@babel/generator": "7.16.0",
|
|
15
|
+
"@babel/helper-annotate-as-pure": "7.16.0",
|
|
16
|
+
"@babel/plugin-proposal-async-generator-functions": "7.16.0",
|
|
17
|
+
"@babel/plugin-transform-async-to-generator": "7.16.0",
|
|
18
|
+
"@babel/plugin-transform-runtime": "7.16.0",
|
|
19
|
+
"@babel/preset-env": "7.16.0",
|
|
20
|
+
"@babel/runtime": "7.16.0",
|
|
21
|
+
"@babel/template": "7.16.0",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.5",
|
|
23
|
-
"@
|
|
24
|
-
"@ngtools/webpack": "13.0.0-rc.1",
|
|
23
|
+
"@ngtools/webpack": "13.1.0-next.0",
|
|
25
24
|
"ansi-colors": "4.1.1",
|
|
26
|
-
"babel-loader": "8.2.
|
|
25
|
+
"babel-loader": "8.2.3",
|
|
26
|
+
"babel-plugin-istanbul": "6.1.1",
|
|
27
27
|
"browserslist": "^4.9.1",
|
|
28
28
|
"cacache": "15.3.0",
|
|
29
29
|
"caniuse-lite": "^1.0.30001032",
|
|
30
30
|
"circular-dependency-plugin": "5.2.2",
|
|
31
31
|
"copy-webpack-plugin": "9.0.1",
|
|
32
|
-
"core-js": "3.
|
|
33
|
-
"critters": "0.0.
|
|
34
|
-
"css-loader": "6.
|
|
35
|
-
"esbuild-wasm": "0.13.
|
|
32
|
+
"core-js": "3.19.1",
|
|
33
|
+
"critters": "0.0.14",
|
|
34
|
+
"css-loader": "6.5.0",
|
|
35
|
+
"esbuild-wasm": "0.13.12",
|
|
36
36
|
"glob": "7.2.0",
|
|
37
37
|
"https-proxy-agent": "5.0.0",
|
|
38
38
|
"inquirer": "8.2.0",
|
|
39
39
|
"karma-source-map-support": "1.4.0",
|
|
40
40
|
"less": "4.1.2",
|
|
41
|
-
"less-loader": "10.
|
|
41
|
+
"less-loader": "10.2.0",
|
|
42
42
|
"license-webpack-plugin": "3.0.0",
|
|
43
|
-
"loader-utils": "
|
|
44
|
-
"mini-css-extract-plugin": "2.4.
|
|
43
|
+
"loader-utils": "3.1.0",
|
|
44
|
+
"mini-css-extract-plugin": "2.4.3",
|
|
45
45
|
"minimatch": "3.0.4",
|
|
46
|
-
"open": "8.
|
|
46
|
+
"open": "8.4.0",
|
|
47
47
|
"ora": "5.4.1",
|
|
48
48
|
"parse5-html-rewriting-stream": "6.0.1",
|
|
49
49
|
"piscina": "3.1.0",
|
|
50
|
-
"postcss": "8.3.
|
|
50
|
+
"postcss": "8.3.11",
|
|
51
51
|
"postcss-import": "14.0.2",
|
|
52
52
|
"postcss-loader": "6.2.0",
|
|
53
53
|
"postcss-preset-env": "6.7.0",
|
|
54
54
|
"regenerator-runtime": "0.13.9",
|
|
55
55
|
"resolve-url-loader": "4.0.0",
|
|
56
56
|
"rxjs": "6.6.7",
|
|
57
|
-
"sass": "1.43.
|
|
58
|
-
"sass-loader": "12.
|
|
57
|
+
"sass": "1.43.4",
|
|
58
|
+
"sass-loader": "12.3.0",
|
|
59
59
|
"semver": "7.3.5",
|
|
60
60
|
"source-map-loader": "3.0.0",
|
|
61
61
|
"source-map-support": "0.5.20",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
"text-table": "0.2.0",
|
|
66
66
|
"tree-kill": "1.2.2",
|
|
67
67
|
"tslib": "2.3.1",
|
|
68
|
-
"webpack": "5.
|
|
68
|
+
"webpack": "5.61.0",
|
|
69
69
|
"webpack-dev-middleware": "5.2.1",
|
|
70
|
-
"webpack-dev-server": "4.
|
|
70
|
+
"webpack-dev-server": "4.4.0",
|
|
71
71
|
"webpack-merge": "5.8.0",
|
|
72
72
|
"webpack-subresource-integrity": "5.0.0"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"esbuild": "0.13.
|
|
75
|
+
"esbuild": "0.13.12"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@angular/compiler-cli": "^13.0.0 || ^13.0.0-next",
|
|
@@ -32,6 +32,14 @@ export interface ApplicationPresetOptions {
|
|
|
32
32
|
};
|
|
33
33
|
forceES5?: boolean;
|
|
34
34
|
forceAsyncTransformation?: boolean;
|
|
35
|
+
instrumentCode?: {
|
|
36
|
+
includedBasePath: string;
|
|
37
|
+
};
|
|
38
|
+
optimize?: {
|
|
39
|
+
looseEnums: boolean;
|
|
40
|
+
pureTopLevel: boolean;
|
|
41
|
+
wrapDecorators: boolean;
|
|
42
|
+
};
|
|
35
43
|
diagnosticReporter?: DiagnosticReporter;
|
|
36
44
|
}
|
|
37
45
|
export default function (api: unknown, options: ApplicationPresetOptions): {
|
|
@@ -145,6 +145,24 @@ function default_1(api, options) {
|
|
|
145
145
|
plugins.push(require('@babel/plugin-transform-async-to-generator').default, require('@babel/plugin-proposal-async-generator-functions').default);
|
|
146
146
|
needRuntimeTransform = true;
|
|
147
147
|
}
|
|
148
|
+
if (options.optimize) {
|
|
149
|
+
if (options.optimize.pureTopLevel) {
|
|
150
|
+
plugins.push(require('../plugins/pure-toplevel-functions').default);
|
|
151
|
+
}
|
|
152
|
+
plugins.push(require('../plugins/elide-angular-metadata').default, [
|
|
153
|
+
require('../plugins/adjust-typescript-enums').default,
|
|
154
|
+
{ loose: options.optimize.looseEnums },
|
|
155
|
+
], [
|
|
156
|
+
require('../plugins/adjust-static-class-members').default,
|
|
157
|
+
{ wrapDecorators: options.optimize.wrapDecorators },
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
if (options.instrumentCode) {
|
|
161
|
+
plugins.push([
|
|
162
|
+
require('babel-plugin-istanbul').default,
|
|
163
|
+
{ inputSourceMap: false, cwd: options.instrumentCode.includedBasePath },
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
148
166
|
if (needRuntimeTransform) {
|
|
149
167
|
// Babel equivalent to TypeScript's `importHelpers` option
|
|
150
168
|
plugins.push([
|
|
@@ -5,5 +5,14 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import { ApplicationPresetOptions } from './presets/application';
|
|
9
|
+
interface AngularCustomOptions extends Omit<ApplicationPresetOptions, 'instrumentCode'> {
|
|
10
|
+
instrumentCode?: {
|
|
11
|
+
/** node_modules and test files are always excluded. */
|
|
12
|
+
excludedPaths: Set<String>;
|
|
13
|
+
includedBasePath: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare type AngularBabelLoaderOptions = AngularCustomOptions & Record<string, unknown>;
|
|
8
17
|
declare const _default: any;
|
|
9
18
|
export default _default;
|
|
@@ -51,8 +51,9 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
51
51
|
inputSourceMap: false,
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
54
|
-
async customOptions(
|
|
54
|
+
async customOptions(options, { source }) {
|
|
55
55
|
var _a, _b;
|
|
56
|
+
const { i18n, scriptTarget, aot, optimize, instrumentCode, ...rawOptions } = options;
|
|
56
57
|
// Must process file if plugins are added
|
|
57
58
|
let shouldProcess = Array.isArray(rawOptions.plugins) && rawOptions.plugins.length > 0;
|
|
58
59
|
const customOptions = {
|
|
@@ -60,6 +61,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
60
61
|
forceES5: false,
|
|
61
62
|
angularLinker: undefined,
|
|
62
63
|
i18n: undefined,
|
|
64
|
+
instrumentCode: undefined,
|
|
63
65
|
};
|
|
64
66
|
// Analyze file for linking
|
|
65
67
|
if (await requiresLinking(this.resourcePath, source)) {
|
|
@@ -91,7 +93,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
91
93
|
customOptions.forceAsyncTransformation =
|
|
92
94
|
!/[\\/][_f]?esm2015[\\/]/.test(this.resourcePath) && source.includes('async');
|
|
93
95
|
}
|
|
94
|
-
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation || customOptions.forceES5);
|
|
96
|
+
shouldProcess || (shouldProcess = customOptions.forceAsyncTransformation || customOptions.forceES5 || false);
|
|
95
97
|
}
|
|
96
98
|
// Analyze for i18n inlining
|
|
97
99
|
if (i18n &&
|
|
@@ -131,6 +133,16 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
131
133
|
};
|
|
132
134
|
shouldProcess = true;
|
|
133
135
|
}
|
|
136
|
+
if (instrumentCode &&
|
|
137
|
+
!instrumentCode.excludedPaths.has(this.resourcePath) &&
|
|
138
|
+
!/\.(e2e|spec)\.tsx?$|[\\/]node_modules[\\/]/.test(this.resourcePath) &&
|
|
139
|
+
this.resourcePath.startsWith(instrumentCode.includedBasePath)) {
|
|
140
|
+
// `babel-plugin-istanbul` has it's own includes but we do the below so that we avoid running the the loader.
|
|
141
|
+
customOptions.instrumentCode = {
|
|
142
|
+
includedBasePath: instrumentCode.includedBasePath,
|
|
143
|
+
};
|
|
144
|
+
shouldProcess = true;
|
|
145
|
+
}
|
|
134
146
|
// Add provided loader options to default base options
|
|
135
147
|
const loaderOptions = {
|
|
136
148
|
...baseOptions,
|
|
@@ -150,27 +162,12 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
150
162
|
return { custom: customOptions, loader: loaderOptions };
|
|
151
163
|
},
|
|
152
164
|
config(configuration, { customOptions }) {
|
|
153
|
-
var _a;
|
|
154
|
-
const plugins = (_a = configuration.options.plugins) !== null && _a !== void 0 ? _a : [];
|
|
155
|
-
if (customOptions.optimize) {
|
|
156
|
-
if (customOptions.optimize.pureTopLevel) {
|
|
157
|
-
plugins.push(require('./plugins/pure-toplevel-functions').default);
|
|
158
|
-
}
|
|
159
|
-
plugins.push(require('./plugins/elide-angular-metadata').default, [
|
|
160
|
-
require('./plugins/adjust-typescript-enums').default,
|
|
161
|
-
{ loose: customOptions.optimize.looseEnums },
|
|
162
|
-
], [
|
|
163
|
-
require('./plugins/adjust-static-class-members').default,
|
|
164
|
-
{ wrapDecorators: customOptions.optimize.wrapDecorators },
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
167
165
|
return {
|
|
168
166
|
...configuration.options,
|
|
169
167
|
// Using `false` disables babel from attempting to locate sourcemaps or process any inline maps.
|
|
170
168
|
// The babel types do not include the false option even though it is valid
|
|
171
169
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
170
|
inputSourceMap: false,
|
|
173
|
-
plugins,
|
|
174
171
|
presets: [
|
|
175
172
|
...(configuration.options.presets || []),
|
|
176
173
|
[
|
|
@@ -201,13 +198,7 @@ exports.default = (0, babel_loader_1.custom)(() => {
|
|
|
201
198
|
// `@ampproject/remapping` source map objects but both are compatible with Webpack.
|
|
202
199
|
// This method for merging is used because it provides more accurate output
|
|
203
200
|
// and is faster while using less memory.
|
|
204
|
-
result.map =
|
|
205
|
-
// Convert the SourceMap back to simple plain object.
|
|
206
|
-
// This is needed because otherwise code-coverage will fail with `don't know how to turn this value into a node`
|
|
207
|
-
// Which is throw by Babel when it is invoked again from `istanbul-lib-instrument`.
|
|
208
|
-
// https://github.com/babel/babel/blob/780aa48d2a34dc55f556843074b6aed45e7eabeb/packages/babel-types/src/converters/valueToNode.ts#L115-L130
|
|
209
|
-
...(0, remapping_1.default)([result.map, inputSourceMap], () => null),
|
|
210
|
-
};
|
|
201
|
+
result.map = (0, remapping_1.default)([result.map, inputSourceMap], () => null);
|
|
211
202
|
}
|
|
212
203
|
return result;
|
|
213
204
|
},
|
|
@@ -59,12 +59,8 @@ async function initialize(options, context, webpackConfigurationTransform) {
|
|
|
59
59
|
const adjustedOptions = options.watch ? options : { ...options, assets: [] };
|
|
60
60
|
const { config, projectRoot, projectSourceRoot, i18n, target } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)(adjustedOptions, context, (wco) => [
|
|
61
61
|
(0, configs_1.getCommonConfig)(wco),
|
|
62
|
-
(0, configs_1.getBrowserConfig)(wco),
|
|
63
62
|
(0, configs_1.getStylesConfig)(wco),
|
|
64
|
-
(0, configs_1.getStatsConfig)(wco),
|
|
65
63
|
(0, configs_1.getAnalyticsConfig)(wco, context),
|
|
66
|
-
(0, configs_1.getTypeScriptConfig)(wco),
|
|
67
|
-
wco.buildOptions.webWorkerTsConfig ? (0, configs_1.getWorkerConfig)(wco) : {},
|
|
68
64
|
]);
|
|
69
65
|
// Validate asset option values if processed directly
|
|
70
66
|
if (((_a = options.assets) === null || _a === void 0 ? void 0 : _a.length) && !((_b = adjustedOptions.assets) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
@@ -124,12 +124,8 @@ function serveWebpackBrowser(options, context, transforms = {}) {
|
|
|
124
124
|
const { config, projectRoot, i18n } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)(browserOptions, context, (wco) => [
|
|
125
125
|
(0, configs_1.getDevServerConfig)(wco),
|
|
126
126
|
(0, configs_1.getCommonConfig)(wco),
|
|
127
|
-
(0, configs_1.getBrowserConfig)(wco),
|
|
128
127
|
(0, configs_1.getStylesConfig)(wco),
|
|
129
|
-
(0, configs_1.getStatsConfig)(wco),
|
|
130
128
|
(0, configs_1.getAnalyticsConfig)(wco, context),
|
|
131
|
-
(0, configs_1.getTypeScriptConfig)(wco),
|
|
132
|
-
browserOptions.webWorkerTsConfig ? (0, configs_1.getWorkerConfig)(wco) : {},
|
|
133
129
|
], options);
|
|
134
130
|
if (!config.devServer) {
|
|
135
131
|
throw new Error('Webpack Dev Server configuration was not set.');
|
|
@@ -132,6 +132,16 @@ async function execute(options, context, transforms) {
|
|
|
132
132
|
if (!context.target || !context.target.project) {
|
|
133
133
|
throw new Error('The builder requires a target.');
|
|
134
134
|
}
|
|
135
|
+
try {
|
|
136
|
+
require.resolve('@angular/localize');
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return {
|
|
140
|
+
success: false,
|
|
141
|
+
error: `i18n extraction requires the '@angular/localize' package.`,
|
|
142
|
+
outputPath: outFile,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
135
145
|
const metadata = await context.getProjectMetadata(context.target);
|
|
136
146
|
const i18n = (0, i18n_options_1.createI18nOptions)(metadata);
|
|
137
147
|
let useLegacyIds = true;
|
|
@@ -156,6 +166,7 @@ async function execute(options, context, transforms) {
|
|
|
156
166
|
subresourceIntegrity: false,
|
|
157
167
|
outputHashing: schema_1.OutputHashing.None,
|
|
158
168
|
namedChunks: true,
|
|
169
|
+
allowedCommonJsDependencies: undefined,
|
|
159
170
|
};
|
|
160
171
|
const { config, projectRoot } = await (0, webpack_browser_config_1.generateBrowserWebpackConfigFromContext)(builderOptions, context, (wco) => {
|
|
161
172
|
var _a;
|
|
@@ -164,10 +175,6 @@ async function execute(options, context, transforms) {
|
|
|
164
175
|
const partials = [
|
|
165
176
|
{ plugins: [new NoEmitPlugin()] },
|
|
166
177
|
(0, configs_1.getCommonConfig)(wco),
|
|
167
|
-
(0, configs_1.getBrowserConfig)(wco),
|
|
168
|
-
(0, configs_1.getTypeScriptConfig)(wco),
|
|
169
|
-
(0, configs_1.getWorkerConfig)(wco),
|
|
170
|
-
(0, configs_1.getStatsConfig)(wco),
|
|
171
178
|
];
|
|
172
179
|
// Add Ivy application file extractor support
|
|
173
180
|
partials.unshift({
|
|
@@ -196,16 +203,6 @@ async function execute(options, context, transforms) {
|
|
|
196
203
|
});
|
|
197
204
|
return partials;
|
|
198
205
|
});
|
|
199
|
-
try {
|
|
200
|
-
require.resolve('@angular/localize');
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
return {
|
|
204
|
-
success: false,
|
|
205
|
-
error: `Ivy extraction requires the '@angular/localize' package.`,
|
|
206
|
-
outputPath: outFile,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
206
|
// All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
|
|
210
207
|
// This provides interim compatibility while the framework is transitioned to bundled ESM packages.
|
|
211
208
|
const localizeToolsModule = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
9
9
|
import { ConfigOptions } from 'karma';
|
|
10
10
|
import { Observable } from 'rxjs';
|
|
11
|
-
import
|
|
11
|
+
import { Configuration } from 'webpack';
|
|
12
12
|
import { ExecutionTransformer } from '../../transforms';
|
|
13
13
|
import { Schema as KarmaBuilderOptions } from './schema';
|
|
14
14
|
export declare type KarmaConfigOptions = ConfigOptions & {
|
|
@@ -19,7 +19,7 @@ export declare type KarmaConfigOptions = ConfigOptions & {
|
|
|
19
19
|
* @experimental Direct usage of this function is considered experimental.
|
|
20
20
|
*/
|
|
21
21
|
export declare function execute(options: KarmaBuilderOptions, context: BuilderContext, transforms?: {
|
|
22
|
-
webpackConfiguration?: ExecutionTransformer<
|
|
22
|
+
webpackConfiguration?: ExecutionTransformer<Configuration>;
|
|
23
23
|
karmaOptions?: (options: KarmaConfigOptions) => KarmaConfigOptions;
|
|
24
24
|
}): Observable<BuilderOutput>;
|
|
25
25
|
export { KarmaBuilderOptions };
|
|
@@ -59,13 +59,7 @@ async function initialize(options, context, webpackConfigurationTransformer) {
|
|
|
59
59
|
// https://github.com/webpack/webpack-dev-middleware/blob/698c9ae5e9bb9a013985add6189ff21c1a1ec185/src/index.js#L65
|
|
60
60
|
// https://github.com/webpack/webpack/blob/cde1b73e12eb8a77eb9ba42e7920c9ec5d29c2c9/lib/Compiler.js#L379-L388
|
|
61
61
|
watch: true,
|
|
62
|
-
}, context, (wco) => [
|
|
63
|
-
(0, configs_1.getCommonConfig)(wco),
|
|
64
|
-
(0, configs_1.getStylesConfig)(wco),
|
|
65
|
-
(0, configs_1.getTypeScriptConfig)(wco),
|
|
66
|
-
(0, configs_1.getTestConfig)(wco),
|
|
67
|
-
(0, configs_1.getWorkerConfig)(wco),
|
|
68
|
-
]);
|
|
62
|
+
}, context, (wco) => [(0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)]);
|
|
69
63
|
const karma = await Promise.resolve().then(() => __importStar(require('karma')));
|
|
70
64
|
return [
|
|
71
65
|
karma,
|
|
@@ -109,13 +109,7 @@ async function initialize(options, context, webpackConfigurationTransform) {
|
|
|
109
109
|
buildOptimizer: false,
|
|
110
110
|
aot: true,
|
|
111
111
|
platform: 'server',
|
|
112
|
-
}, context, (wco) => [
|
|
113
|
-
(0, configs_1.getCommonConfig)(wco),
|
|
114
|
-
(0, configs_1.getServerConfig)(wco),
|
|
115
|
-
(0, configs_1.getStylesConfig)(wco),
|
|
116
|
-
(0, configs_1.getStatsConfig)(wco),
|
|
117
|
-
(0, configs_1.getTypeScriptConfig)(wco),
|
|
118
|
-
]);
|
|
112
|
+
}, context, (wco) => [(0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)]);
|
|
119
113
|
let transformedConfig;
|
|
120
114
|
if (webpackConfigurationTransform) {
|
|
121
115
|
transformedConfig = await webpackConfigurationTransform(config);
|
package/src/sass/sass-service.js
CHANGED
|
@@ -48,9 +48,9 @@ class SassWorkerImplementation {
|
|
|
48
48
|
* @param callback The function to execute when the rendering is complete.
|
|
49
49
|
*/
|
|
50
50
|
render(options, callback) {
|
|
51
|
-
// The `functions` and `importer` options are JavaScript functions that cannot be transferred.
|
|
51
|
+
// The `functions`, `logger` and `importer` options are JavaScript functions that cannot be transferred.
|
|
52
52
|
// If any additional function options are added in the future, they must be excluded as well.
|
|
53
|
-
const { functions, importer, ...serializableOptions } = options;
|
|
53
|
+
const { functions, importer, logger, ...serializableOptions } = options;
|
|
54
54
|
// The CLI's configuration does not use or expose the ability to defined custom Sass functions
|
|
55
55
|
if (functions && Object.keys(functions).length > 0) {
|
|
56
56
|
throw new Error('Sass custom functions are not supported.');
|
package/src/sass/worker.js
CHANGED
|
@@ -25,7 +25,6 @@ worker_threads_1.parentPort.on('message', ({ id, hasImporter, options }) => {
|
|
|
25
25
|
options.importer = function (url, prev) {
|
|
26
26
|
var _a;
|
|
27
27
|
Atomics.store(importerSignal, 0, 0);
|
|
28
|
-
// `this.fromImport` was added in dart-sass in 1.33.0, `@types/sass` doesn't include it yet.
|
|
29
28
|
const { fromImport } = this;
|
|
30
29
|
workerImporterPort.postMessage({ id, url, prev, fromImport });
|
|
31
30
|
Atomics.wait(importerSignal, 0, 0);
|
|
@@ -40,13 +40,12 @@ class BundleActionExecutor {
|
|
|
40
40
|
const executions = new Map();
|
|
41
41
|
for (const action of actions) {
|
|
42
42
|
const execution = executor(action);
|
|
43
|
-
executions.set(execution, execution.then((result) =>
|
|
44
|
-
executions.delete(execution);
|
|
45
|
-
return result;
|
|
46
|
-
}));
|
|
43
|
+
executions.set(execution, execution.then((result) => [execution, result]));
|
|
47
44
|
}
|
|
48
45
|
while (executions.size > 0) {
|
|
49
|
-
|
|
46
|
+
const [execution, result] = await Promise.race(executions.values());
|
|
47
|
+
executions.delete(execution);
|
|
48
|
+
yield result;
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
stop() {
|
|
@@ -59,8 +59,6 @@ export interface BuildOptions {
|
|
|
59
59
|
inlineStyleLanguage?: InlineStyleLanguage;
|
|
60
60
|
allowedCommonJsDependencies?: string[];
|
|
61
61
|
cache: NormalizedCachedOptions;
|
|
62
|
-
}
|
|
63
|
-
export interface WebpackTestOptions extends BuildOptions {
|
|
64
62
|
codeCoverage?: boolean;
|
|
65
63
|
codeCoverageExclude?: string[];
|
|
66
64
|
}
|
|
@@ -32,7 +32,7 @@ const path = __importStar(require("path"));
|
|
|
32
32
|
const action_executor_1 = require("./action-executor");
|
|
33
33
|
const copy_assets_1 = require("./copy-assets");
|
|
34
34
|
const spinner_1 = require("./spinner");
|
|
35
|
-
function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emittedPath, outputPath, es5, missingTranslation) {
|
|
35
|
+
function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emittedPath, outputPath, es5, missingTranslation, context) {
|
|
36
36
|
const options = [];
|
|
37
37
|
const originalFiles = [];
|
|
38
38
|
for (const emittedFile of emittedFiles) {
|
|
@@ -51,16 +51,31 @@ function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emitte
|
|
|
51
51
|
setLocale: emittedFile.name === 'main' || emittedFile.name === 'vendor',
|
|
52
52
|
};
|
|
53
53
|
originalFiles.push(originalPath);
|
|
54
|
+
// Remove temporary original file as the content has now been read
|
|
55
|
+
try {
|
|
56
|
+
fs.unlinkSync(originalPath);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
context.logger.debug(`Unable to delete i18n temporary file [${originalPath}]: ${e.toString()}`);
|
|
60
|
+
}
|
|
54
61
|
try {
|
|
55
62
|
const originalMapPath = originalPath + '.map';
|
|
56
63
|
action.map = fs.readFileSync(originalMapPath, 'utf8');
|
|
57
64
|
originalFiles.push(originalMapPath);
|
|
65
|
+
// Remove temporary original map file as the content has now been read
|
|
66
|
+
try {
|
|
67
|
+
fs.unlinkSync(originalMapPath);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
context.logger.debug(`Unable to delete i18n temporary file [${originalMapPath}]: ${e.toString()}`);
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
73
|
catch (err) {
|
|
60
74
|
if (err.code !== 'ENOENT') {
|
|
61
75
|
throw err;
|
|
62
76
|
}
|
|
63
77
|
}
|
|
78
|
+
context.logger.debug(`i18n file queued for processing: ${action.filename}`);
|
|
64
79
|
options.push(action);
|
|
65
80
|
}
|
|
66
81
|
return { options, originalFiles };
|
|
@@ -71,8 +86,9 @@ async function i18nInlineEmittedFiles(context, emittedFiles, i18n, baseOutputPat
|
|
|
71
86
|
const spinner = new spinner_1.Spinner();
|
|
72
87
|
spinner.start('Generating localized bundles...');
|
|
73
88
|
try {
|
|
74
|
-
const { options, originalFiles: processedFiles } = emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emittedPath, baseOutputPath, es5, missingTranslation);
|
|
89
|
+
const { options, originalFiles: processedFiles } = emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emittedPath, baseOutputPath, es5, missingTranslation, context);
|
|
75
90
|
for await (const result of executor.inlineAll(options)) {
|
|
91
|
+
context.logger.debug(`i18n file processed: ${result.file}`);
|
|
76
92
|
for (const diagnostic of result.diagnostics) {
|
|
77
93
|
spinner.stop();
|
|
78
94
|
if (diagnostic.type === 'error') {
|
|
@@ -16,8 +16,7 @@ function normalizeOptimization(optimization = true) {
|
|
|
16
16
|
? optimization.styles
|
|
17
17
|
: {
|
|
18
18
|
minify: !!optimization.styles,
|
|
19
|
-
|
|
20
|
-
inlineCritical: false,
|
|
19
|
+
inlineCritical: !!optimization.styles,
|
|
21
20
|
},
|
|
22
21
|
fonts: typeof optimization.fonts === 'object'
|
|
23
22
|
? optimization.fonts
|
|
@@ -30,8 +29,7 @@ function normalizeOptimization(optimization = true) {
|
|
|
30
29
|
scripts: optimization,
|
|
31
30
|
styles: {
|
|
32
31
|
minify: optimization,
|
|
33
|
-
|
|
34
|
-
inlineCritical: false,
|
|
32
|
+
inlineCritical: optimization,
|
|
35
33
|
},
|
|
36
34
|
fonts: {
|
|
37
35
|
inline: optimization,
|