@angular-devkit/build-angular 14.0.4 → 14.0.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "14.0.4",
3
+ "version": "14.0.7",
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.1400.4",
11
- "@angular-devkit/build-webpack": "0.1400.4",
12
- "@angular-devkit/core": "14.0.4",
10
+ "@angular-devkit/architect": "0.1400.7",
11
+ "@angular-devkit/build-webpack": "0.1400.7",
12
+ "@angular-devkit/core": "14.0.7",
13
13
  "@babel/core": "7.17.10",
14
14
  "@babel/generator": "7.17.10",
15
15
  "@babel/helper-annotate-as-pure": "7.16.7",
@@ -20,7 +20,7 @@
20
20
  "@babel/runtime": "7.17.9",
21
21
  "@babel/template": "7.16.7",
22
22
  "@discoveryjs/json-ext": "0.5.7",
23
- "@ngtools/webpack": "14.0.4",
23
+ "@ngtools/webpack": "14.0.7",
24
24
  "ansi-colors": "4.1.1",
25
25
  "babel-loader": "8.2.5",
26
26
  "babel-plugin-istanbul": "6.1.1",
@@ -95,7 +95,7 @@ async function _renderUniversal(options, context, browserResult, serverResult, s
95
95
  }
96
96
  await fs.promises.writeFile(outputIndexPath, html);
97
97
  if (browserOptions.serviceWorker) {
98
- await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref, browserOptions.ngswConfigPath);
98
+ await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, root, outputPath, baseHref !== null && baseHref !== void 0 ? baseHref : '/', browserOptions.ngswConfigPath);
99
99
  }
100
100
  }
101
101
  return browserResult;
@@ -28,7 +28,7 @@ export declare type BrowserBuilderOutput = BuilderOutput & {
28
28
  outputs: {
29
29
  locale?: string;
30
30
  path: string;
31
- baseHref: string;
31
+ baseHref?: string;
32
32
  }[];
33
33
  };
