@angular-devkit/build-angular 15.0.0-next.2 → 15.0.0-next.3
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 +11 -11
- package/src/builders/app-shell/index.js +16 -8
- package/src/builders/browser/schema.d.ts +6 -2
- package/src/builders/browser/schema.json +16 -2
- package/src/builders/browser-esbuild/options.js +6 -1
- package/src/builders/browser-esbuild/schema.d.ts +6 -2
- package/src/builders/browser-esbuild/schema.json +16 -2
- package/src/builders/karma/find-tests-plugin.d.ts +19 -0
- package/src/builders/karma/{find-tests.js → find-tests-plugin.js} +49 -5
- package/src/builders/karma/index.js +40 -38
- package/src/builders/karma/schema.d.ts +7 -3
- package/src/builders/karma/schema.json +18 -3
- package/src/builders/server/schema.d.ts +0 -5
- package/src/builders/server/schema.json +0 -5
- package/src/sass/sass-service-legacy.d.ts +51 -0
- package/src/sass/sass-service-legacy.js +175 -0
- package/src/sass/sass-service.d.ts +6 -9
- package/src/sass/sass-service.js +69 -52
- package/src/{builders/karma/find-tests.d.ts → sass/worker-legacy.d.ts} +1 -1
- package/src/sass/worker-legacy.js +44 -0
- package/src/sass/worker.js +64 -14
- package/src/utils/build-options.d.ts +1 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +11 -1
- package/src/utils/normalize-builder-schema.d.ts +1 -0
- package/src/utils/normalize-builder-schema.js +3 -2
- package/src/utils/normalize-polyfills.d.ts +8 -0
- package/src/utils/normalize-polyfills.js +24 -0
- package/src/utils/webpack-diagnostics.d.ts +1 -1
- package/src/utils/webpack-diagnostics.js +2 -3
- package/src/webpack/configs/common.js +27 -12
- package/src/webpack/configs/styles.js +63 -60
- package/src/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/webpack/plugins/karma/karma.js +4 -5
- package/src/webpack/plugins/transfer-size-plugin.js +2 -1
- package/src/webpack/utils/helpers.d.ts +0 -1
- package/src/webpack/utils/helpers.js +1 -20
- package/src/webpack/plugins/single-test-transform.d.ts +0 -27
- package/src/webpack/plugins/single-test-transform.js +0 -44
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "15.0.0-next.
|
|
3
|
+
"version": "15.0.0-next.3",
|
|
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": "2.2.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1500.0-next.
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1500.0-next.
|
|
12
|
-
"@angular-devkit/core": "15.0.0-next.
|
|
13
|
-
"@babel/core": "7.19.
|
|
14
|
-
"@babel/generator": "7.19.
|
|
10
|
+
"@angular-devkit/architect": "0.1500.0-next.3",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1500.0-next.3",
|
|
12
|
+
"@angular-devkit/core": "15.0.0-next.3",
|
|
13
|
+
"@babel/core": "7.19.3",
|
|
14
|
+
"@babel/generator": "7.19.3",
|
|
15
15
|
"@babel/helper-annotate-as-pure": "7.18.6",
|
|
16
16
|
"@babel/plugin-proposal-async-generator-functions": "7.19.1",
|
|
17
17
|
"@babel/plugin-transform-async-to-generator": "7.18.6",
|
|
18
18
|
"@babel/plugin-transform-runtime": "7.19.1",
|
|
19
|
-
"@babel/preset-env": "7.19.
|
|
19
|
+
"@babel/preset-env": "7.19.3",
|
|
20
20
|
"@babel/runtime": "7.19.0",
|
|
21
21
|
"@babel/template": "7.18.10",
|
|
22
22
|
"@discoveryjs/json-ext": "0.5.7",
|
|
23
|
-
"@ngtools/webpack": "15.0.0-next.
|
|
23
|
+
"@ngtools/webpack": "15.0.0-next.3",
|
|
24
24
|
"ansi-colors": "4.1.3",
|
|
25
25
|
"autoprefixer": "10.4.12",
|
|
26
26
|
"babel-loader": "8.2.5",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"copy-webpack-plugin": "11.0.0",
|
|
31
31
|
"critters": "0.0.16",
|
|
32
32
|
"css-loader": "6.7.1",
|
|
33
|
-
"esbuild-wasm": "0.15.
|
|
33
|
+
"esbuild-wasm": "0.15.9",
|
|
34
34
|
"glob": "8.0.3",
|
|
35
35
|
"https-proxy-agent": "5.0.1",
|
|
36
36
|
"inquirer": "8.2.4",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"regenerator-runtime": "0.13.9",
|
|
53
53
|
"resolve-url-loader": "5.0.0",
|
|
54
54
|
"rxjs": "6.6.7",
|
|
55
|
-
"sass": "1.
|
|
55
|
+
"sass": "1.55.0",
|
|
56
56
|
"sass-loader": "13.0.2",
|
|
57
57
|
"semver": "7.3.7",
|
|
58
58
|
"source-map-loader": "4.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"webpack-subresource-integrity": "5.1.0"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
|
-
"esbuild": "0.15.
|
|
71
|
+
"esbuild": "0.15.9"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@angular/compiler-cli": "^15.0.0-next",
|
|
@@ -29,8 +29,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
__setModuleDefault(result, mod);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
32
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
36
|
const architect_1 = require("@angular-devkit/architect");
|
|
37
|
+
const assert_1 = __importDefault(require("assert"));
|
|
34
38
|
const fs = __importStar(require("fs"));
|
|
35
39
|
const path = __importStar(require("path"));
|
|
36
40
|
const utils_1 = require("../../utils");
|
|
@@ -67,17 +71,21 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
|
|
|
67
71
|
const browserIndexOutputPath = path.join(outputPath, 'index.html');
|
|
68
72
|
const indexHtml = await fs.promises.readFile(browserIndexOutputPath, 'utf8');
|
|
69
73
|
const serverBundlePath = await _getServerModuleBundlePath(options, context, serverResult, localeDirectory);
|
|
70
|
-
const { AppServerModule, renderModule } = await Promise.resolve().then(() => __importStar(require(serverBundlePath)));
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
74
|
+
const { AppServerModule, renderModule, ɵSERVER_CONTEXT } = (await Promise.resolve().then(() => __importStar(require(serverBundlePath))));
|
|
75
|
+
(0, assert_1.default)(renderModule, `renderModule was not exported from: ${serverBundlePath}.`);
|
|
76
|
+
(0, assert_1.default)(AppServerModule, `AppServerModule was not exported from: ${serverBundlePath}.`);
|
|
77
|
+
(0, assert_1.default)(ɵSERVER_CONTEXT, `ɵSERVER_CONTEXT was not exported from: ${serverBundlePath}.`);
|
|
75
78
|
// Load platform server module renderer
|
|
76
|
-
|
|
79
|
+
let html = await renderModule(AppServerModule, {
|
|
77
80
|
document: indexHtml,
|
|
78
81
|
url: options.route,
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
extraProviders: [
|
|
83
|
+
{
|
|
84
|
+
provide: ɵSERVER_CONTEXT,
|
|
85
|
+
useValue: 'app-shell',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
81
89
|
// Overwrite the client index file.
|
|
82
90
|
const outputIndexPath = options.outputIndexPath
|
|
83
91
|
? path.join(root, options.outputIndexPath)
|
|
@@ -106,9 +106,9 @@ export interface Schema {
|
|
|
106
106
|
*/
|
|
107
107
|
poll?: number;
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
109
|
+
* Polyfills to be included in the build.
|
|
110
110
|
*/
|
|
111
|
-
polyfills?:
|
|
111
|
+
polyfills?: Polyfills;
|
|
112
112
|
/**
|
|
113
113
|
* Do not use the real path when resolving modules. If unset then will default to `true` if
|
|
114
114
|
* NodeJS option --preserve-symlinks is set.
|
|
@@ -359,6 +359,10 @@ export declare enum OutputHashing {
|
|
|
359
359
|
Media = "media",
|
|
360
360
|
None = "none"
|
|
361
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Polyfills to be included in the build.
|
|
364
|
+
*/
|
|
365
|
+
export declare type Polyfills = string[] | string;
|
|
362
366
|
export declare type ScriptElement = ScriptClass | string;
|
|
363
367
|
export interface ScriptClass {
|
|
364
368
|
/**
|
|
@@ -17,8 +17,22 @@
|
|
|
17
17
|
"description": "The full path for the main entry point to the app, relative to the current workspace."
|
|
18
18
|
},
|
|
19
19
|
"polyfills": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"description": "Polyfills to be included in the build.",
|
|
21
|
+
"oneOf": [
|
|
22
|
+
{
|
|
23
|
+
"type": "array",
|
|
24
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"uniqueItems": true
|
|
28
|
+
},
|
|
29
|
+
"default": []
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
34
|
+
}
|
|
35
|
+
]
|
|
22
36
|
},
|
|
23
37
|
"tsConfig": {
|
|
24
38
|
"type": "string",
|
|
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
exports.normalizeOptions = void 0;
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const utils_1 = require("../../utils");
|
|
36
|
+
const normalize_polyfills_1 = require("../../utils/normalize-polyfills");
|
|
36
37
|
const schema_1 = require("../browser/schema");
|
|
37
38
|
/**
|
|
38
39
|
* Normalize the user provided options by creating full paths for all path based options
|
|
@@ -52,7 +53,11 @@ async function normalizeOptions(context, projectName, options) {
|
|
|
52
53
|
const projectSourceRoot = path.join(workspaceRoot, (_b = projectMetadata.sourceRoot) !== null && _b !== void 0 ? _b : 'src');
|
|
53
54
|
// Normalize options
|
|
54
55
|
const mainEntryPoint = path.join(workspaceRoot, options.main);
|
|
55
|
-
|
|
56
|
+
// Currently esbuild do not support multiple files per entry-point
|
|
57
|
+
const [polyfillsEntryPoint, ...remainingPolyfills] = (0, normalize_polyfills_1.normalizePolyfills)(options.polyfills, workspaceRoot);
|
|
58
|
+
if (remainingPolyfills.length) {
|
|
59
|
+
context.logger.warn(`The 'polyfills' option currently does not support multiple entries by this experimental builder. The first entry will be used.`);
|
|
60
|
+
}
|
|
56
61
|
const tsconfig = path.join(workspaceRoot, options.tsConfig);
|
|
57
62
|
const outputPath = path.join(workspaceRoot, options.outputPath);
|
|
58
63
|
const optimizationOptions = (0, utils_1.normalizeOptimization)(options.optimization);
|
|
@@ -111,9 +111,9 @@ export interface Schema {
|
|
|
111
111
|
*/
|
|
112
112
|
poll?: number;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Polyfills to be included in the build.
|
|
115
115
|
*/
|
|
116
|
-
polyfills?:
|
|
116
|
+
polyfills?: Polyfills;
|
|
117
117
|
/**
|
|
118
118
|
* Do not use the real path when resolving modules. If unset then will default to `true` if
|
|
119
119
|
* NodeJS option --preserve-symlinks is set.
|
|
@@ -362,6 +362,10 @@ export declare enum OutputHashing {
|
|
|
362
362
|
Media = "media",
|
|
363
363
|
None = "none"
|
|
364
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Polyfills to be included in the build.
|
|
367
|
+
*/
|
|
368
|
+
export declare type Polyfills = string[] | string;
|
|
365
369
|
export declare type ScriptElement = ScriptClass | string;
|
|
366
370
|
export interface ScriptClass {
|
|
367
371
|
/**
|
|
@@ -17,8 +17,22 @@
|
|
|
17
17
|
"description": "The full path for the main entry point to the app, relative to the current workspace."
|
|
18
18
|
},
|
|
19
19
|
"polyfills": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"description": "Polyfills to be included in the build.",
|
|
21
|
+
"oneOf": [
|
|
22
|
+
{
|
|
23
|
+
"type": "array",
|
|
24
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"uniqueItems": true
|
|
28
|
+
},
|
|
29
|
+
"default": []
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
34
|
+
}
|
|
35
|
+
]
|
|
22
36
|
},
|
|
23
37
|
"tsConfig": {
|
|
24
38
|
"type": "string",
|
|
@@ -0,0 +1,19 @@
|
|
|
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 type { Compiler } from 'webpack';
|
|
9
|
+
export interface FindTestsPluginOptions {
|
|
10
|
+
include?: string[];
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
projectSourceRoot: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class FindTestsPlugin {
|
|
15
|
+
private options;
|
|
16
|
+
private compilation;
|
|
17
|
+
constructor(options: FindTestsPluginOptions);
|
|
18
|
+
apply(compiler: Compiler): void;
|
|
19
|
+
}
|
|
@@ -29,13 +29,54 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
__setModuleDefault(result, mod);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
32
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.
|
|
36
|
+
exports.FindTestsPlugin = void 0;
|
|
37
|
+
const assert_1 = __importDefault(require("assert"));
|
|
34
38
|
const fs_1 = require("fs");
|
|
35
39
|
const glob_1 = __importStar(require("glob"));
|
|
36
40
|
const path_1 = require("path");
|
|
37
41
|
const util_1 = require("util");
|
|
42
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
38
43
|
const globPromise = (0, util_1.promisify)(glob_1.default);
|
|
44
|
+
/**
|
|
45
|
+
* The name of the plugin provided to Webpack when tapping Webpack compiler hooks.
|
|
46
|
+
*/
|
|
47
|
+
const PLUGIN_NAME = 'angular-find-tests-plugin';
|
|
48
|
+
class FindTestsPlugin {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this.options = options;
|
|
51
|
+
}
|
|
52
|
+
apply(compiler) {
|
|
53
|
+
const { include = ['**/*.spec.ts'], projectSourceRoot, workspaceRoot } = this.options;
|
|
54
|
+
const webpackOptions = compiler.options;
|
|
55
|
+
const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
|
|
56
|
+
let originalImport;
|
|
57
|
+
// Add tests files are part of the entry-point.
|
|
58
|
+
webpackOptions.entry = async () => {
|
|
59
|
+
const specFiles = await findTests(include, workspaceRoot, projectSourceRoot);
|
|
60
|
+
if (!specFiles.length) {
|
|
61
|
+
(0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
|
|
62
|
+
(0, webpack_diagnostics_1.addError)(this.compilation, `Specified patterns: "${include.join(', ')}" did not match any spec files.`);
|
|
63
|
+
}
|
|
64
|
+
const entrypoints = await entry;
|
|
65
|
+
const entrypoint = entrypoints['main'];
|
|
66
|
+
if (!entrypoint.import) {
|
|
67
|
+
throw new Error(`Cannot find 'main' entrypoint.`);
|
|
68
|
+
}
|
|
69
|
+
originalImport !== null && originalImport !== void 0 ? originalImport : (originalImport = entrypoint.import);
|
|
70
|
+
entrypoint.import = [...originalImport, ...specFiles];
|
|
71
|
+
return entrypoints;
|
|
72
|
+
};
|
|
73
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
74
|
+
this.compilation = compilation;
|
|
75
|
+
compilation.contextDependencies.add(projectSourceRoot);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.FindTestsPlugin = FindTestsPlugin;
|
|
39
80
|
// go through all patterns and find unique list of files
|
|
40
81
|
async function findTests(patterns, workspaceRoot, projectSourceRoot) {
|
|
41
82
|
const matchingTestsPromises = patterns.map((pattern) => findMatchingTests(pattern, workspaceRoot, projectSourceRoot));
|
|
@@ -43,11 +84,13 @@ async function findTests(patterns, workspaceRoot, projectSourceRoot) {
|
|
|
43
84
|
// Unique file names
|
|
44
85
|
return [...new Set(files.flat())];
|
|
45
86
|
}
|
|
46
|
-
exports.findTests = findTests;
|
|
47
87
|
const normalizePath = (path) => path.replace(/\\/g, '/');
|
|
48
88
|
async function findMatchingTests(pattern, workspaceRoot, projectSourceRoot) {
|
|
49
89
|
// normalize pattern, glob lib only accepts forward slashes
|
|
50
90
|
let normalizedPattern = normalizePath(pattern);
|
|
91
|
+
if (normalizedPattern.charAt(0) === '/') {
|
|
92
|
+
normalizedPattern = normalizedPattern.substring(1);
|
|
93
|
+
}
|
|
51
94
|
const relativeProjectRoot = normalizePath((0, path_1.relative)(workspaceRoot, projectSourceRoot) + '/');
|
|
52
95
|
// remove relativeProjectRoot to support relative paths from root
|
|
53
96
|
// such paths are easy to get when running scripts via IDEs
|
|
@@ -63,9 +106,9 @@ async function findMatchingTests(pattern, workspaceRoot, projectSourceRoot) {
|
|
|
63
106
|
// see if matching spec file exists
|
|
64
107
|
const fileExt = (0, path_1.extname)(normalizedPattern);
|
|
65
108
|
// Replace extension to `.spec.ext`. Example: `src/app/app.component.ts`-> `src/app/app.component.spec.ts`
|
|
66
|
-
const potentialSpec = (0, path_1.join)((0, path_1.dirname)(normalizedPattern), `${(0, path_1.basename)(normalizedPattern, fileExt)}.spec${fileExt}`);
|
|
67
|
-
if (await exists(
|
|
68
|
-
return [
|
|
109
|
+
const potentialSpec = (0, path_1.join)(projectSourceRoot, (0, path_1.dirname)(normalizedPattern), `${(0, path_1.basename)(normalizedPattern, fileExt)}.spec${fileExt}`);
|
|
110
|
+
if (await exists(potentialSpec)) {
|
|
111
|
+
return [potentialSpec];
|
|
69
112
|
}
|
|
70
113
|
}
|
|
71
114
|
}
|
|
@@ -73,6 +116,7 @@ async function findMatchingTests(pattern, workspaceRoot, projectSourceRoot) {
|
|
|
73
116
|
cwd: projectSourceRoot,
|
|
74
117
|
root: projectSourceRoot,
|
|
75
118
|
nomount: true,
|
|
119
|
+
absolute: true,
|
|
76
120
|
});
|
|
77
121
|
}
|
|
78
122
|
async function isDirectory(path) {
|
|
@@ -39,10 +39,10 @@ const purge_cache_1 = require("../../utils/purge-cache");
|
|
|
39
39
|
const version_1 = require("../../utils/version");
|
|
40
40
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
41
41
|
const configs_1 = require("../../webpack/configs");
|
|
42
|
-
const single_test_transform_1 = require("../../webpack/plugins/single-test-transform");
|
|
43
42
|
const schema_1 = require("../browser/schema");
|
|
44
|
-
const
|
|
43
|
+
const find_tests_plugin_1 = require("./find-tests-plugin");
|
|
45
44
|
async function initialize(options, context, webpackConfigurationTransformer) {
|
|
45
|
+
var _a;
|
|
46
46
|
// Purge old build disk cache.
|
|
47
47
|
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
|
48
48
|
const { config } = await (0, webpack_browser_config_1.generateBrowserWebpackConfigFromContext)(
|
|
@@ -67,10 +67,7 @@ async function initialize(options, context, webpackConfigurationTransformer) {
|
|
|
67
67
|
watch: true,
|
|
68
68
|
}, context, (wco) => [(0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)]);
|
|
69
69
|
const karma = await Promise.resolve().then(() => __importStar(require('karma')));
|
|
70
|
-
return [
|
|
71
|
-
karma,
|
|
72
|
-
webpackConfigurationTransformer ? await webpackConfigurationTransformer(config) : config,
|
|
73
|
-
];
|
|
70
|
+
return [karma, (_a = (await (webpackConfigurationTransformer === null || webpackConfigurationTransformer === void 0 ? void 0 : webpackConfigurationTransformer(config)))) !== null && _a !== void 0 ? _a : config];
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
76
73
|
* @experimental Direct usage of this function is considered experimental.
|
|
@@ -100,40 +97,29 @@ function execute(options, context, transforms = {}) {
|
|
|
100
97
|
karmaOptions.reporters = reporters;
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
// Get the rules and ensure the Webpack configuration is setup properly
|
|
118
|
-
const rules = ((_e = webpackConfig.module) === null || _e === void 0 ? void 0 : _e.rules) || [];
|
|
119
|
-
if (!webpackConfig.module) {
|
|
120
|
-
webpackConfig.module = { rules };
|
|
121
|
-
}
|
|
122
|
-
else if (!webpackConfig.module.rules) {
|
|
123
|
-
webpackConfig.module.rules = rules;
|
|
100
|
+
const projectName = (_a = context.target) === null || _a === void 0 ? void 0 : _a.project;
|
|
101
|
+
if (!projectName) {
|
|
102
|
+
throw new Error('The builder requires a target.');
|
|
103
|
+
}
|
|
104
|
+
if (!options.main) {
|
|
105
|
+
(_b = webpackConfig.entry) !== null && _b !== void 0 ? _b : (webpackConfig.entry = {});
|
|
106
|
+
if (typeof webpackConfig.entry === 'object' && !Array.isArray(webpackConfig.entry)) {
|
|
107
|
+
if (Array.isArray(webpackConfig.entry['main'])) {
|
|
108
|
+
webpackConfig.entry['main'].push(getBuiltInMainFile());
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
webpackConfig.entry['main'] = [getBuiltInMainFile()];
|
|
112
|
+
}
|
|
124
113
|
}
|
|
125
|
-
rules.unshift({
|
|
126
|
-
test: path.resolve(context.workspaceRoot, options.main),
|
|
127
|
-
use: {
|
|
128
|
-
// cannot be a simple path as it differs between environments
|
|
129
|
-
loader: single_test_transform_1.SingleTestTransformLoader,
|
|
130
|
-
options: {
|
|
131
|
-
files,
|
|
132
|
-
logger: context.logger,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
114
|
}
|
|
115
|
+
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
116
|
+
const sourceRoot = ((_d = (_c = projectMetadata.sourceRoot) !== null && _c !== void 0 ? _c : projectMetadata.root) !== null && _d !== void 0 ? _d : '');
|
|
117
|
+
(_e = webpackConfig.plugins) !== null && _e !== void 0 ? _e : (webpackConfig.plugins = []);
|
|
118
|
+
webpackConfig.plugins.push(new find_tests_plugin_1.FindTestsPlugin({
|
|
119
|
+
include: options.include,
|
|
120
|
+
workspaceRoot: context.workspaceRoot,
|
|
121
|
+
projectSourceRoot: path.join(context.workspaceRoot, sourceRoot),
|
|
122
|
+
}));
|
|
137
123
|
karmaOptions.buildWebpack = {
|
|
138
124
|
options,
|
|
139
125
|
webpackConfig,
|
|
@@ -164,3 +150,19 @@ function execute(options, context, transforms = {}) {
|
|
|
164
150
|
}
|
|
165
151
|
exports.execute = execute;
|
|
166
152
|
exports.default = (0, architect_1.createBuilder)(execute);
|
|
153
|
+
function getBuiltInMainFile() {
|
|
154
|
+
const content = Buffer.from(`
|
|
155
|
+
import { getTestBed } from '@angular/core/testing';
|
|
156
|
+
import {
|
|
157
|
+
BrowserDynamicTestingModule,
|
|
158
|
+
platformBrowserDynamicTesting,
|
|
159
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
160
|
+
|
|
161
|
+
// Initialize the Angular testing environment.
|
|
162
|
+
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
|
|
163
|
+
errorOnUnknownElements: true,
|
|
164
|
+
errorOnUnknownProperties: true
|
|
165
|
+
});
|
|
166
|
+
`).toString('base64');
|
|
167
|
+
return `ng-virtual-main.js!=!data:text/javascript;base64,${content}`;
|
|
168
|
+
}
|
|
@@ -42,15 +42,15 @@ export interface Schema {
|
|
|
42
42
|
/**
|
|
43
43
|
* The name of the main entry-point file.
|
|
44
44
|
*/
|
|
45
|
-
main
|
|
45
|
+
main?: string;
|
|
46
46
|
/**
|
|
47
47
|
* Enable and define the file watching poll time period in milliseconds.
|
|
48
48
|
*/
|
|
49
49
|
poll?: number;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Polyfills to be included in the build.
|
|
52
52
|
*/
|
|
53
|
-
polyfills?:
|
|
53
|
+
polyfills?: Polyfills;
|
|
54
54
|
/**
|
|
55
55
|
* Do not use the real path when resolving modules. If unset then will default to `true` if
|
|
56
56
|
* NodeJS option --preserve-symlinks is set.
|
|
@@ -128,6 +128,10 @@ export declare enum InlineStyleLanguage {
|
|
|
128
128
|
Sass = "sass",
|
|
129
129
|
Scss = "scss"
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Polyfills to be included in the build.
|
|
133
|
+
*/
|
|
134
|
+
export declare type Polyfills = string[] | string;
|
|
131
135
|
export declare type ScriptElement = ScriptClass | string;
|
|
132
136
|
export interface ScriptClass {
|
|
133
137
|
/**
|
|
@@ -17,8 +17,22 @@
|
|
|
17
17
|
"description": "The name of the Karma configuration file."
|
|
18
18
|
},
|
|
19
19
|
"polyfills": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"description": "Polyfills to be included in the build.",
|
|
21
|
+
"oneOf": [
|
|
22
|
+
{
|
|
23
|
+
"type": "array",
|
|
24
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"uniqueItems": true
|
|
28
|
+
},
|
|
29
|
+
"default": []
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
34
|
+
}
|
|
35
|
+
]
|
|
22
36
|
},
|
|
23
37
|
"assets": {
|
|
24
38
|
"type": "array",
|
|
@@ -126,6 +140,7 @@
|
|
|
126
140
|
"items": {
|
|
127
141
|
"type": "string"
|
|
128
142
|
},
|
|
143
|
+
"default": ["**/*.spec.ts"],
|
|
129
144
|
"description": "Globs of files to include, relative to workspace or project root. \nThere are 2 special cases:\n - when a path to directory is provided, all spec files ending \".spec.@(ts|tsx)\" will be included\n - when a path to a file is provided, and a matching spec file exists it will be included instead."
|
|
130
145
|
},
|
|
131
146
|
"sourceMap": {
|
|
@@ -240,7 +255,7 @@
|
|
|
240
255
|
}
|
|
241
256
|
},
|
|
242
257
|
"additionalProperties": false,
|
|
243
|
-
"required": ["
|
|
258
|
+
"required": ["tsConfig", "karmaConfig"],
|
|
244
259
|
"definitions": {
|
|
245
260
|
"assetPattern": {
|
|
246
261
|
"oneOf": [
|
|
@@ -181,11 +181,6 @@
|
|
|
181
181
|
"description": "Use file name for lazy loaded chunks.",
|
|
182
182
|
"default": false
|
|
183
183
|
},
|
|
184
|
-
"bundleDependencies": {
|
|
185
|
-
"description": "Which external dependencies to bundle into the bundle. By default, all of node_modules will be bundled.",
|
|
186
|
-
"default": true,
|
|
187
|
-
"type": "boolean"
|
|
188
|
-
},
|
|
189
184
|
"externalDependencies": {
|
|
190
185
|
"description": "Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime.",
|
|
191
186
|
"type": "array",
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { LegacyResult as CompileResult, LegacyException as Exception, LegacyOptions as Options } from 'sass';
|
|
9
|
+
/**
|
|
10
|
+
* The callback type for the `dart-sass` asynchronous render function.
|
|
11
|
+
*/
|
|
12
|
+
declare type RenderCallback = (error?: Exception, result?: CompileResult) => void;
|
|
13
|
+
/**
|
|
14
|
+
* A Sass renderer implementation that provides an interface that can be used by Webpack's
|
|
15
|
+
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
|
|
16
|
+
* with the `dart-sass` package. The `dart-sass` synchronous render function is used within
|
|
17
|
+
* the worker which can be up to two times faster than the asynchronous variant.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SassLegacyWorkerImplementation {
|
|
20
|
+
private readonly workers;
|
|
21
|
+
private readonly availableWorkers;
|
|
22
|
+
private readonly requests;
|
|
23
|
+
private readonly workerPath;
|
|
24
|
+
private idCounter;
|
|
25
|
+
private nextWorkerIndex;
|
|
26
|
+
/**
|
|
27
|
+
* Provides information about the Sass implementation.
|
|
28
|
+
* This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
|
|
29
|
+
*/
|
|
30
|
+
get info(): string;
|
|
31
|
+
/**
|
|
32
|
+
* The synchronous render function is not used by the `sass-loader`.
|
|
33
|
+
*/
|
|
34
|
+
renderSync(): never;
|
|
35
|
+
/**
|
|
36
|
+
* Asynchronously request a Sass stylesheet to be renderered.
|
|
37
|
+
*
|
|
38
|
+
* @param options The `dart-sass` options to use when rendering the stylesheet.
|
|
39
|
+
* @param callback The function to execute when the rendering is complete.
|
|
40
|
+
*/
|
|
41
|
+
render(options: Options<'async'>, callback: RenderCallback): void;
|
|
42
|
+
/**
|
|
43
|
+
* Shutdown the Sass render worker.
|
|
44
|
+
* Executing this method will stop any pending render requests.
|
|
45
|
+
*/
|
|
46
|
+
close(): void;
|
|
47
|
+
private createWorker;
|
|
48
|
+
private processImporters;
|
|
49
|
+
private createRequest;
|
|
50
|
+
}
|
|
51
|
+
export {};
|