@angular-devkit/build-angular 15.0.3 → 15.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "15.0.3",
3
+ "version": "15.0.4",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
7
7
  "builders": "builders.json",
8
8
  "dependencies": {
9
9
  "@ampproject/remapping": "2.2.0",
10
- "@angular-devkit/architect": "0.1500.3",
11
- "@angular-devkit/build-webpack": "0.1500.3",
12
- "@angular-devkit/core": "15.0.3",
10
+ "@angular-devkit/architect": "0.1500.4",
11
+ "@angular-devkit/build-webpack": "0.1500.4",
12
+ "@angular-devkit/core": "15.0.4",
13
13
  "@babel/core": "7.20.2",
14
14
  "@babel/generator": "7.20.4",
15
15
  "@babel/helper-annotate-as-pure": "7.18.6",
@@ -20,7 +20,7 @@
20
20
  "@babel/runtime": "7.20.1",
21
21
  "@babel/template": "7.18.10",
22
22
  "@discoveryjs/json-ext": "0.5.7",
23
- "@ngtools/webpack": "15.0.3",
23
+ "@ngtools/webpack": "15.0.4",
24
24
  "ansi-colors": "4.1.3",
25
25
  "autoprefixer": "10.4.13",
26
26
  "babel-loader": "9.1.0",
@@ -30,7 +30,7 @@
30
30
  "chokidar": "3.5.3",
31
31
  "copy-webpack-plugin": "11.0.0",
32
32
  "critters": "0.0.16",
33
- "css-loader": "6.7.1",
33
+ "css-loader": "6.7.3",
34
34
  "esbuild-wasm": "0.15.13",
35
35
  "glob": "8.0.3",
36
36
  "https-proxy-agent": "5.0.1",
@@ -139,7 +139,7 @@ function default_1(api, options) {
139
139
  // downlevel class properties by ensuring the class properties Babel plugin
140
140
  // is always included- regardless of the preset-env targets.
141
141
  if (options.supportedBrowsers.some((b) => safariClassFieldScopeBugBrowsers.has(b))) {
142
- includePlugins.push('@babel/plugin-proposal-class-properties');
142
+ includePlugins.push('@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-private-methods');
143
143
  }
144
144
  presets.push([
145
145
  require('@babel/preset-env').default,
@@ -155,6 +155,10 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
155
155
  // Skip keys that have been manually provided
156
156
  continue;
157
157
  }
158
+ if (key === 'ngDevMode') {
159
+ // ngDevMode is already set based on the builder's script optimization option
160
+ continue;
161
+ }
158
162
  // esbuild requires values to be a string (actual strings need to be quoted).
159
163
  // In this case, all provided values are booleans.
160
164
  build.initialOptions.define[key] = value.toString();
@@ -232,7 +232,11 @@ function createCodeBundleOptions(options, target, sourceFileCache) {
232
232
  }),
233
233
  ],
234
234
  define: {
235
+ // Only set to false when script optimizations are enabled. It should not be set to true because
236
+ // Angular turns `ngDevMode` into an object for development debugging purposes when not defined
237
+ // which a constant true value would break.
235
238
  ...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
239
+ // Only AOT mode is supported currently
236
240
  'ngJitMode': 'false',
237
241
  },
238
242
  };
@@ -0,0 +1,59 @@
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
+ // import type ng from '@angular/compiler-cli';
10
+ // import { Worker } from 'node:worker_threads';
11
+ // import { AngularHostOptions } from './angular-host';
12
+ // interface Message {
13
+ // id: number;
14
+ // }
15
+ // interface InitializeRequest extends Message {
16
+ // tsconfig: string;
17
+ // tsCallbackId: number;
18
+ // tcoCallbackId?: number;
19
+ // }
20
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ // type ResponseCallback = (...args: any[]) => void;
22
+ // let callbackIds = 0;
23
+ // export class WorkerAngularCompilation {
24
+ // #worker: Worker;
25
+ // #callbacks = new Map<number, ResponseCallback>();
26
+ // constructor() {
27
+ // this.#worker = new Worker(require.resolve('./compilation-worker'));
28
+ // }
29
+ // async initialize(
30
+ // tsconfig: string,
31
+ // hostOptions: AngularHostOptions,
32
+ // transformCompilerOptions?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions,
33
+ // ): Promise<{ compilerOptions: ng.CompilerOptions }> {
34
+ // const request: InitializeRequest = {
35
+ // id: ++callbackIds,
36
+ // tsconfig,
37
+ // tsCallbackId: ++callbackIds,
38
+ // };
39
+ // this.#callbacks.set(request.tsCallbackId, () => {
40
+ // hostOptions.transformStylesheet();
41
+ // });
42
+ // if (transformCompilerOptions) {
43
+ // request.tcoCallbackId = ++callbackIds;
44
+ // this.#callbacks.set(request.tcoCallbackId, (id: number, compilerOptions) => {
45
+ // try {
46
+ // transformCompilerOptions(compilerOptions);
47
+ // } catch (e) {
48
+ // }
49
+ // });
50
+ // }
51
+ // const result = new Promise<{ compilerOptions: ng.CompilerOptions }>((resolve, reject) => {
52
+ // this.#callbacks.set(request.id, () => {
53
+ // resolve({});
54
+ // });
55
+ // });
56
+ // this.#worker.postMessage(request);
57
+ // return result;
58
+ // }
59
+ // }
@@ -52,7 +52,7 @@ function emittedFilesToInlineOptions(emittedFiles, scriptsEntryPointName, emitte
52
52
  code: fs.readFileSync(originalPath, 'utf8'),
53
53
  outputPath,
54
54
  missingTranslation,
55
- setLocale: emittedFile.name === 'main' || emittedFile.name === 'vendor',
55
+ setLocale: emittedFile.name === 'main',
56
56
  };
