@angular-devkit/build-optimizer 0.1001.0-rc.0 → 0.1001.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-optimizer",
3
- "version": "0.1001.0-rc.0",
3
+ "version": "0.1001.3",
4
4
  "description": "Angular Build Optimizer",
5
5
  "experimental": true,
6
6
  "main": "src/index.js",
@@ -15,7 +15,7 @@ const prefix_functions_1 = require("../transforms/prefix-functions");
15
15
  const scrub_file_1 = require("../transforms/scrub-file");
16
16
  const wrap_enums_1 = require("../transforms/wrap-enums");
17
17
  // Angular packages are known to have no side effects.
18
- const whitelistedAngularModules = [
18
+ const knownSideEffectFreeAngularModules = [
19
19
  /[\\/]node_modules[\\/]@angular[\\/]animations[\\/]/,
20
20
  /[\\/]node_modules[\\/]@angular[\\/]common[\\/]/,
21
21
  /[\\/]node_modules[\\/]@angular[\\/]compiler[\\/]/,
@@ -49,7 +49,7 @@ function isKnownCoreFile(filePath) {
49
49
  }
50
50
  function isKnownSideEffectFree(filePath) {
51
51
  return ngFactories.some((re) => re.test(filePath)) ||
52
- whitelistedAngularModules.some((re) => re.test(filePath));
52
+ knownSideEffectFreeAngularModules.some((re) => re.test(filePath));
53
53
  }
54
54
  function buildOptimizer(options) {
55
55
  const { inputFilePath, isAngularCoreFile } = options;
@@ -82,7 +82,7 @@ function buildOptimizer(options) {
82
82
  getTransforms.push(
83
83
  // getPrefixFunctionsTransformer is rather dangerous, apply only to known pure es5 modules.
84
84
  // It will mark both `require()` calls and `console.log(stuff)` as pure.
85
- // We only apply it to whitelisted modules, since we know they are safe.
85
+ // We only apply it to modules known to be side effect free, since we know they are safe.
86
86
  // getPrefixFunctionsTransformer needs to be before getFoldFileTransformer.
87
87
  prefix_functions_1.getPrefixFunctionsTransformer, selectedGetScrubFileTransformer);
88
88
  typeCheck = true;
@@ -127,7 +127,7 @@ function isAngularCoreImport(node, isAngularCoreFile) {
127
127
  return true;
128
128
  }
129
129
  // Relative imports from a Angular core file are also core imports.
130
- if (isAngularCoreFile && (importText.startsWith('./') || importText.startsWith('../'))) {
130
+ if (isAngularCoreFile && importText.startsWith('.')) {
131
131
  return true;
132
132
  }
133
133
  return false;
@@ -456,11 +456,13 @@ function isTslibHelper(callExpr, helper, tslibImports, checker) {
456
456
  if (!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a.length)) {
457
457
  return false;
458
458
  }
459
- for (const name of tslibImports) {
460
- for (const dec of symbol.declarations) {
461
- if (ts.isImportSpecifier(dec) && name.elements.includes(dec)) {
462
- return true;
463
- }
459
+ for (const dec of symbol.declarations) {
460
+ if (ts.isImportSpecifier(dec) && tslibImports.some(name => name.elements.includes(dec))) {
461
+ return true;
462
+ }
463
+ // Handle inline helpers `var __decorate = (this...`
464
+ if (ts.isVariableDeclaration(dec)) {
465
+ return true;
464
466
  }
465
467
  }
466
468
  return false;