@angular-devkit/build-angular 13.0.0-next.6 → 13.0.0-next.7
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 +14 -14
- package/src/babel/plugins/adjust-static-class-members.js +2 -2
- package/src/babel/plugins/adjust-typescript-enums.js +8 -2
- package/src/babel/plugins/pure-toplevel-functions.js +2 -2
- package/src/babel/presets/application.d.ts +14 -0
- package/src/babel/presets/application.js +42 -36
- package/src/babel/webpack-loader.js +50 -5
- package/src/builders/app-shell/index.js +9 -9
- package/src/builders/browser/index.js +42 -52
- package/src/builders/dev-server/index.js +23 -23
- package/src/builders/extract-i18n/index.js +33 -21
- package/src/builders/extract-i18n/ivy-extract-loader.js +34 -8
- package/src/builders/karma/find-tests.js +5 -5
- package/src/builders/karma/index.js +14 -14
- package/src/builders/ng-packagr/index.js +4 -4
- package/src/builders/protractor/index.js +4 -4
- package/src/builders/server/index.js +16 -16
- package/src/sass/worker.js +2 -2
- package/src/utils/build-browser-features.js +2 -2
- package/src/utils/bundle-calculator.js +4 -4
- package/src/utils/cache-path.js +2 -2
- package/src/utils/check-port.js +1 -1
- package/src/utils/copy-assets.js +1 -1
- package/src/utils/delete-output-dir.js +1 -1
- package/src/utils/i18n-inlining.js +1 -1
- package/src/utils/i18n-options.js +26 -50
- package/src/utils/index-file/augment-index-html.js +2 -2
- package/src/utils/index-file/index-html-generator.js +3 -3
- package/src/utils/index-file/inline-fonts.js +4 -4
- package/src/utils/load-esm.d.ts +22 -0
- package/src/utils/load-esm.js +37 -0
- package/src/utils/load-translations.js +21 -8
- package/src/utils/normalize-asset-patterns.js +8 -8
- package/src/utils/normalize-builder-schema.js +4 -4
- package/src/utils/normalize-file-replacements.js +10 -10
- package/src/utils/output-paths.js +3 -3
- package/src/utils/package-chunk-sort.js +1 -1
- package/src/utils/process-bundle.d.ts +0 -1
- package/src/utils/process-bundle.js +44 -12
- package/src/utils/read-tsconfig.js +6 -8
- package/src/utils/run-module-as-observable-fork.js +2 -2
- package/src/utils/service-worker.js +16 -9
- package/src/utils/spinner.js +2 -2
- package/src/utils/version.js +1 -1
- package/src/utils/webpack-browser-config.js +11 -11
- package/src/webpack/configs/browser.js +1 -1
- package/src/webpack/configs/common.js +16 -17
- package/src/webpack/configs/dev-server.d.ts +1 -1
- package/src/webpack/configs/dev-server.js +22 -10
- package/src/webpack/configs/server.js +2 -2
- package/src/webpack/configs/styles.js +4 -4
- package/src/webpack/configs/test.js +2 -2
- package/src/webpack/configs/typescript.js +1 -1
- package/src/webpack/configs/worker.js +1 -1
- package/src/webpack/plugins/any-component-style-budget-checker.js +4 -4
- package/src/webpack/plugins/common-js-usage-warn-plugin.js +2 -2
- package/src/webpack/plugins/css-optimizer-plugin.js +1 -1
- package/src/webpack/plugins/dedupe-module-resolve-plugin.js +1 -1
- package/src/webpack/plugins/esbuild-executor.js +1 -1
- package/src/webpack/plugins/hmr/hmr-accept.js +3 -3
- package/src/webpack/plugins/hmr/hmr-loader.js +1 -1
- package/src/webpack/plugins/index-html-webpack-plugin.js +6 -6
- package/src/webpack/plugins/javascript-optimizer-worker.js +2 -2
- package/src/webpack/plugins/karma/karma.js +4 -4
- package/src/webpack/plugins/postcss-cli-resources.js +1 -1
- package/src/webpack/plugins/scripts-webpack-plugin.js +1 -1
- package/src/webpack/plugins/single-test-transform.js +1 -1
- package/src/webpack/utils/stats.js +6 -6
|
@@ -13,12 +13,12 @@ const normalize_file_replacements_1 = require("./normalize-file-replacements");
|
|
|
13
13
|
const normalize_optimization_1 = require("./normalize-optimization");
|
|
14
14
|
const normalize_source_maps_1 = require("./normalize-source-maps");
|
|
15
15
|
function normalizeBrowserSchema(root, projectRoot, sourceRoot, options) {
|
|
16
|
-
const normalizedSourceMapOptions = normalize_source_maps_1.normalizeSourceMaps(options.sourceMap || false);
|
|
16
|
+
const normalizedSourceMapOptions = (0, normalize_source_maps_1.normalizeSourceMaps)(options.sourceMap || false);
|
|
17
17
|
return {
|
|
18
18
|
...options,
|
|
19
|
-
assets: normalize_asset_patterns_1.normalizeAssetPatterns(options.assets || [], root, projectRoot, sourceRoot),
|
|
20
|
-
fileReplacements: normalize_file_replacements_1.normalizeFileReplacements(options.fileReplacements || [], root),
|
|
21
|
-
optimization: normalize_optimization_1.normalizeOptimization(options.optimization),
|
|
19
|
+
assets: (0, normalize_asset_patterns_1.normalizeAssetPatterns)(options.assets || [], root, projectRoot, sourceRoot),
|
|
20
|
+
fileReplacements: (0, normalize_file_replacements_1.normalizeFileReplacements)(options.fileReplacements || [], root),
|
|
21
|
+
optimization: (0, normalize_optimization_1.normalizeOptimization)(options.optimization),
|
|
22
22
|
sourceMap: normalizedSourceMapOptions,
|
|
23
23
|
preserveSymlinks: options.preserveSymlinks === undefined
|
|
24
24
|
? process.execArgv.includes('--preserve-symlinks')
|
|
@@ -22,11 +22,11 @@ function normalizeFileReplacements(fileReplacements, root) {
|
|
|
22
22
|
}
|
|
23
23
|
const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement, root));
|
|
24
24
|
for (const { replace, with: replacementWith } of normalizedReplacement) {
|
|
25
|
-
if (!fs_1.existsSync(core_1.getSystemPath(replacementWith))) {
|
|
26
|
-
throw new MissingFileReplacementException(core_1.getSystemPath(replacementWith));
|
|
25
|
+
if (!(0, fs_1.existsSync)((0, core_1.getSystemPath)(replacementWith))) {
|
|
26
|
+
throw new MissingFileReplacementException((0, core_1.getSystemPath)(replacementWith));
|
|
27
27
|
}
|
|
28
|
-
if (!fs_1.existsSync(core_1.getSystemPath(replace))) {
|
|
29
|
-
throw new MissingFileReplacementException(core_1.getSystemPath(replace));
|
|
28
|
+
if (!(0, fs_1.existsSync)((0, core_1.getSystemPath)(replace))) {
|
|
29
|
+
throw new MissingFileReplacementException((0, core_1.getSystemPath)(replace));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
return normalizedReplacement;
|
|
@@ -36,22 +36,22 @@ function normalizeFileReplacement(fileReplacement, root) {
|
|
|
36
36
|
let replacePath;
|
|
37
37
|
let withPath;
|
|
38
38
|
if (fileReplacement.src && fileReplacement.replaceWith) {
|
|
39
|
-
replacePath = core_1.normalize(fileReplacement.src);
|
|
40
|
-
withPath = core_1.normalize(fileReplacement.replaceWith);
|
|
39
|
+
replacePath = (0, core_1.normalize)(fileReplacement.src);
|
|
40
|
+
withPath = (0, core_1.normalize)(fileReplacement.replaceWith);
|
|
41
41
|
}
|
|
42
42
|
else if (fileReplacement.replace && fileReplacement.with) {
|
|
43
|
-
replacePath = core_1.normalize(fileReplacement.replace);
|
|
44
|
-
withPath = core_1.normalize(fileReplacement.with);
|
|
43
|
+
replacePath = (0, core_1.normalize)(fileReplacement.replace);
|
|
44
|
+
withPath = (0, core_1.normalize)(fileReplacement.with);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
throw new Error(`Invalid file replacement: ${JSON.stringify(fileReplacement)}`);
|
|
48
48
|
}
|
|
49
49
|
// TODO: For 7.x should this only happen if not absolute?
|
|
50
50
|
if (root) {
|
|
51
|
-
replacePath = core_1.join(root, replacePath);
|
|
51
|
+
replacePath = (0, core_1.join)(root, replacePath);
|
|
52
52
|
}
|
|
53
53
|
if (root) {
|
|
54
|
-
withPath = core_1.join(root, withPath);
|
|
54
|
+
withPath = (0, core_1.join)(root, withPath);
|
|
55
55
|
}
|
|
56
56
|
return { replace: replacePath, with: withPath };
|
|
57
57
|
}
|
|
@@ -14,12 +14,12 @@ function ensureOutputPaths(baseOutputPath, i18n) {
|
|
|
14
14
|
const outputPaths = i18n.shouldInline
|
|
15
15
|
? [...i18n.inlineLocales].map((l) => [
|
|
16
16
|
l,
|
|
17
|
-
i18n.flatOutput ? baseOutputPath : path_1.join(baseOutputPath, l),
|
|
17
|
+
i18n.flatOutput ? baseOutputPath : (0, path_1.join)(baseOutputPath, l),
|
|
18
18
|
])
|
|
19
19
|
: [['', baseOutputPath]];
|
|
20
20
|
for (const [, outputPath] of outputPaths) {
|
|
21
|
-
if (!fs_1.existsSync(outputPath)) {
|
|
22
|
-
fs_1.mkdirSync(outputPath, { recursive: true });
|
|
21
|
+
if (!(0, fs_1.existsSync)(outputPath)) {
|
|
22
|
+
(0, fs_1.mkdirSync)(outputPath, { recursive: true });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
return new Map(outputPaths);
|
|
@@ -12,7 +12,7 @@ const helpers_1 = require("../webpack/utils/helpers");
|
|
|
12
12
|
function generateEntryPoints(options) {
|
|
13
13
|
// Add all styles/scripts, except lazy-loaded ones.
|
|
14
14
|
const extraEntryPoints = (extraEntryPoints, defaultBundleName) => {
|
|
15
|
-
const entryPoints = helpers_1.normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName)
|
|
15
|
+
const entryPoints = (0, helpers_1.normalizeExtraEntryPoints)(extraEntryPoints, defaultBundleName)
|
|
16
16
|
.filter((entry) => entry.inject)
|
|
17
17
|
.map((entry) => entry.bundleName);
|
|
18
18
|
// remove duplicates
|
|
@@ -5,7 +5,6 @@
|
|
|
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
|
-
/// <reference types="packages/angular_devkit/build_angular/src/babel-bazel" />
|
|
9
8
|
export declare function createI18nPlugins(locale: string, translation: unknown | undefined, missingTranslation: 'error' | 'warning' | 'ignore', shouldInline: boolean, localeDataContent?: string): Promise<{
|
|
10
9
|
diagnostics: import("@angular/localize/src/tools/src/diagnostics").Diagnostics;
|
|
11
10
|
plugins: import("@babel/core").PluginObj<import("@babel/core").PluginPass>[];
|
|
@@ -37,30 +37,61 @@ const fs = __importStar(require("fs"));
|
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const worker_threads_1 = require("worker_threads");
|
|
39
39
|
const environment_options_1 = require("./environment-options");
|
|
40
|
+
const load_esm_1 = require("./load-esm");
|
|
40
41
|
// Lazy loaded webpack-sources object
|
|
41
42
|
// Webpack is only imported if needed during the processing
|
|
42
43
|
let webpackSources;
|
|
43
44
|
const { i18n } = (worker_threads_1.workerData || {});
|
|
45
|
+
/**
|
|
46
|
+
* Internal flag to enable the direct usage of the `@angular/localize` translation plugins.
|
|
47
|
+
* Their usage is currently several times slower than the string manipulation method.
|
|
48
|
+
* Future work to optimize the plugins should enable plugin usage as the default.
|
|
49
|
+
*/
|
|
44
50
|
const USE_LOCALIZE_PLUGINS = false;
|
|
51
|
+
/**
|
|
52
|
+
* Cached instance of the `@angular/localize/tools` module.
|
|
53
|
+
* This is used to remove the need to repeatedly import the module per file translation.
|
|
54
|
+
*/
|
|
55
|
+
let localizeToolsModule;
|
|
56
|
+
/**
|
|
57
|
+
* Attempts to load the `@angular/localize/tools` module containing the functionality to
|
|
58
|
+
* perform the file translations.
|
|
59
|
+
* This module must be dynamically loaded as it is an ESM module and this file is CommonJS.
|
|
60
|
+
*/
|
|
61
|
+
async function loadLocalizeTools() {
|
|
62
|
+
if (localizeToolsModule !== undefined) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// All the localize usages are setup to first try the ESM entry point then fallback to the deep imports.
|
|
66
|
+
// This provides interim compatibility while the framework is transitioned to bundled ESM packages.
|
|
67
|
+
// TODO_ESM: Remove all deep imports once `@angular/localize` is published with the `tools` entry point
|
|
68
|
+
try {
|
|
69
|
+
// Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
|
|
70
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
71
|
+
// changed to a direct dynamic import.
|
|
72
|
+
localizeToolsModule = await (0, load_esm_1.loadEsmModule)('@angular/localize/tools');
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
}
|
|
45
76
|
async function createI18nPlugins(locale, translation, missingTranslation, shouldInline, localeDataContent) {
|
|
46
77
|
const plugins = [];
|
|
47
|
-
const localizeDiag = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics')));
|
|
78
|
+
const localizeDiag = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics'))));
|
|
48
79
|
const diagnostics = new localizeDiag.Diagnostics();
|
|
49
80
|
if (shouldInline) {
|
|
50
|
-
const es2015 = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin')));
|
|
81
|
+
const es2015 = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin'))));
|
|
51
82
|
plugins.push(
|
|
52
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
84
|
es2015.makeEs2015TranslatePlugin(diagnostics, (translation || {}), {
|
|
54
85
|
missingTranslation: translation === undefined ? 'ignore' : missingTranslation,
|
|
55
86
|
}));
|
|
56
|
-
const es5 = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin')));
|
|
87
|
+
const es5 = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin'))));
|
|
57
88
|
plugins.push(
|
|
58
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
90
|
es5.makeEs5TranslatePlugin(diagnostics, (translation || {}), {
|
|
60
91
|
missingTranslation: translation === undefined ? 'ignore' : missingTranslation,
|
|
61
92
|
}));
|
|
62
93
|
}
|
|
63
|
-
const inlineLocale = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/locale_plugin')));
|
|
94
|
+
const inlineLocale = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/translate/source_files/locale_plugin'))));
|
|
64
95
|
plugins.push(inlineLocale.makeLocalePlugin(locale));
|
|
65
96
|
if (localeDataContent) {
|
|
66
97
|
plugins.push({
|
|
@@ -87,9 +118,10 @@ async function inlineLocales(options) {
|
|
|
87
118
|
if (!hasLocalizeName && !options.setLocale) {
|
|
88
119
|
return inlineCopyOnly(options);
|
|
89
120
|
}
|
|
121
|
+
await loadLocalizeTools();
|
|
90
122
|
let ast;
|
|
91
123
|
try {
|
|
92
|
-
ast = core_1.parseSync(options.code, {
|
|
124
|
+
ast = (0, core_1.parseSync)(options.code, {
|
|
93
125
|
babelrc: false,
|
|
94
126
|
configFile: false,
|
|
95
127
|
sourceType: 'script',
|
|
@@ -126,7 +158,7 @@ async function inlineLocales(options) {
|
|
|
126
158
|
}
|
|
127
159
|
}
|
|
128
160
|
const { diagnostics: localeDiagnostics, plugins } = await createI18nPlugins(locale, translations, isSourceLocale ? 'ignore' : options.missingTranslation || 'warning', true, localeDataContent);
|
|
129
|
-
const transformResult = await core_1.transformFromAstSync(ast, options.code, {
|
|
161
|
+
const transformResult = await (0, core_1.transformFromAstSync)(ast, options.code, {
|
|
130
162
|
filename: options.filename,
|
|
131
163
|
// using false ensures that babel will NOT search and process sourcemap comments (large memory usage)
|
|
132
164
|
// The types do not include the false option even though it is valid
|
|
@@ -145,7 +177,7 @@ async function inlineLocales(options) {
|
|
|
145
177
|
const outputPath = path.join(options.outputPath, i18n.flatOutput ? '' : locale, options.filename);
|
|
146
178
|
fs.writeFileSync(outputPath, transformResult.code);
|
|
147
179
|
if (options.map && transformResult.map) {
|
|
148
|
-
const outputMap = remapping_1.default([transformResult.map, options.map], () => null);
|
|
180
|
+
const outputMap = (0, remapping_1.default)([transformResult.map, options.map], () => null);
|
|
149
181
|
fs.writeFileSync(outputPath + '.map', JSON.stringify(outputMap));
|
|
150
182
|
}
|
|
151
183
|
}
|
|
@@ -157,8 +189,8 @@ async function inlineLocalesDirect(ast, options) {
|
|
|
157
189
|
return { file: options.filename, diagnostics: [], count: 0 };
|
|
158
190
|
}
|
|
159
191
|
const { default: generate } = await Promise.resolve().then(() => __importStar(require('@babel/generator')));
|
|
160
|
-
const utils = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/source_file_utils')));
|
|
161
|
-
const localizeDiag = await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics')));
|
|
192
|
+
const utils = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/source_file_utils'))));
|
|
193
|
+
const localizeDiag = localizeToolsModule !== null && localizeToolsModule !== void 0 ? localizeToolsModule : (await Promise.resolve().then(() => __importStar(require('@angular/localize/src/tools/src/diagnostics'))));
|
|
162
194
|
const diagnostics = new localizeDiag.Diagnostics();
|
|
163
195
|
const positions = findLocalizePositions(ast, options, utils);
|
|
164
196
|
if (positions.length === 0 && !options.setLocale) {
|
|
@@ -235,7 +267,7 @@ function findLocalizePositions(ast, options, utils) {
|
|
|
235
267
|
const { File } = require('@babel/core');
|
|
236
268
|
const file = new File({}, { code: options.code, ast });
|
|
237
269
|
if (options.es5) {
|
|
238
|
-
core_1.traverse(file.ast, {
|
|
270
|
+
(0, core_1.traverse)(file.ast, {
|
|
239
271
|
CallExpression(path) {
|
|
240
272
|
const callee = path.get('callee');
|
|
241
273
|
if (callee.isIdentifier() &&
|
|
@@ -255,7 +287,7 @@ function findLocalizePositions(ast, options, utils) {
|
|
|
255
287
|
});
|
|
256
288
|
}
|
|
257
289
|
else {
|
|
258
|
-
core_1.traverse(file.ast, {
|
|
290
|
+
(0, core_1.traverse)(file.ast, {
|
|
259
291
|
TaggedTemplateExpression(path) {
|
|
260
292
|
if (core_1.types.isIdentifier(path.node.tag) && path.node.tag.name === localizeName) {
|
|
261
293
|
const [messageParts, expressions] = unwrapTemplateLiteral(path, utils);
|
|
@@ -287,7 +319,7 @@ async function loadLocaleData(path, optimize, es5) {
|
|
|
287
319
|
// The path is validated during option processing before the build starts
|
|
288
320
|
const content = fs.readFileSync(path, 'utf8');
|
|
289
321
|
// Downlevel and optimize the data
|
|
290
|
-
const transformResult = await core_1.transformAsync(content, {
|
|
322
|
+
const transformResult = await (0, core_1.transformAsync)(content, {
|
|
291
323
|
filename: path,
|
|
292
324
|
// The types do not include the false option even though it is valid
|
|
293
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -28,6 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.readTsconfig = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
|
+
const load_esm_1 = require("./load-esm");
|
|
31
32
|
/**
|
|
32
33
|
* Reads and parses a given TsConfig file.
|
|
33
34
|
*
|
|
@@ -37,15 +38,12 @@ const path = __importStar(require("path"));
|
|
|
37
38
|
*/
|
|
38
39
|
async function readTsconfig(tsconfigPath, workspaceRoot) {
|
|
39
40
|
const tsConfigFullPath = workspaceRoot ? path.resolve(workspaceRoot, tsconfigPath) : tsconfigPath;
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
// this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
45
|
-
// Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
46
|
-
// be dropped.
|
|
47
|
-
const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
|
|
41
|
+
// Load ESM `@angular/compiler-cli` using the TypeScript dynamic import workaround.
|
|
42
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
43
|
+
// changed to a direct dynamic import.
|
|
44
|
+
const compilerCliModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
|
|
48
45
|
// If it is not ESM then the functions needed will be stored in the `default` property.
|
|
46
|
+
// TODO_ESM: This can be removed once `@angular/compiler-cli` is ESM only.
|
|
49
47
|
const { formatDiagnostics, readConfiguration } = (compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default);
|
|
50
48
|
const configResult = readConfiguration(tsConfigFullPath);
|
|
51
49
|
if (configResult.errors && configResult.errors.length) {
|
|
@@ -16,7 +16,7 @@ function runModuleAsObservableFork(cwd, modulePath, exportName,
|
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
17
|
args) {
|
|
18
18
|
return new rxjs_1.Observable((obs) => {
|
|
19
|
-
const workerPath = path_1.resolve(__dirname, './run-module-worker.js');
|
|
19
|
+
const workerPath = (0, path_1.resolve)(__dirname, './run-module-worker.js');
|
|
20
20
|
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug(?:-brk|-port)/;
|
|
21
21
|
const execArgv = process.execArgv.filter((arg) => {
|
|
22
22
|
// Remove debug args.
|
|
@@ -35,7 +35,7 @@ args) {
|
|
|
35
35
|
// logger.error, // make it a stream
|
|
36
36
|
// ];
|
|
37
37
|
// }
|
|
38
|
-
const forkedProcess = child_process_1.fork(workerPath, undefined, forkOptions);
|
|
38
|
+
const forkedProcess = (0, child_process_1.fork)(workerPath, undefined, forkOptions);
|
|
39
39
|
// Cleanup.
|
|
40
40
|
const killForkedProcess = () => {
|
|
41
41
|
if (forkedProcess && forkedProcess.pid) {
|
|
@@ -32,6 +32,8 @@ const crypto = __importStar(require("crypto"));
|
|
|
32
32
|
const fs_1 = require("fs");
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const stream_1 = require("stream");
|
|
35
|
+
const url_1 = require("url");
|
|
36
|
+
const load_esm_1 = require("./load-esm");
|
|
35
37
|
class CliFilesystem {
|
|
36
38
|
constructor(base) {
|
|
37
39
|
this.base = base;
|
|
@@ -45,7 +47,7 @@ class CliFilesystem {
|
|
|
45
47
|
hash(file) {
|
|
46
48
|
return new Promise((resolve, reject) => {
|
|
47
49
|
const hash = crypto.createHash('sha1').setEncoding('hex');
|
|
48
|
-
stream_1.pipeline(fs_1.createReadStream(this._resolve(file)), hash, (error) => error ? reject(error) : resolve(hash.read()));
|
|
50
|
+
(0, stream_1.pipeline)((0, fs_1.createReadStream)(this._resolve(file)), hash, (error) => error ? reject(error) : resolve(hash.read()));
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
write(file, content) {
|
|
@@ -72,22 +74,24 @@ class CliFilesystem {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
async function augmentAppWithServiceWorker(projectRoot, appRoot, outputPath, baseHref, ngswConfigPath) {
|
|
75
|
-
const distPath = core_1.getSystemPath(core_1.normalize(outputPath));
|
|
76
|
-
const systemProjectRoot = core_1.getSystemPath(projectRoot);
|
|
77
|
+
const distPath = (0, core_1.getSystemPath)((0, core_1.normalize)(outputPath));
|
|
78
|
+
const systemProjectRoot = (0, core_1.getSystemPath)(projectRoot);
|
|
77
79
|
// Find the service worker package
|
|
78
80
|
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js', {
|
|
79
81
|
paths: [systemProjectRoot],
|
|
80
82
|
});
|
|
81
|
-
|
|
83
|
+
// Absolute paths on Windows must be `file://` URLs when using ESM. Otherwise,
|
|
84
|
+
// `c:` would be interpreted as a protocol instead of a drive letter.
|
|
85
|
+
const swConfigPath = (0, url_1.pathToFileURL)(require.resolve('@angular/service-worker/config', {
|
|
82
86
|
paths: [systemProjectRoot],
|
|
83
|
-
});
|
|
87
|
+
}));
|
|
84
88
|
// Determine the configuration file path
|
|
85
89
|
let configPath;
|
|
86
90
|
if (ngswConfigPath) {
|
|
87
|
-
configPath = core_1.getSystemPath(core_1.normalize(ngswConfigPath));
|
|
91
|
+
configPath = (0, core_1.getSystemPath)((0, core_1.normalize)(ngswConfigPath));
|
|
88
92
|
}
|
|
89
93
|
else {
|
|
90
|
-
configPath = path.join(core_1.getSystemPath(appRoot), 'ngsw-config.json');
|
|
94
|
+
configPath = path.join((0, core_1.getSystemPath)(appRoot), 'ngsw-config.json');
|
|
91
95
|
}
|
|
92
96
|
// Read the configuration file
|
|
93
97
|
let config;
|
|
@@ -98,15 +102,18 @@ async function augmentAppWithServiceWorker(projectRoot, appRoot, outputPath, bas
|
|
|
98
102
|
catch (error) {
|
|
99
103
|
if (error.code === 'ENOENT') {
|
|
100
104
|
throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
|
|
101
|
-
` in the ${core_1.getSystemPath(appRoot)} folder. Either provide one or` +
|
|
105
|
+
` in the ${(0, core_1.getSystemPath)(appRoot)} folder. Either provide one or` +
|
|
102
106
|
' disable Service Worker in the angular.json configuration file.');
|
|
103
107
|
}
|
|
104
108
|
else {
|
|
105
109
|
throw error;
|
|
106
110
|
}
|
|
107
111
|
}
|
|
112
|
+
// Load ESM `@angular/service-worker/config` using the TypeScript dynamic import workaround.
|
|
113
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
114
|
+
// changed to a direct dynamic import.
|
|
115
|
+
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)(swConfigPath)).Generator;
|
|
108
116
|
// Generate the manifest
|
|
109
|
-
const GeneratorConstructor = require(swConfigPath).Generator;
|
|
110
117
|
const generator = new GeneratorConstructor(new CliFilesystem(distPath), baseHref);
|
|
111
118
|
const output = await generator.process(config);
|
|
112
119
|
// Write the manifest
|
package/src/utils/spinner.js
CHANGED
|
@@ -24,8 +24,8 @@ class Spinner {
|
|
|
24
24
|
constructor(text) {
|
|
25
25
|
/** When false, only fail messages will be displayed. */
|
|
26
26
|
this.enabled = true;
|
|
27
|
-
_Spinner_isTTY.set(this, tty_1.isTTY());
|
|
28
|
-
this.spinner = ora_1.default({
|
|
27
|
+
_Spinner_isTTY.set(this, (0, tty_1.isTTY)());
|
|
28
|
+
this.spinner = (0, ora_1.default)({
|
|
29
29
|
text,
|
|
30
30
|
// The below 2 options are needed because otherwise CTRL+C will be delayed
|
|
31
31
|
// when the underlying process is sync.
|
package/src/utils/version.js
CHANGED
|
@@ -51,7 +51,7 @@ function assertCompatibleAngularVersion(projectRoot) {
|
|
|
51
51
|
}
|
|
52
52
|
const supportedAngularSemver = require('../../package.json')['peerDependencies']['@angular/compiler-cli'];
|
|
53
53
|
const angularVersion = new semver_1.SemVer(angularPkgJson['version']);
|
|
54
|
-
if (!semver_1.satisfies(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
|
|
54
|
+
if (!(0, semver_1.satisfies)(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
|
|
55
55
|
console.error(core_1.tags.stripIndents `
|
|
56
56
|
This version of CLI is only compatible with Angular versions ${supportedAngularSemver},
|
|
57
57
|
but Angular version ${angularVersion} was found instead.
|
|
@@ -42,7 +42,7 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
|
|
|
42
42
|
throw new Error(`The 'buildOptimizer' option cannot be used without 'aot'.`);
|
|
43
43
|
}
|
|
44
44
|
const tsConfigPath = path.resolve(workspaceRoot, options.tsConfig);
|
|
45
|
-
const tsConfig = await read_tsconfig_1.readTsconfig(tsConfigPath);
|
|
45
|
+
const tsConfig = await (0, read_tsconfig_1.readTsconfig)(tsConfigPath);
|
|
46
46
|
const ts = await Promise.resolve().then(() => __importStar(require('typescript')));
|
|
47
47
|
const scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
|
|
48
48
|
const buildOptions = { ...options, ...extraBuildOptions };
|
|
@@ -56,15 +56,15 @@ async function generateWebpackConfig(workspaceRoot, projectRoot, sourceRoot, opt
|
|
|
56
56
|
tsConfigPath,
|
|
57
57
|
scriptTarget,
|
|
58
58
|
};
|
|
59
|
-
wco.buildOptions.progress = utils_1.defaultProgress(wco.buildOptions.progress);
|
|
59
|
+
wco.buildOptions.progress = (0, utils_1.defaultProgress)(wco.buildOptions.progress);
|
|
60
60
|
const partials = await Promise.all(webpackPartialGenerator(wco));
|
|
61
|
-
const webpackConfig = webpack_merge_1.merge(partials);
|
|
61
|
+
const webpackConfig = (0, webpack_merge_1.merge)(partials);
|
|
62
62
|
return webpackConfig;
|
|
63
63
|
}
|
|
64
64
|
exports.generateWebpackConfig = generateWebpackConfig;
|
|
65
65
|
async function generateI18nBrowserWebpackConfigFromContext(options, context, webpackPartialGenerator, extraBuildOptions = {}) {
|
|
66
66
|
var _a;
|
|
67
|
-
const { buildOptions, i18n } = await i18n_options_1.configureI18nBuild(context, options);
|
|
67
|
+
const { buildOptions, i18n } = await (0, i18n_options_1.configureI18nBuild)(context, options);
|
|
68
68
|
let target = typescript_1.ScriptTarget.ES5;
|
|
69
69
|
const result = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
|
|
70
70
|
target = wco.scriptTarget;
|
|
@@ -111,15 +111,15 @@ async function generateBrowserWebpackConfigFromContext(options, context, webpack
|
|
|
111
111
|
if (!projectName) {
|
|
112
112
|
throw new Error('The builder requires a target.');
|
|
113
113
|
}
|
|
114
|
-
const workspaceRoot = core_1.normalize(context.workspaceRoot);
|
|
114
|
+
const workspaceRoot = (0, core_1.normalize)(context.workspaceRoot);
|
|
115
115
|
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
116
|
-
const projectRoot = core_1.resolve(workspaceRoot, core_1.normalize(projectMetadata.root || ''));
|
|
116
|
+
const projectRoot = (0, core_1.resolve)(workspaceRoot, (0, core_1.normalize)(projectMetadata.root || ''));
|
|
117
117
|
const projectSourceRoot = projectMetadata.sourceRoot;
|
|
118
118
|
const sourceRoot = projectSourceRoot
|
|
119
|
-
? core_1.resolve(workspaceRoot, core_1.normalize(projectSourceRoot))
|
|
119
|
+
? (0, core_1.resolve)(workspaceRoot, (0, core_1.normalize)(projectSourceRoot))
|
|
120
120
|
: undefined;
|
|
121
|
-
const normalizedOptions = utils_1.normalizeBrowserSchema(workspaceRoot, projectRoot, sourceRoot, options);
|
|
122
|
-
const config = await generateWebpackConfig(core_1.getSystemPath(workspaceRoot), core_1.getSystemPath(projectRoot), sourceRoot && core_1.getSystemPath(sourceRoot), normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
|
|
121
|
+
const normalizedOptions = (0, utils_1.normalizeBrowserSchema)(workspaceRoot, projectRoot, sourceRoot, options);
|
|
122
|
+
const config = await generateWebpackConfig((0, core_1.getSystemPath)(workspaceRoot), (0, core_1.getSystemPath)(projectRoot), sourceRoot && (0, core_1.getSystemPath)(sourceRoot), normalizedOptions, webpackPartialGenerator, context.logger, extraBuildOptions);
|
|
123
123
|
// If builder watch support is present in the context, add watch plugin
|
|
124
124
|
// This is internal only and currently only used for testing
|
|
125
125
|
const watcherFactory = context.watcherFactory;
|
|
@@ -131,8 +131,8 @@ async function generateBrowserWebpackConfigFromContext(options, context, webpack
|
|
|
131
131
|
}
|
|
132
132
|
return {
|
|
133
133
|
config,
|
|
134
|
-
projectRoot: core_1.getSystemPath(projectRoot),
|
|
135
|
-
projectSourceRoot: sourceRoot && core_1.getSystemPath(sourceRoot),
|
|
134
|
+
projectRoot: (0, core_1.getSystemPath)(projectRoot),
|
|
135
|
+
projectSourceRoot: sourceRoot && (0, core_1.getSystemPath)(sourceRoot),
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
exports.generateBrowserWebpackConfigFromContext = generateBrowserWebpackConfigFromContext;
|
|
@@ -22,7 +22,7 @@ function getBrowserConfig(wco) {
|
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
24
|
if (scriptsSourceMap || stylesSourceMap) {
|
|
25
|
-
extraPlugins.push(helpers_1.getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, hiddenSourceMap, false));
|
|
25
|
+
extraPlugins.push((0, helpers_1.getSourceMapDevTool)(scriptsSourceMap, stylesSourceMap, hiddenSourceMap, false));
|
|
26
26
|
}
|
|
27
27
|
let crossOriginLoading = false;
|
|
28
28
|
if (subresourceIntegrity && crossOrigin === 'none') {
|
|
@@ -39,6 +39,7 @@ const webpack_1 = require("webpack");
|
|
|
39
39
|
const utils_1 = require("../../utils");
|
|
40
40
|
const cache_path_1 = require("../../utils/cache-path");
|
|
41
41
|
const environment_options_1 = require("../../utils/environment-options");
|
|
42
|
+
const load_esm_1 = require("../../utils/load-esm");
|
|
42
43
|
const spinner_1 = require("../../utils/spinner");
|
|
43
44
|
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
44
45
|
const plugins_1 = require("../plugins");
|
|
@@ -52,18 +53,15 @@ async function getCommonConfig(wco) {
|
|
|
52
53
|
const extraPlugins = [];
|
|
53
54
|
const extraRules = [];
|
|
54
55
|
const entryPoints = {};
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
// this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
60
|
-
// Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
61
|
-
// be dropped.
|
|
62
|
-
const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();
|
|
56
|
+
// Load ESM `@angular/compiler-cli` using the TypeScript dynamic import workaround.
|
|
57
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
58
|
+
// changed to a direct dynamic import.
|
|
59
|
+
const compilerCliModule = await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
|
|
63
60
|
// If it is not ESM then the values needed will be stored in the `default` property.
|
|
61
|
+
// TODO_ESM: This can be removed once `@angular/compiler-cli` is ESM only.
|
|
64
62
|
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT, VERSION: NG_VERSION, } = (compilerCliModule.GLOBAL_DEFS_FOR_TERSER ? compilerCliModule : compilerCliModule.default);
|
|
65
63
|
// determine hashing format
|
|
66
|
-
const hashFormat = helpers_1.getOutputHashFormat(buildOptions.outputHashing || 'none');
|
|
64
|
+
const hashFormat = (0, helpers_1.getOutputHashFormat)(buildOptions.outputHashing || 'none');
|
|
67
65
|
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(projectRoot);
|
|
68
66
|
if (buildOptions.progress) {
|
|
69
67
|
const spinner = new spinner_1.Spinner();
|
|
@@ -117,10 +115,10 @@ async function getCommonConfig(wco) {
|
|
|
117
115
|
}));
|
|
118
116
|
}
|
|
119
117
|
// process global scripts
|
|
120
|
-
const globalScriptsByBundleName = helpers_1.normalizeExtraEntryPoints(buildOptions.scripts, 'scripts').reduce((prev, curr) => {
|
|
118
|
+
const globalScriptsByBundleName = (0, helpers_1.normalizeExtraEntryPoints)(buildOptions.scripts, 'scripts').reduce((prev, curr) => {
|
|
121
119
|
const { bundleName, inject, input } = curr;
|
|
122
120
|
let resolvedPath = path.resolve(root, input);
|
|
123
|
-
if (!fs_1.existsSync(resolvedPath)) {
|
|
121
|
+
if (!(0, fs_1.existsSync)(resolvedPath)) {
|
|
124
122
|
try {
|
|
125
123
|
resolvedPath = require.resolve(input, { paths: [root] });
|
|
126
124
|
}
|
|
@@ -225,12 +223,12 @@ async function getCommonConfig(wco) {
|
|
|
225
223
|
try {
|
|
226
224
|
await fs_1.promises.mkdir(path.dirname(statsOutputPath), { recursive: true });
|
|
227
225
|
await new Promise((resolve, reject) => stringifyStream(data)
|
|
228
|
-
.pipe(fs_1.createWriteStream(statsOutputPath))
|
|
226
|
+
.pipe((0, fs_1.createWriteStream)(statsOutputPath))
|
|
229
227
|
.on('close', resolve)
|
|
230
228
|
.on('error', reject));
|
|
231
229
|
}
|
|
232
230
|
catch (error) {
|
|
233
|
-
webpack_diagnostics_1.addError(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
|
|
231
|
+
(0, webpack_diagnostics_1.addError)(stats.compilation, `Unable to write stats file: ${error.message || 'unknown error'}`);
|
|
234
232
|
}
|
|
235
233
|
});
|
|
236
234
|
}
|
|
@@ -285,6 +283,7 @@ async function getCommonConfig(wco) {
|
|
|
285
283
|
context: root,
|
|
286
284
|
entry: entryPoints,
|
|
287
285
|
output: {
|
|
286
|
+
hashFunction: 'xxhash64',
|
|
288
287
|
clean: (_a = buildOptions.deleteOutputPath) !== null && _a !== void 0 ? _a : true,
|
|
289
288
|
path: path.resolve(root, buildOptions.outputPath),
|
|
290
289
|
publicPath: (_b = buildOptions.deployUrl) !== null && _b !== void 0 ? _b : '',
|
|
@@ -292,7 +291,7 @@ async function getCommonConfig(wco) {
|
|
|
292
291
|
chunkFilename: `[name]${hashFormat.chunk}.js`,
|
|
293
292
|
},
|
|
294
293
|
watch: buildOptions.watch,
|
|
295
|
-
watchOptions: helpers_1.getWatchOptions(buildOptions.poll),
|
|
294
|
+
watchOptions: (0, helpers_1.getWatchOptions)(buildOptions.poll),
|
|
296
295
|
performance: {
|
|
297
296
|
hints: false,
|
|
298
297
|
},
|
|
@@ -331,7 +330,7 @@ async function getCommonConfig(wco) {
|
|
|
331
330
|
{
|
|
332
331
|
loader: require.resolve('../../babel/webpack-loader'),
|
|
333
332
|
options: {
|
|
334
|
-
cacheDirectory: cache_path_1.findCachePath('babel-webpack'),
|
|
333
|
+
cacheDirectory: (0, cache_path_1.findCachePath)('babel-webpack'),
|
|
335
334
|
scriptTarget: wco.scriptTarget,
|
|
336
335
|
aot: buildOptions.aot,
|
|
337
336
|
optimize: buildOptions.buildOptimizer,
|
|
@@ -371,12 +370,12 @@ function getCacheSettings(wco, supportedBrowsers, angularVersion) {
|
|
|
371
370
|
const packageVersion = require('../../../package.json').version;
|
|
372
371
|
return {
|
|
373
372
|
type: 'filesystem',
|
|
374
|
-
cacheDirectory: cache_path_1.findCachePath('angular-webpack'),
|
|
373
|
+
cacheDirectory: (0, cache_path_1.findCachePath)('angular-webpack'),
|
|
375
374
|
maxMemoryGenerations: 1,
|
|
376
375
|
// We use the versions and build options as the cache name. The Webpack configurations are too
|
|
377
376
|
// dynamic and shared among different build types: test, build and serve.
|
|
378
377
|
// None of which are "named".
|
|
379
|
-
name: crypto_1.createHash('sha1')
|
|
378
|
+
name: (0, crypto_1.createHash)('sha1')
|
|
380
379
|
.update(angularVersion)
|
|
381
380
|
.update(packageVersion)
|
|
382
381
|
.update(wco.projectRoot)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
9
|
import * as webpack from 'webpack';
|
|
10
10
|
import { WebpackConfigOptions, WebpackDevServerOptions } from '../../utils/build-options';
|
|
11
|
-
export declare function getDevServerConfig(wco: WebpackConfigOptions<WebpackDevServerOptions>): webpack.Configuration
|
|
11
|
+
export declare function getDevServerConfig(wco: WebpackConfigOptions<WebpackDevServerOptions>): Promise<webpack.Configuration>;
|
|
12
12
|
/**
|
|
13
13
|
* Resolve and build a URL _path_ that will be the root of the server. This resolved base href and
|
|
14
14
|
* deploy URL from the browser options and returns a path from the root.
|
|
@@ -31,16 +31,17 @@ const core_1 = require("@angular-devkit/core");
|
|
|
31
31
|
const fs_1 = require("fs");
|
|
32
32
|
const path_1 = require("path");
|
|
33
33
|
const url = __importStar(require("url"));
|
|
34
|
+
const load_esm_1 = require("../../utils/load-esm");
|
|
34
35
|
const webpack_browser_config_1 = require("../../utils/webpack-browser-config");
|
|
35
36
|
const hmr_loader_1 = require("../plugins/hmr/hmr-loader");
|
|
36
|
-
function getDevServerConfig(wco) {
|
|
37
|
+
async function getDevServerConfig(wco) {
|
|
37
38
|
const { buildOptions: { host, port, index, headers, watch, hmr, main, liveReload, proxyConfig }, logger, root, } = wco;
|
|
38
39
|
const servePath = buildServePath(wco.buildOptions, logger);
|
|
39
40
|
const extraRules = [];
|
|
40
41
|
if (hmr) {
|
|
41
42
|
extraRules.push({
|
|
42
43
|
loader: hmr_loader_1.HmrLoader,
|
|
43
|
-
include: [main].map((p) => path_1.resolve(wco.root, p)),
|
|
44
|
+
include: [main].map((p) => (0, path_1.resolve)(wco.root, p)),
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
const extraPlugins = [];
|
|
@@ -71,7 +72,7 @@ function getDevServerConfig(wco) {
|
|
|
71
72
|
...headers,
|
|
72
73
|
},
|
|
73
74
|
historyApiFallback: !!index && {
|
|
74
|
-
index: path_1.posix.join(servePath, webpack_browser_config_1.getIndexOutputFile(index)),
|
|
75
|
+
index: path_1.posix.join(servePath, (0, webpack_browser_config_1.getIndexOutputFile)(index)),
|
|
75
76
|
disableDotRule: true,
|
|
76
77
|
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
77
78
|
rewrites: [
|
|
@@ -96,7 +97,7 @@ function getDevServerConfig(wco) {
|
|
|
96
97
|
},
|
|
97
98
|
liveReload,
|
|
98
99
|
hot: hmr && !liveReload ? 'only' : hmr,
|
|
99
|
-
proxy: addProxyConfig(root, proxyConfig),
|
|
100
|
+
proxy: await addProxyConfig(root, proxyConfig),
|
|
100
101
|
client: {
|
|
101
102
|
logging: 'info',
|
|
102
103
|
webSocketURL: getPublicHostOptions(wco.buildOptions, webSocketPath),
|
|
@@ -142,8 +143,8 @@ function getSslConfig(root, options) {
|
|
|
142
143
|
const { ssl, sslCert, sslKey } = options;
|
|
143
144
|
if (ssl && sslCert && sslKey) {
|
|
144
145
|
return {
|
|
145
|
-
key:
|
|
146
|
-
cert:
|
|
146
|
+
key: (0, path_1.resolve)(root, sslKey),
|
|
147
|
+
cert: (0, path_1.resolve)(root, sslCert),
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
return ssl;
|
|
@@ -152,13 +153,24 @@ function getSslConfig(root, options) {
|
|
|
152
153
|
* Private method to enhance a webpack config with Proxy configuration.
|
|
153
154
|
* @private
|
|
154
155
|
*/
|
|
155
|
-
function addProxyConfig(root, proxyConfig) {
|
|
156
|
+
async function addProxyConfig(root, proxyConfig) {
|
|
156
157
|
if (!proxyConfig) {
|
|
157
158
|
return undefined;
|
|
158
159
|
}
|
|
159
|
-
const proxyPath = path_1.resolve(root, proxyConfig);
|
|
160
|
-
if (fs_1.existsSync(proxyPath)) {
|
|
161
|
-
|
|
160
|
+
const proxyPath = (0, path_1.resolve)(root, proxyConfig);
|
|
161
|
+
if ((0, fs_1.existsSync)(proxyPath)) {
|
|
162
|
+
try {
|
|
163
|
+
return require(proxyPath);
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
if (e.code === 'ERR_REQUIRE_ESM') {
|
|
167
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
168
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
169
|
+
// changed to a direct dynamic import.
|
|
170
|
+
return (await (0, load_esm_1.loadEsmModule)(url.pathToFileURL(proxyPath))).default;
|
|
171
|
+
}
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
162
174
|
}
|
|
163
175
|
throw new Error('Proxy config file ' + proxyPath + ' does not exist.');
|
|
164
176
|
}
|