@angular-devkit/build-angular 0.1000.3 → 0.1000.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,16 +1,16 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "0.1000.3",
3
+ "version": "0.1000.4",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "experimental": true,
6
6
  "main": "src/index.js",
7
7
  "typings": "src/index.d.ts",
8
8
  "builders": "builders.json",
9
9
  "dependencies": {
10
- "@angular-devkit/architect": "0.1000.3",
11
- "@angular-devkit/build-optimizer": "0.1000.3",
12
- "@angular-devkit/build-webpack": "0.1000.3",
13
- "@angular-devkit/core": "10.0.3",
10
+ "@angular-devkit/architect": "0.1000.4",
11
+ "@angular-devkit/build-optimizer": "0.1000.4",
12
+ "@angular-devkit/build-webpack": "0.1000.4",
13
+ "@angular-devkit/core": "10.0.4",
14
14
  "@babel/core": "7.9.6",
15
15
  "@babel/generator": "7.9.6",
16
16
  "@babel/plugin-transform-runtime": "7.9.6",
@@ -18,8 +18,8 @@
18
18
  "@babel/runtime": "7.9.6",
19
19
  "@babel/template": "7.8.6",
20
20
  "@jsdevtools/coverage-istanbul-loader": "3.0.3",
21
- "@ngtools/webpack": "10.0.3",
22
- "ajv": "6.12.2",
21
+ "@ngtools/webpack": "10.0.4",
22
+ "ajv": "6.12.3",
23
23
  "autoprefixer": "9.8.0",
24
24
  "babel-loader": "8.1.0",
25
25
  "browserslist": "^4.9.1",
@@ -422,6 +422,13 @@ function getCommonConfig(wco) {
422
422
  test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
423
423
  parser: { system: true },
424
424
  },
425
+ {
426
+ // Mark files inside `rxjs/add` as containing side effects.
427
+ // If this is fixed upstream and the fixed version becomes the minimum
428
+ // supported version, this can be removed.
429
+ test: /[\/\\]rxjs[\/\\]add[\/\\].+\.js$/,
430
+ sideEffects: true,
431
+ },
425
432
  {
426
433
  test: /\.m?js$/,
427
434
  exclude: [/[\/\\](?:core-js|\@babel|tslib)[\/\\]/, /(ngfactory|ngstyle)\.js$/],
@@ -440,6 +447,7 @@ function getCommonConfig(wco) {
440
447
  cacheIdentifier: JSON.stringify({
441
448
  buildAngular: require('../../../../package.json').version,
442
449
  }),
450
+ sourceType: 'unambiguous',
443
451
  presets: [
444
452
  [
445
453
  require.resolve('@babel/preset-env'),
@@ -79,10 +79,11 @@ function statsWarningsToString(json, statsConfig) {
79
79
  const y = (x) => colors ? bold(yellow(x)) : x;
80
80
  const warnings = [...json.warnings];
81
81
  if (json.children) {
82
- warnings.push(...json.children.map((c) => c.warnings));
82
+ warnings.push(...json.children
83
+ .map((c) => c.warnings)
84
+ .reduce((a, b) => [...a, ...b], []));
83
85
  }
84
86
  return rs('\n' + warnings
85
- .filter(m => !!m)
86
87
  .map((warning) => `${warning}`)
87
88
  .filter((warning) => !ERRONEOUS_WARNINGS.some((erroneous) => erroneous.test(warning)))
88
89
  .map((warning) => y(`WARNING in ${warning}`))
@@ -95,10 +96,11 @@ function statsErrorsToString(json, statsConfig) {
95
96
  const r = (x) => colors ? bold(red(x)) : x;
96
97
  const errors = [...json.errors];
97
98
  if (json.children) {
98
- errors.push(...json.children.map((c) => c.errors));
99
+ errors.push(...json.children
100
+ .map((c) => c.errors)
101
+ .reduce((a, b) => [...a, ...b], []));
99
102
  }
100
103
  return rs('\n' + errors
101
- .filter(m => !!m)
102
104
  .map((error) => r(`ERROR in ${error}`))
103
105
  .join('\n\n'));
104
106
  }
@@ -14,15 +14,35 @@ async function createTranslationLoader() {
14
14
  const { parsers, diagnostics } = await importParsers();
15
15
  return (path) => {
16
16
  const content = fs.readFileSync(path, 'utf8');
17
+ const unusedParsers = new Map();
17
18
  for (const [format, parser] of Object.entries(parsers)) {
18
- if (parser.canParse(path, content)) {
19
- const result = parser.parse(path, content);
19
+ const analysis = analyze(parser, path, content);
20
+ if (analysis.canParse) {
21
+ const translationBundle = parser.parse(path, content, analysis.hint);
20
22
  const integrity = 'sha256-' + crypto_1.createHash('sha256').update(content).digest('base64');
21
- return { format, translation: result.translations, diagnostics, integrity };
23
+ return { format, translation: translationBundle.translations, diagnostics, integrity };
22
24
  }
25
+ else {
26
+ unusedParsers.set(parser, analysis);
27
+ }
28
+ }
29
+ const messages = [];
30
+ for (const [parser, analysis] of unusedParsers.entries()) {
31
+ messages.push(analysis.diagnostics.formatDiagnostics(`*** ${parser.constructor.name} ***`));
23
32
  }
24
- throw new Error('Unsupported translation file format.');
33
+ throw new Error(`Unsupported translation file format in ${path}. The following parsers were tried:\n` + messages.join('\n'));
25
34
  };
35
+ // TODO: `parser.canParse()` is deprecated; remove this polyfill once we are sure all parsers provide the `parser.analyze()` method.
36
+ // tslint:disable-next-line: no-any
37
+ function analyze(parser, path, content) {
38
+ if (parser.analyze !== undefined) {
39
+ return parser.analyze(path, content);
40
+ }
41
+ else {
42
+ const hint = parser.canParse(path, content);
43
+ return { canParse: hint !== false, hint, diagnostics };
44
+ }
45
+ }
26
46
  }
27
47
  exports.createTranslationLoader = createTranslationLoader;
28
48
  async function importParsers() {