@angular-devkit/build-angular 15.0.0-next.1 → 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 +15 -17
- package/src/babel/presets/application.d.ts +1 -2
- package/src/babel/presets/application.js +1 -4
- package/src/babel/webpack-loader.js +8 -22
- package/src/builders/app-shell/index.js +16 -8
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +4 -16
- package/src/builders/browser/schema.d.ts +6 -2
- package/src/builders/browser/schema.json +18 -4
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +1 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +20 -17
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -1
- package/src/builders/browser-esbuild/index.js +18 -5
- package/src/builders/browser-esbuild/options.js +6 -1
- package/src/builders/browser-esbuild/schema.d.ts +8 -6
- package/src/builders/browser-esbuild/schema.json +29 -34
- package/src/builders/browser-esbuild/stylesheets.d.ts +1 -0
- package/src/builders/browser-esbuild/stylesheets.js +1 -0
- package/src/builders/extract-i18n/index.js +1 -1
- 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 +20 -5
- package/src/builders/server/index.d.ts +1 -1
- package/src/builders/server/index.js +42 -10
- package/src/builders/server/platform-server-exports-loader.d.ts +13 -0
- package/src/builders/server/platform-server-exports-loader.js +24 -0
- 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 +2 -4
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +11 -1
- package/src/utils/esbuild-targets.d.ts +12 -0
- package/src/utils/esbuild-targets.js +39 -0
- package/src/utils/i18n-inlining.d.ts +1 -1
- package/src/utils/i18n-inlining.js +3 -4
- package/src/utils/normalize-builder-schema.d.ts +3 -2
- package/src/utils/normalize-builder-schema.js +5 -4
- package/src/utils/normalize-polyfills.d.ts +8 -0
- package/src/utils/normalize-polyfills.js +24 -0
- package/src/utils/process-bundle.d.ts +0 -1
- package/src/utils/process-bundle.js +29 -57
- package/src/utils/supported-browsers.d.ts +2 -1
- package/src/utils/supported-browsers.js +18 -2
- package/src/utils/webpack-browser-config.d.ts +0 -2
- package/src/utils/webpack-browser-config.js +2 -8
- package/src/utils/webpack-diagnostics.d.ts +1 -1
- package/src/utils/webpack-diagnostics.js +2 -3
- package/src/webpack/configs/common.js +37 -24
- package/src/webpack/configs/dev-server.js +1 -1
- package/src/webpack/configs/styles.js +63 -80
- package/src/webpack/plugins/any-component-style-budget-checker.js +1 -1
- package/src/webpack/plugins/css-optimizer-plugin.d.ts +0 -1
- package/src/webpack/plugins/css-optimizer-plugin.js +3 -26
- package/src/webpack/plugins/hmr/hmr-loader.d.ts +1 -1
- package/src/webpack/plugins/hmr/hmr-loader.js +2 -5
- package/src/webpack/plugins/javascript-optimizer-plugin.d.ts +4 -6
- package/src/webpack/plugins/javascript-optimizer-plugin.js +7 -16
- package/src/webpack/plugins/javascript-optimizer-worker.d.ts +3 -2
- package/src/webpack/plugins/javascript-optimizer-worker.js +21 -46
- package/src/webpack/plugins/karma/karma.js +4 -5
- package/src/webpack/plugins/transfer-size-plugin.js +2 -1
- package/src/webpack/plugins/typescript.js +14 -25
- package/src/webpack/utils/helpers.d.ts +0 -3
- package/src/webpack/utils/helpers.js +1 -36
- package/src/webpack/plugins/single-test-transform.d.ts +0 -27
- package/src/webpack/plugins/single-test-transform.js +0 -44
|
@@ -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",
|
|
@@ -72,7 +86,7 @@
|
|
|
72
86
|
"input": {
|
|
73
87
|
"type": "string",
|
|
74
88
|
"description": "The file to include.",
|
|
75
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
89
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
76
90
|
},
|
|
77
91
|
"bundleName": {
|
|
78
92
|
"type": "string",
|
|
@@ -91,7 +105,7 @@
|
|
|
91
105
|
{
|
|
92
106
|
"type": "string",
|
|
93
107
|
"description": "The file to include.",
|
|
94
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
108
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
95
109
|
}
|
|
96
110
|
]
|
|
97
111
|
}
|
|
@@ -461,38 +475,19 @@
|
|
|
461
475
|
]
|
|
462
476
|
},
|
|
463
477
|
"fileReplacement": {
|
|
464
|
-
"
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
"
|
|
468
|
-
|
|
469
|
-
"type": "string",
|
|
470
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
471
|
-
},
|
|
472
|
-
"replaceWith": {
|
|
473
|
-
"type": "string",
|
|
474
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
475
|
-
}
|
|
476
|
-
},
|
|
477
|
-
"additionalProperties": false,
|
|
478
|
-
"required": ["src", "replaceWith"]
|
|
478
|
+
"type": "object",
|
|
479
|
+
"properties": {
|
|
480
|
+
"replace": {
|
|
481
|
+
"type": "string",
|
|
482
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
479
483
|
},
|
|
480
|
-
{
|
|
481
|
-
"type": "
|
|
482
|
-
"
|
|
483
|
-
"replace": {
|
|
484
|
-
"type": "string",
|
|
485
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
486
|
-
},
|
|
487
|
-
"with": {
|
|
488
|
-
"type": "string",
|
|
489
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
"additionalProperties": false,
|
|
493
|
-
"required": ["replace", "with"]
|
|
484
|
+
"with": {
|
|
485
|
+
"type": "string",
|
|
486
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
494
487
|
}
|
|
495
|
-
|
|
488
|
+
},
|
|
489
|
+
"additionalProperties": false,
|
|
490
|
+
"required": ["replace", "with"]
|
|
496
491
|
},
|
|
497
492
|
"budget": {
|
|
498
493
|
"type": "object",
|
|
@@ -53,6 +53,7 @@ async function bundleStylesheet(entry, options) {
|
|
|
53
53
|
outdir: options.workspaceRoot,
|
|
54
54
|
write: false,
|
|
55
55
|
platform: 'browser',
|
|
56
|
+
target: options.target,
|
|
56
57
|
preserveSymlinks: options.preserveSymlinks,
|
|
57
58
|
external: options.externalDependencies,
|
|
58
59
|
conditions: ['style', 'sass'],
|
|
@@ -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",
|
|
@@ -76,7 +90,7 @@
|
|
|
76
90
|
"input": {
|
|
77
91
|
"type": "string",
|
|
78
92
|
"description": "The file to include.",
|
|
79
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
93
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
80
94
|
},
|
|
81
95
|
"bundleName": {
|
|
82
96
|
"type": "string",
|
|
@@ -95,7 +109,7 @@
|
|
|
95
109
|
{
|
|
96
110
|
"type": "string",
|
|
97
111
|
"description": "The file to include.",
|
|
98
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
112
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
99
113
|
}
|
|
100
114
|
]
|
|
101
115
|
}
|
|
@@ -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": [
|
|
@@ -35,5 +35,5 @@ export { ServerBuilderOptions };
|
|
|
35
35
|
export declare function execute(options: ServerBuilderOptions, context: BuilderContext, transforms?: {
|
|
36
36
|
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
|
|
37
37
|
}): Observable<ServerBuilderOutput>;
|
|
38
|
-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<ServerBuilderOptions & import("
|
|
38
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<ServerBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
39
39
|
export default _default;
|
|
@@ -36,7 +36,6 @@ const build_webpack_1 = require("@angular-devkit/build-webpack");
|
|
|
36
36
|
const path = __importStar(require("path"));
|
|
37
37
|
const rxjs_1 = require("rxjs");
|
|
38
38
|
const operators_1 = require("rxjs/operators");
|
|
39
|
-
const typescript_1 = require("typescript");
|
|
40
39
|
const utils_1 = require("../../utils");
|
|
41
40
|
const i18n_inlining_1 = require("../../utils/i18n-inlining");
|
|
42
41
|
const output_paths_1 = require("../../utils/output-paths");
|
|
@@ -54,7 +53,7 @@ function execute(options, context, transforms = {}) {
|
|
|
54
53
|
(0, version_1.assertCompatibleAngularVersion)(root);
|
|
55
54
|
const baseOutputPath = path.resolve(root, options.outputPath);
|
|
56
55
|
let outputPaths;
|
|
57
|
-
return (0, rxjs_1.from)(initialize(options, context, transforms.webpackConfiguration)).pipe((0, operators_1.concatMap)(({ config, i18n
|
|
56
|
+
return (0, rxjs_1.from)(initialize(options, context, transforms.webpackConfiguration)).pipe((0, operators_1.concatMap)(({ config, i18n }) => {
|
|
58
57
|
return (0, build_webpack_1.runWebpack)(config, context, {
|
|
59
58
|
webpackFactory: require('webpack'),
|
|
60
59
|
logging: (stats, config) => {
|
|
@@ -70,7 +69,7 @@ function execute(options, context, transforms = {}) {
|
|
|
70
69
|
let success = output.success;
|
|
71
70
|
if (success && i18n.shouldInline) {
|
|
72
71
|
outputPaths = (0, output_paths_1.ensureOutputPaths)(baseOutputPath, i18n);
|
|
73
|
-
success = await (0, i18n_inlining_1.i18nInlineEmittedFiles)(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), [], outputPath,
|
|
72
|
+
success = await (0, i18n_inlining_1.i18nInlineEmittedFiles)(context, emittedFiles, i18n, baseOutputPath, Array.from(outputPaths.values()), [], outputPath, options.i18nMissingTranslation);
|
|
74
73
|
}
|
|
75
74
|
(0, stats_1.webpackStatsLogger)(context.logger, webpackStats, config);
|
|
76
75
|
return { ...output, success };
|
|
@@ -97,21 +96,54 @@ function execute(options, context, transforms = {}) {
|
|
|
97
96
|
exports.execute = execute;
|
|
98
97
|
exports.default = (0, architect_1.createBuilder)(execute);
|
|
99
98
|
async function initialize(options, context, webpackConfigurationTransform) {
|
|
99
|
+
var _a;
|
|
100
100
|
// Purge old build disk cache.
|
|
101
101
|
await (0, purge_cache_1.purgeStaleBuildCache)(context);
|
|
102
|
+
const browserslist = (await Promise.resolve().then(() => __importStar(require('browserslist')))).default;
|
|
102
103
|
const originalOutputPath = options.outputPath;
|
|
103
|
-
const { config, i18n
|
|
104
|
+
const { config, i18n } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)({
|
|
104
105
|
...options,
|
|
105
106
|
buildOptimizer: false,
|
|
106
107
|
aot: true,
|
|
107
108
|
platform: 'server',
|
|
108
|
-
}, context, (wco) =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
}, context, (wco) => {
|
|
110
|
+
var _a;
|
|
111
|
+
var _b;
|
|
112
|
+
// We use the platform to determine the JavaScript syntax output.
|
|
113
|
+
(_a = (_b = wco.buildOptions).supportedBrowsers) !== null && _a !== void 0 ? _a : (_b.supportedBrowsers = []);
|
|
114
|
+
wco.buildOptions.supportedBrowsers.push(...browserslist('maintained node versions'));
|
|
115
|
+
return [getPlatformServerExportsConfig(wco), (0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)];
|
|
116
|
+
});
|
|
113
117
|
if (options.deleteOutputPath) {
|
|
114
118
|
(0, utils_1.deleteOutputDir)(context.workspaceRoot, originalOutputPath);
|
|
115
119
|
}
|
|
116
|
-
|
|
120
|
+
const transformedConfig = (_a = (await (webpackConfigurationTransform === null || webpackConfigurationTransform === void 0 ? void 0 : webpackConfigurationTransform(config)))) !== null && _a !== void 0 ? _a : config;
|
|
121
|
+
return { config: transformedConfig, i18n };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Add `@angular/platform-server` exports.
|
|
125
|
+
* This is needed so that DI tokens can be referenced and set at runtime outside of the bundle.
|
|
126
|
+
*/
|
|
127
|
+
function getPlatformServerExportsConfig(wco) {
|
|
128
|
+
// Add `@angular/platform-server` exports.
|
|
129
|
+
// This is needed so that DI tokens can be referenced and set at runtime outside of the bundle.
|
|
130
|
+
try {
|
|
131
|
+
// Only add `@angular/platform-server` exports when it is installed.
|
|
132
|
+
// In some cases this builder is used when `@angular/platform-server` is not installed.
|
|
133
|
+
// Example: when using `@nguniversal/common/clover` which does not need `@angular/platform-server`.
|
|
134
|
+
require.resolve('@angular/platform-server', { paths: [wco.root] });
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
module: {
|
|
141
|
+
rules: [
|
|
142
|
+
{
|
|
143
|
+
loader: require.resolve('./platform-server-exports-loader'),
|
|
144
|
+
include: [path.resolve(wco.root, wco.buildOptions.main)],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
117
149
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* This loader is needed to add additional exports and is a workaround for a Webpack bug that doesn't
|
|
10
|
+
* allow exports from multiple files in the same entry.
|
|
11
|
+
* @see https://github.com/webpack/webpack/issues/15936.
|
|
12
|
+
*/
|
|
13
|
+
export default function (this: import('webpack').LoaderContext<{}>, content: string, map: Parameters<import('webpack').LoaderDefinitionFunction>[1]): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* This loader is needed to add additional exports and is a workaround for a Webpack bug that doesn't
|
|
12
|
+
* allow exports from multiple files in the same entry.
|
|
13
|
+
* @see https://github.com/webpack/webpack/issues/15936.
|
|
14
|
+
*/
|
|
15
|
+
function default_1(content, map) {
|
|
16
|
+
const source = `${content}
|
|
17
|
+
|
|
18
|
+
// EXPORTS added by @angular-devkit/build-angular
|
|
19
|
+
export { renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
|
|
20
|
+
`;
|
|
21
|
+
this.callback(null, source, map);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
exports.default = default_1;
|
|
@@ -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 {};
|