34
34
  /**
@@ -117,9 +117,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
117
117
  }), (0, operators_1.switchMap)(
118
118
  // eslint-disable-next-line max-lines-per-function
119
119
  ({ config, projectRoot, projectSourceRoot, i18n, target, cacheOptions }) => {
120
- var _a;
121
120
  const normalizedOptimization = (0, utils_1.normalizeOptimization)(options.optimization);
122
- const defaultBaseHref = (_a = options.baseHref) !== null && _a !== void 0 ? _a : '/';
123
121
  return (0, build_webpack_1.runWebpack)(config, context, {
124
122
  webpackFactory: require('webpack'),
125
123
  logging: transforms.logging ||
@@ -129,7 +127,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
129
127
  }
130
128
  }),
131
129
  }).pipe((0, operators_1.concatMap)(async (buildEvent) => {
132
- var _a, _b, _c, _d, _e, _f;
130
+ var _a, _b, _c, _d, _e, _f, _g, _h;
133
131
  const spinner = new spinner_1.Spinner();
134
132
  spinner.enabled = options.progress !== false;
135
133
  const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
@@ -218,7 +216,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
218
216
  for (const [locale, outputPath] of outputPaths.entries()) {
219
217
  try {
220
218
  const { content, warnings, errors } = await indexHtmlGenerator.process({
221
- baseHref: getLocaleBaseHref(i18n, locale) || defaultBaseHref,
219
+ baseHref: (_f = getLocaleBaseHref(i18n, locale)) !== null && _f !== void 0 ? _f : options.baseHref,
222
220
  // i18nLocale is used when Ivy is disabled
223
221
  lang: locale || undefined,
224
222
  outputPath,
@@ -254,7 +252,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
254
252
  spinner.start('Generating service worker...');
255
253
  for (const [locale, outputPath] of outputPaths.entries()) {
256
254
  try {
257
- await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, (_f = getLocaleBaseHref(i18n, locale)) !== null && _f !== void 0 ? _f : defaultBaseHref, options.ngswConfigPath);
255
+ await (0, service_worker_1.augmentAppWithServiceWorker)(projectRoot, context.workspaceRoot, outputPath, (_h = (_g = getLocaleBaseHref(i18n, locale)) !== null && _g !== void 0 ? _g : options.baseHref) !== null && _h !== void 0 ? _h : '/', options.ngswConfigPath);
258
256
  }
259
257
  catch (error) {
260
258
  spinner.fail('Service worker generation failed.');
@@ -278,11 +276,11 @@ function buildWebpackBrowser(options, context, transforms = {}) {
278
276
  return ({
279
277
  locale,
280
278
  path,
281
- baseHref: (_a = getLocaleBaseHref(i18n, locale)) !== null && _a !== void 0 ? _a : defaultBaseHref,
279
+ baseHref: (_a = getLocaleBaseHref(i18n, locale)) !== null && _a !== void 0 ? _a : options.baseHref,
282
280
  });
283
281
  })) || {
284
282
  path: baseOutputPath,
285
- baseHref: defaultBaseHref,
283
+ baseHref: options.baseHref,
286
284
  },
287
285
  })));
288
286
  }));
@@ -249,7 +249,11 @@ async function bundleCode(workspaceRoot, entryPoints, outputNames, options, opti
249
249
  {
250
250
  workspaceRoot,
251
251
  optimization: !!optimizationOptions.styles.minify,
252
- sourcemap: !!sourcemapOptions.styles,
252
+ sourcemap:
253
+ // Hidden component stylesheet sourcemaps are inaccessible which is effectively
254
+ // the same as being disabled. Disabling has the advantage of avoiding the overhead
255
+ // of sourcemap processing.
256
+ !!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
253
257
  outputNames,
254
258
  }),
255
259
  ],
@@ -10,7 +10,7 @@ export interface BundleStylesheetOptions {
10
10
  workspaceRoot?: string;
11
11
  optimization: boolean;
12
12
  preserveSymlinks?: boolean;
13
- sourcemap: boolean | 'external';
13
+ sourcemap: boolean | 'external' | 'inline';
14
14
  outputNames?: {
15
15
  bundles?: string;
16
16
  media?: string;
@@ -71,6 +71,8 @@ async function findMatchingTests(pattern, workspaceRoot, projectSourceRoot) {
71
71
  }
72
72
  return globPromise(normalizedPattern, {
73
73
  cwd: projectSourceRoot,
74
+ root: projectSourceRoot,
75
+ nomount: true,
74
76
  });
75
77
  }
76
78
  async function isDirectory(path) {
@@ -37,17 +37,18 @@ exports.copyAssets = void 0;
37
37
  const fs = __importStar(require("fs"));
38
38
  const glob_1 = __importDefault(require("glob"));
39
39
  const path = __importStar(require("path"));
40
- function globAsync(pattern, options) {
41
- return new Promise((resolve, reject) => (0, glob_1.default)(pattern, options, (e, m) => (e ? reject(e) : resolve(m))));
42
- }
40
+ const util_1 = require("util");
41
+ const globPromise = (0, util_1.promisify)(glob_1.default);
43
42
  async function copyAssets(entries, basePaths, root, changed) {
44
43
  const defaultIgnore = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db'];
45
44
  for (const entry of entries) {
46
45
  const cwd = path.resolve(root, entry.input);
47
- const files = await globAsync(entry.glob, {
46
+ const files = await globPromise(entry.glob, {
48
47
  cwd,
49
48
  dot: true,
50
49
  nodir: true,
50
+ root: cwd,
51
+ nomount: true,
51
52
  ignore: entry.ignore ? defaultIgnore.concat(entry.ignore) : defaultIgnore,
52
53
  follow: entry.followSymlinks,
53
54
  });
@@ -307,7 +307,7 @@ async function getCommonConfig(wco) {
307
307
  supportedBrowsers: buildOptions.supportedBrowsers,
308
308
  instrumentCode: codeCoverage
309
309
  ? {
310
- includedBasePath: sourceRoot,
310
+ includedBasePath: sourceRoot !== null && sourceRoot !== void 0 ? sourceRoot : projectRoot,
311
311
  excludedPaths: (0, helpers_1.getInstrumentationExcludedPaths)(root, codeCoverageExclude),
312
312
  }
313
313
  : undefined,
@@ -12,7 +12,9 @@ const path_1 = require("path");
12
12
  const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
13
13
  // Webpack doesn't export these so the deep imports can potentially break.
14
14
  const AMDDefineDependency = require('webpack/lib/dependencies/AMDDefineDependency');
15
+ const CommonJsExportsDependency = require('webpack/lib/dependencies/CommonJsExportsDependency');
15
16
  const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency');
17
+ const CommonJsSelfReferenceDependency = require('webpack/lib/dependencies/CommonJsSelfReferenceDependency');
16
18
  class CommonJsUsageWarnPlugin {
17
19
  constructor(options = {}) {
18
20
  this.options = options;
@@ -81,7 +83,10 @@ class CommonJsUsageWarnPlugin {
81
83
  }
82
84
  hasCommonJsDependencies(compilation, dependencies, checkParentModules = false) {
83
85
  for (const dep of dependencies) {
84
- if (dep instanceof CommonJsRequireDependency || dep instanceof AMDDefineDependency) {
86
+ if (dep instanceof CommonJsRequireDependency ||
87
+ dep instanceof CommonJsExportsDependency ||
88
+ dep instanceof CommonJsSelfReferenceDependency ||
89
+ dep instanceof AMDDefineDependency) {
85
90
  return true;
86
91
  }
87
92
  if (checkParentModules) {
@@ -35,6 +35,10 @@ const loader_utils_1 = require("loader-utils");
35
35
  const path = __importStar(require("path"));
36
36
  const webpack_1 = require("webpack");
37
37
  const Entrypoint = require('webpack/lib/Entrypoint');
38
+ /**
39
+ * The name of the plugin provided to Webpack when tapping Webpack compiler hooks.
40
+ */
41
+ const PLUGIN_NAME = 'scripts-webpack-plugin';
38
42
  function addDependencies(compilation, scripts) {
39
43
  for (const script of scripts) {
40
44
  compilation.fileDependencies.add(script);
@@ -88,8 +92,8 @@ class ScriptsWebpackPlugin {
88
92
  const scripts = this.options.scripts
89
93
  .filter((script) => !!script)
90
94
  .map((script) => path.resolve(this.options.basePath || '', script));
91
- compiler.hooks.thisCompilation.tap('scripts-webpack-plugin', (compilation) => {
92
- compilation.hooks.additionalAssets.tapPromise('scripts-webpack-plugin', async () => {
95
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
96
+ compilation.hooks.additionalAssets.tapPromise(PLUGIN_NAME, async () => {
93
97
  if (await this.shouldSkip(compilation, scripts)) {
94
98
  if (this._cachedOutput) {
95
99
  this._insertOutput(compilation, this._cachedOutput, true);
@@ -129,14 +133,24 @@ class ScriptsWebpackPlugin {
129
133
  concatSource.add('\n;');
130
134
  });
131
135
  const combinedSource = new webpack_1.sources.CachedSource(concatSource);
132
- const filename = (0, loader_utils_1.interpolateName)({ resourcePath: 'scripts.js' }, this.options.filename, {
133
- content: combinedSource.source(),
134
- });
135
- const output = { filename, source: combinedSource };
136
+ const output = { filename: this.options.filename, source: combinedSource };
136
137
  this._insertOutput(compilation, output);
137
138
  this._cachedOutput = output;
138
139
  addDependencies(compilation, scripts);
139
140
  });
141
+ compilation.hooks.processAssets.tapPromise({
142
+ name: PLUGIN_NAME,
143
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
144
+ }, async () => {
145
+ const assetName = this.options.filename;
146
+ const asset = compilation.getAsset(assetName);
147
+ if (asset) {
148
+ const interpolatedFilename = (0, loader_utils_1.interpolateName)({ resourcePath: 'scripts.js' }, assetName, { content: asset.source.source() });
149
+ if (assetName !== interpolatedFilename) {
150
+ compilation.renameAsset(assetName, interpolatedFilename);
151
+ }
152
+ }
153
+ });
140
154
  });
141
155
  }
142
156
  }
@@ -21,7 +21,7 @@ export declare function getOutputHashFormat(outputHashing?: OutputHashing, lengt
21
21
  export declare type NormalizedEntryPoint = Required<Exclude<ScriptElement | StyleElement, string>>;
22
22
  export declare function normalizeExtraEntryPoints(extraEntryPoints: (ScriptElement | StyleElement)[], defaultBundleName: string): NormalizedEntryPoint[];
23
23
  export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
24
- export declare function getInstrumentationExcludedPaths(sourceRoot: string, excludedPaths: string[]): Set<string>;
24
+ export declare function getInstrumentationExcludedPaths(root: string, excludedPaths: string[]): Set<string>;
25
25
  export declare function getCacheSettings(wco: WebpackConfigOptions, angularVersion: string): WebpackOptionsNormalized['cache'];
26
26
  export declare function globalScriptsByBundleName(root: string, scripts: ScriptElement[]): {
27
27
  bundleName: string;
@@ -121,12 +121,12 @@ function assetNameTemplateFactory(hashFormat) {
121
121
  };
122
122
  }
123
123
  exports.assetNameTemplateFactory = assetNameTemplateFactory;
124
- function getInstrumentationExcludedPaths(sourceRoot, excludedPaths) {
124
+ function getInstrumentationExcludedPaths(root, excludedPaths) {
125
125
  const excluded = new Set();
126
126
  for (const excludeGlob of excludedPaths) {
127
127
  glob_1.default
128
- .sync(excludeGlob, { nodir: true, cwd: sourceRoot })
129
- .forEach((p) => excluded.add(path.join(sourceRoot, p)));
128
+ .sync(excludeGlob, { nodir: true, cwd: root, root, nomount: true })
129
+ .forEach((p) => excluded.add(path.join(root, p)));
130
130
  }
131
131
  return excluded;
132
132
  }