@angular-devkit/build-optimizer 0.1300.0-next.3 → 0.1300.0-next.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-optimizer",
3
- "version": "0.1300.0-next.3",
3
+ "version": "0.1300.0-next.7",
4
4
  "description": "Angular Build Optimizer",
5
5
  "experimental": true,
6
6
  "main": "src/index.js",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "source-map": "0.7.3",
13
13
  "tslib": "2.3.1",
14
- "typescript": "4.3.5"
14
+ "typescript": "4.4.3"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "webpack": "^5.30.0"
@@ -54,7 +54,7 @@ function buildOptimizer(options) {
54
54
  throw new Error('Either filePath or content must be specified in options.');
55
55
  }
56
56
  if (content === undefined) {
57
- content = fs_1.readFileSync(inputFilePath, 'UTF-8');
57
+ content = (0, fs_1.readFileSync)(inputFilePath, 'UTF-8');
58
58
  }
59
59
  if (!content) {
60
60
  return {
@@ -79,13 +79,13 @@ function buildOptimizer(options) {
79
79
  prefix_functions_1.getPrefixFunctionsTransformer);
80
80
  typeCheck = true;
81
81
  }
82
- else if (prefix_classes_1.testPrefixClasses(content)) {
82
+ else if ((0, prefix_classes_1.testPrefixClasses)(content)) {
83
83
  // This is only relevant if prefix functions is not used since prefix functions will prefix IIFE wrapped classes.
84
84
  getTransforms.unshift(prefix_classes_1.getPrefixClassesTransformer);
85
85
  }
86
- if (scrub_file_1.testScrubFile(content)) {
86
+ if ((0, scrub_file_1.testScrubFile)(content)) {
87
87
  // Always test as these require the type checker
88
- getTransforms.push(scrub_file_1.createScrubFileTransformerFactory(isAngularCoreFile));
88
+ getTransforms.push((0, scrub_file_1.createScrubFileTransformerFactory)(isAngularCoreFile));
89
89
  typeCheck = true;
90
90
  }
91
91
  getTransforms.push(wrap_enums_1.getWrapEnumsTransformer);
@@ -98,6 +98,6 @@ function buildOptimizer(options) {
98
98
  getTransforms,
99
99
  typeCheck,
100
100
  };
101
- return transform_javascript_1.transformJavascript(transformJavascriptOpts);
101
+ return (0, transform_javascript_1.transformJavascript)(transformJavascriptOpts);
102
102
  }
103
103
  exports.buildOptimizer = buildOptimizer;
@@ -28,17 +28,17 @@ if (!inputFile.match(tsOrJsRegExp)) {
28
28
  }
29
29
  // Use provided output file, or add the .bo suffix before the extension.
30
30
  const outputFile = process.argv[3] || inputFile.replace(tsOrJsRegExp, (subStr) => `.bo${subStr}`);
31
- const boOutput = build_optimizer_1.buildOptimizer({
32
- inputFilePath: path_1.join(currentDir, inputFile),
33
- outputFilePath: path_1.join(currentDir, outputFile),
31
+ const boOutput = (0, build_optimizer_1.buildOptimizer)({
32
+ inputFilePath: (0, path_1.join)(currentDir, inputFile),
33
+ outputFilePath: (0, path_1.join)(currentDir, outputFile),
34
34
  emitSourceMap: true,
35
35
  });
36
36
  if (boOutput.emitSkipped) {
37
37
  console.log('Nothing to emit.');
38
38
  }
39
39
  else {
40
- fs_1.writeFileSync(path_1.join(currentDir, outputFile), boOutput.content);
41
- fs_1.writeFileSync(path_1.join(currentDir, `${outputFile}.map`), JSON.stringify(boOutput.sourceMap));
40
+ (0, fs_1.writeFileSync)((0, path_1.join)(currentDir, outputFile), boOutput.content);
41
+ (0, fs_1.writeFileSync)((0, path_1.join)(currentDir, `${outputFile}.map`), JSON.stringify(boOutput.sourceMap));
42
42
  console.log('Emitted:');
43
43
  console.log(` ${outputFile}`);
44
44
  console.log(` ${outputFile}.map`);
@@ -47,7 +47,7 @@ function optimizer(options) {
47
47
  options.sideEffectFreeModules.some((m) => normalizedId.indexOf(m) >= 0);
48
48
  const isAngularCoreFile = options.angularCoreModules &&
49
49
  options.angularCoreModules.some((m) => normalizedId.indexOf(m) >= 0);
50
- const { content: code, sourceMap: map } = build_optimizer_1.buildOptimizer({
50
+ const { content: code, sourceMap: map } = (0, build_optimizer_1.buildOptimizer)({
51
51
  content,
52
52
  inputFilePath: id,
53
53
  emitSourceMap: true,
@@ -22,7 +22,7 @@ function buildOptimizerLoader(content, previousSourceMap) {
22
22
  return;
23
23
  }
24
24
  const options = (this.getOptions() || {});
25
- const boOutput = build_optimizer_1.buildOptimizer({
25
+ const boOutput = (0, build_optimizer_1.buildOptimizer)({
26
26
  content,
27
27
  originalFilePath: this.resourcePath,
28
28
  inputFilePath: this.resourcePath,
package/src/index.js CHANGED
@@ -28,10 +28,10 @@ Object.defineProperty(exports, "getPrefixFunctionsTransformer", { enumerable: tr
28
28
  var wrap_enums_1 = require("./transforms/wrap-enums");
29
29
  Object.defineProperty(exports, "getWrapEnumsTransformer", { enumerable: true, get: function () { return wrap_enums_1.getWrapEnumsTransformer; } });
30
30
  function getScrubFileTransformer(program) {
31
- return scrub_file_1.createScrubFileTransformerFactory(false)(program);
31
+ return (0, scrub_file_1.createScrubFileTransformerFactory)(false)(program);
32
32
  }
33
33
  exports.getScrubFileTransformer = getScrubFileTransformer;
34
34
  function getScrubFileTransformerForCore(program) {
35
- return scrub_file_1.createScrubFileTransformerFactory(true)(program);
35
+ return (0, scrub_file_1.createScrubFileTransformerFactory)(true)(program);
36
36
  }
37
37
  exports.getScrubFileTransformerForCore = getScrubFileTransformerForCore;
@@ -72,7 +72,7 @@ function getPrefixClassesTransformer() {
72
72
  const varInitializer = varDecl.initializer;
73
73
  // Update node with the pure comment before the variable declaration initializer.
74
74
  const newNode = ts.updateVariableStatement(node, node.modifiers, ts.updateVariableDeclarationList(node.declarationList, [
75
- ts.updateVariableDeclaration(varDecl, varDecl.name, varDecl.type, ast_utils_1.addPureComment(varInitializer)),
75
+ ts.updateVariableDeclaration(varDecl, varDecl.name, varDecl.type, (0, ast_utils_1.addPureComment)(varInitializer)),
76
76
  ]));
77
77
  // Replace node with modified one.
78
78
  return ts.visitEachChild(newNode, visitor, context);
@@ -36,7 +36,7 @@ function getPrefixFunctionsTransformer() {
36
36
  const visitor = (node) => {
37
37
  // Add pure function comment to top level functions.
38
38
  if (topLevelFunctions.has(node)) {
39
- const newNode = ast_utils_1.addPureComment(node);
39
+ const newNode = (0, ast_utils_1.addPureComment)(node);
40
40
  // Replace node with modified one.
41
41
  return ts.visitEachChild(newNode, visitor, context);
42
42
  }
@@ -64,11 +64,11 @@ function findTopLevelFunctions(parentNode) {
64
64
  ts.isMethodDeclaration(node)) {
65
65
  return;
66
66
  }
67
- let noPureComment = !ast_utils_1.hasPureComment(node);
67
+ let noPureComment = !(0, ast_utils_1.hasPureComment)(node);
68
68
  let innerNode = node;
69
69
  while (innerNode && ts.isParenthesizedExpression(innerNode)) {
70
70
  innerNode = innerNode.expression;
71
- noPureComment = noPureComment && !ast_utils_1.hasPureComment(innerNode);
71
+ noPureComment = noPureComment && !(0, ast_utils_1.hasPureComment)(innerNode);
72
72
  }
73
73
  if (!innerNode) {
74
74
  return;
@@ -86,7 +86,7 @@ function findTopLevelFunctions(parentNode) {
86
86
  }
87
87
  else if (ts.isCallExpression(innerNode)) {
88
88
  let expression = innerNode.expression;
89
- if (ts.isIdentifier(expression) && ast_utils_1.getCleanHelperName(expression.text)) {
89
+ if (ts.isIdentifier(expression) && (0, ast_utils_1.getCleanHelperName)(expression.text)) {
90
90
  return;
91
91
  }
92
92
  while (expression && ts.isParenthesizedExpression(expression)) {
@@ -112,7 +112,7 @@ function findAngularMetadata(node, isAngularCoreFile) {
112
112
  if (child.kind === ts.SyntaxKind.ImportDeclaration) {
113
113
  const importDecl = child;
114
114
  if (isAngularCoreImport(importDecl, isAngularCoreFile)) {
115
- specs.push(...ast_utils_1.collectDeepNodes(importDecl, ts.SyntaxKind.ImportSpecifier));
115
+ specs.push(...(0, ast_utils_1.collectDeepNodes)(importDecl, ts.SyntaxKind.ImportSpecifier));
116
116
  }
117
117
  }
118
118
  });
@@ -303,7 +303,7 @@ function updateEnumIife(nodeFactory, hostNode, iife, exportAssignment) {
303
303
  arg = nodeFactory.createBinaryExpression(exportAssignment, ts.SyntaxKind.BarBarToken, arg);
304
304
  }
305
305
  const updatedIife = nodeFactory.updateCallExpression(iife, nodeFactory.updateParenthesizedExpression(iife.expression, updatedFunction), iife.typeArguments, [arg]);
306
- let value = ast_utils_1.addPureComment(updatedIife);
306
+ let value = (0, ast_utils_1.addPureComment)(updatedIife);
307
307
  if (exportAssignment) {
308
308
  value = nodeFactory.createBinaryExpression(exportAssignment, ts.SyntaxKind.FirstAssignment, updatedIife);
309
309
  }
@@ -315,7 +315,7 @@ function createWrappedClass(nodeFactory, hostNode, statements) {
315
315
  if (ts.isClassDeclaration(hostNode)) {
316
316
  updatedStatements[0] = nodeFactory.createClassDeclaration(hostNode.decorators, undefined, hostNode.name, hostNode.typeParameters, hostNode.heritageClauses, hostNode.members);
317
317
  }
318
- const pureIife = ast_utils_1.addPureComment(nodeFactory.createImmediatelyInvokedArrowFunction([
318
+ const pureIife = (0, ast_utils_1.addPureComment)(nodeFactory.createImmediatelyInvokedArrowFunction([
319
319
  ...updatedStatements,
320
320
  nodeFactory.createReturnStatement(nodeFactory.createIdentifier(name)),
321
321
  ]));