@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.
Files changed (75) hide show
  1. package/package.json +15 -17
  2. package/src/babel/presets/application.d.ts +1 -2
  3. package/src/babel/presets/application.js +1 -4
  4. package/src/babel/webpack-loader.js +8 -22
  5. package/src/builders/app-shell/index.js +16 -8
  6. package/src/builders/browser/index.d.ts +1 -1
  7. package/src/builders/browser/index.js +4 -16
  8. package/src/builders/browser/schema.d.ts +6 -2
  9. package/src/builders/browser/schema.json +18 -4
  10. package/src/builders/browser-esbuild/compiler-plugin.d.ts +1 -0
  11. package/src/builders/browser-esbuild/compiler-plugin.js +20 -17
  12. package/src/builders/browser-esbuild/experimental-warnings.js +0 -1
  13. package/src/builders/browser-esbuild/index.js +18 -5
  14. package/src/builders/browser-esbuild/options.js +6 -1
  15. package/src/builders/browser-esbuild/schema.d.ts +8 -6
  16. package/src/builders/browser-esbuild/schema.json +29 -34
  17. package/src/builders/browser-esbuild/stylesheets.d.ts +1 -0
  18. package/src/builders/browser-esbuild/stylesheets.js +1 -0
  19. package/src/builders/extract-i18n/index.js +1 -1
  20. package/src/builders/karma/find-tests-plugin.d.ts +19 -0
  21. package/src/builders/karma/{find-tests.js → find-tests-plugin.js} +49 -5
  22. package/src/builders/karma/index.js +40 -38
  23. package/src/builders/karma/schema.d.ts +7 -3
  24. package/src/builders/karma/schema.json +20 -5
  25. package/src/builders/server/index.d.ts +1 -1
  26. package/src/builders/server/index.js +42 -10
  27. package/src/builders/server/platform-server-exports-loader.d.ts +13 -0
  28. package/src/builders/server/platform-server-exports-loader.js +24 -0
  29. package/src/builders/server/schema.d.ts +0 -5
  30. package/src/builders/server/schema.json +0 -5
  31. package/src/sass/sass-service-legacy.d.ts +51 -0
  32. package/src/sass/sass-service-legacy.js +175 -0
  33. package/src/sass/sass-service.d.ts +6 -9
  34. package/src/sass/sass-service.js +69 -52
  35. package/src/{builders/karma/find-tests.d.ts → sass/worker-legacy.d.ts} +1 -1
  36. package/src/sass/worker-legacy.js +44 -0
  37. package/src/sass/worker.js +64 -14
  38. package/src/utils/build-options.d.ts +2 -4
  39. package/src/utils/environment-options.d.ts +1 -0
  40. package/src/utils/environment-options.js +11 -1
  41. package/src/utils/esbuild-targets.d.ts +12 -0
  42. package/src/utils/esbuild-targets.js +39 -0
  43. package/src/utils/i18n-inlining.d.ts +1 -1
  44. package/src/utils/i18n-inlining.js +3 -4
  45. package/src/utils/normalize-builder-schema.d.ts +3 -2
  46. package/src/utils/normalize-builder-schema.js +5 -4
  47. package/src/utils/normalize-polyfills.d.ts +8 -0
  48. package/src/utils/normalize-polyfills.js +24 -0
  49. package/src/utils/process-bundle.d.ts +0 -1
  50. package/src/utils/process-bundle.js +29 -57
  51. package/src/utils/supported-browsers.d.ts +2 -1
  52. package/src/utils/supported-browsers.js +18 -2
  53. package/src/utils/webpack-browser-config.d.ts +0 -2
  54. package/src/utils/webpack-browser-config.js +2 -8
  55. package/src/utils/webpack-diagnostics.d.ts +1 -1
  56. package/src/utils/webpack-diagnostics.js +2 -3
  57. package/src/webpack/configs/common.js +37 -24
  58. package/src/webpack/configs/dev-server.js +1 -1
  59. package/src/webpack/configs/styles.js +63 -80
  60. package/src/webpack/plugins/any-component-style-budget-checker.js +1 -1
  61. package/src/webpack/plugins/css-optimizer-plugin.d.ts +0 -1
  62. package/src/webpack/plugins/css-optimizer-plugin.js +3 -26
  63. package/src/webpack/plugins/hmr/hmr-loader.d.ts +1 -1
  64. package/src/webpack/plugins/hmr/hmr-loader.js +2 -5
  65. package/src/webpack/plugins/javascript-optimizer-plugin.d.ts +4 -6
  66. package/src/webpack/plugins/javascript-optimizer-plugin.js +7 -16
  67. package/src/webpack/plugins/javascript-optimizer-worker.d.ts +3 -2
  68. package/src/webpack/plugins/javascript-optimizer-worker.js +21 -46
  69. package/src/webpack/plugins/karma/karma.js +4 -5
  70. package/src/webpack/plugins/transfer-size-plugin.js +2 -1
  71. package/src/webpack/plugins/typescript.js +14 -25
  72. package/src/webpack/utils/helpers.d.ts +0 -3
  73. package/src/webpack/utils/helpers.js +1 -36
  74. package/src/webpack/plugins/single-test-transform.d.ts +0 -27
  75. 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