57
57
  originalFiles.push(originalPath);
58
58
  try {
@@ -211,7 +211,7 @@ async function inlineLocalesDirect(ast, options) {
211
211
  }
212
212
  let outputSource = content;
213
213
  if (options.setLocale) {
214
- const setLocaleText = `var $localize=Object.assign(void 0===$localize?{}:$localize,{locale:"${locale}"});\n`;
214
+ const setLocaleText = `globalThis.$localize=Object.assign(globalThis.$localize || {},{locale:"${locale}"});\n`;
215
215
  // If locale data is provided, load it and prepend to file
216
216
  let localeDataSource;
217
217
  const localeDataPath = i18n.locales[locale] && i18n.locales[locale].dataPath;
@@ -320,6 +320,7 @@ function getSassLoaderOptions(root, implementation, includePaths, indentedSyntax
320
320
  quietDeps: !verbose,
321
321
  verbose,
322
322
  syntax: indentedSyntax ? 'indented' : 'scss',
323
+ sourceMapIncludeSources: true,
323
324
  }),
324
325
  }
325
326
  : {
@@ -24,8 +24,6 @@ class StylesWebpackPlugin {
24
24
  }
25
25
  apply(compiler) {
26
26
  const { entryPoints, preserveSymlinks, root } = this.options;
27
- const webpackOptions = compiler.options;
28
- const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
29
27
  const resolver = compiler.resolverFactory.get('global-styles', {
30
28
  conditionNames: ['sass', 'less', 'style'],
31
29
  mainFields: ['sass', 'less', 'style', 'main', '...'],
@@ -36,33 +34,37 @@ class StylesWebpackPlugin {
36
34
  symlinks: !preserveSymlinks,
37
35
  fileSystem: compiler.inputFileSystem,
38
36
  });
39
- webpackOptions.entry = async () => {
40
- var _a, _b;
41
- var _c;
42
- const entrypoints = await entry;
43
- for (const [bundleName, paths] of Object.entries(entryPoints)) {
44
- (_a = entrypoints[bundleName]) !== null && _a !== void 0 ? _a : (entrypoints[bundleName] = {});
45
- const entryImport = ((_b = (_c = entrypoints[bundleName]).import) !== null && _b !== void 0 ? _b : (_c.import = []));
46
- for (const path of paths) {
47
- try {
48
- const resolvedPath = resolver.resolveSync({}, root, path);
49
- if (resolvedPath) {
50
- entryImport.push(`${resolvedPath}?ngGlobalStyle`);
37
+ const webpackOptions = compiler.options;
38
+ compiler.hooks.environment.tap(PLUGIN_NAME, () => {
39
+ const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
40
+ webpackOptions.entry = async () => {
41
+ var _a, _b;
42
+ var _c;
43
+ const entrypoints = await entry;
44
+ for (const [bundleName, paths] of Object.entries(entryPoints)) {
45
+ (_a = entrypoints[bundleName]) !== null && _a !== void 0 ? _a : (entrypoints[bundleName] = {});
46
+ const entryImport = ((_b = (_c = entrypoints[bundleName]).import) !== null && _b !== void 0 ? _b : (_c.import = []));
47
+ for (const path of paths) {
48
+ try {
49
+ const resolvedPath = resolver.resolveSync({}, root, path);
50
+ if (resolvedPath) {
51
+ entryImport.push(`${resolvedPath}?ngGlobalStyle`);
52
+ }
53
+ else {
54
+ (0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
55
+ (0, webpack_diagnostics_1.addError)(this.compilation, `Cannot resolve '${path}'.`);
56
+ }
51
57
  }
52
- else {
58
+ catch (error) {
53
59
  (0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
54
- (0, webpack_diagnostics_1.addError)(this.compilation, `Cannot resolve '${path}'.`);
60
+ (0, error_1.assertIsError)(error);
61
+ (0, webpack_diagnostics_1.addError)(this.compilation, error.message);
55
62
  }
56
63
  }
57
- catch (error) {
58
- (0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
59
- (0, error_1.assertIsError)(error);
60
- (0, webpack_diagnostics_1.addError)(this.compilation, error.message);
61
- }
62
64
  }
63
- }
64
- return entrypoints;
65
- };
65
+ return entrypoints;
66
+ };
67
+ });
66
68
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
67
69
  this.compilation = compilation;
68
70
  });