- "type": "string",
21
- "description": "The full path for the polyfills file, relative to the current workspace."
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|styl)$"
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|styl)$"
108
+ "pattern": "\\.(?:css|scss|sass|less)$"
95
109
  }
96
110
  ]
97
111
  }
@@ -461,38 +475,19 @@
461
475
  ]
462
476
  },
463
477
  "fileReplacement": {
464
- "oneOf": [
465
- {
466
- "type": "object",
467
- "properties": {
468
- "src": {
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": "object",
482
- "properties": {
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",
@@ -17,6 +17,7 @@ export interface BundleStylesheetOptions {
17
17
  };
18
18
  includePaths?: string[];
19
19
  externalDependencies?: string[];
20
+ target: string[];
20
21
  }
21
22
  /**
22
23
  * Bundle a stylesheet that exists as a file on the filesystem.
@@ -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'],
@@ -202,7 +202,7 @@ async function execute(options, context, transforms) {
202
202
  module: {
203
203
  rules: [
204
204
  {
205
- test: /\.(css|scss|sass|styl|less)$/,
205
+ test: /\.(css|scss|sass|less)$/,
206
206
  loader: require.resolve('./empty-loader'),
207
207
  },
208
208
  ],
@@ -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.findTests = void 0;
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((0, path_1.join)(projectSourceRoot, potentialSpec))) {
68
- return [normalizePath(potentialSpec)];
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 find_tests_1 = require("./find-tests");
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
- // prepend special webpack loader that will transform test.ts
104
- if ((_a = options.include) === null || _a === void 0 ? void 0 : _a.length) {
105
- const projectName = (_b = context.target) === null || _b === void 0 ? void 0 : _b.project;
106
- if (!projectName) {
107
- throw new Error('The builder requires a target.');
108
- }
109
- const projectMetadata = await context.getProjectMetadata(projectName);
110
- const sourceRoot = ((_d = (_c = projectMetadata.sourceRoot) !== null && _c !== void 0 ? _c : projectMetadata.root) !== null && _d !== void 0 ? _d : '');
111
- const projectSourceRoot = path.join(context.workspaceRoot, sourceRoot);
112
- const files = await (0, find_tests_1.findTests)(options.include, context.workspaceRoot, projectSourceRoot);
113
- // early exit, no reason to start karma
114
- if (!files.length) {
115
- throw new Error(`Specified patterns: "${options.include.join(', ')}" did not match any spec files.`);
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: string;
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
- * The name of the polyfills file.
51
+ * Polyfills to be included in the build.
52
52
  */
53
- polyfills?: string;
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
- "type": "string",
21
- "description": "The name of the polyfills file."
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|styl)$"
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|styl)$"
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": ["main", "tsConfig", "karmaConfig"],
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("@angular-devkit/core").JsonObject>;
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, target }) => {
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, target <= typescript_1.ScriptTarget.ES5, options.i18nMissingTranslation);
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, target } = await (0, webpack_browser_config_1.generateI18nBrowserWebpackConfigFromContext)({
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) => [(0, configs_1.getCommonConfig)(wco), (0, configs_1.getStylesConfig)(wco)]);
109
- let transformedConfig;
110
- if (webpackConfigurationTransform) {
111
- transformedConfig = await webpackConfigurationTransform(config);
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
- return { config: transformedConfig || config, i18n, target };
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;
@@ -1,9 +1,4 @@
1
1
  export interface Schema {
2
- /**
3
- * Which external dependencies to bundle into the bundle. By default, all of node_modules
4
- * will be bundled.
5
- */
6
- bundleDependencies?: boolean;
7
2
  /**
8
3
  * Delete the output path before building.
9
4
  */
@@ -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 {};