@stencil/core 2.12.0 → 2.12.1

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/cli/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI (CommonJS) v2.12.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI (CommonJS) v2.12.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  'use strict';
5
5
 
@@ -33,6 +33,16 @@ const dashToPascalCase = (str) => toLowerCase(str)
33
33
  const isFunction = (v) => typeof v === 'function';
34
34
  const isString = (v) => typeof v === 'string';
35
35
 
36
+ /**
37
+ * Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
38
+ * detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
39
+ * to attach the specifics of the error message.
40
+ *
41
+ * The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
42
+ *
43
+ * @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
44
+ * @returns the created `Diagnostic`
45
+ */
36
46
  const buildError = (diagnostics) => {
37
47
  const diagnostic = {
38
48
  level: 'error',
@@ -79,6 +89,12 @@ const catchError = (diagnostics, err, msg) => {
79
89
  }
80
90
  return diagnostic;
81
91
  };
92
+ /**
93
+ * Determine if the provided diagnostics have any build errors
94
+ * @param diagnostics the diagnostics to inspect
95
+ * @returns true if any of the diagnostics in the list provided are errors that did not occur at runtime. false
96
+ * otherwise.
97
+ */
82
98
  const hasError = (diagnostics) => {
83
99
  if (diagnostics == null || diagnostics.length === 0) {
84
100
  return false;
@@ -490,7 +506,7 @@ const getNpmConfigEnvArgs = (sys) => {
490
506
  const dependencies = [
491
507
  {
492
508
  name: "@stencil/core",
493
- version: "2.12.0",
509
+ version: "2.12.1",
494
510
  main: "compiler/stencil.js",
495
511
  resources: [
496
512
  "package.json",
package/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI v2.12.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI v2.12.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  const toLowerCase = (str) => str.toLowerCase();
5
5
  const dashToPascalCase = (str) => toLowerCase(str)
@@ -9,6 +9,16 @@ const dashToPascalCase = (str) => toLowerCase(str)
9
9
  const isFunction = (v) => typeof v === 'function';
10
10
  const isString = (v) => typeof v === 'string';
11
11
 
12
+ /**
13
+ * Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
14
+ * detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
15
+ * to attach the specifics of the error message.
16
+ *
17
+ * The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
18
+ *
19
+ * @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
20
+ * @returns the created `Diagnostic`
21
+ */
12
22
  const buildError = (diagnostics) => {
13
23
  const diagnostic = {
14
24
  level: 'error',
@@ -55,6 +65,12 @@ const catchError = (diagnostics, err, msg) => {
55
65
  }
56
66
  return diagnostic;
57
67
  };
68
+ /**
69
+ * Determine if the provided diagnostics have any build errors
70
+ * @param diagnostics the diagnostics to inspect
71
+ * @returns true if any of the diagnostics in the list provided are errors that did not occur at runtime. false
72
+ * otherwise.
73
+ */
58
74
  const hasError = (diagnostics) => {
59
75
  if (diagnostics == null || diagnostics.length === 0) {
60
76
  return false;
@@ -466,7 +482,7 @@ const getNpmConfigEnvArgs = (sys) => {
466
482
  const dependencies = [
467
483
  {
468
484
  name: "@stencil/core",
469
- version: "2.12.0",
485
+ version: "2.12.1",
470
486
  main: "compiler/stencil.js",
471
487
  resources: [
472
488
  "package.json",
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/cli",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Stencil CLI.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/compiler",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Stencil Compiler.",
5
5
  "main": "./stencil.js",
6
6
  "types": "./stencil.d.ts",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.12.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v2.12.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  (function(exports) {
5
5
  'use strict';
@@ -832,6 +832,12 @@ const isRootPath = (p) => p === '/' || windowsPathRegex.test(p);
832
832
  // https://github.com/nodejs/node/blob/5883a59b21a97e8b7339f435c977155a2c29ba8d/lib/path.js#L43
833
833
  const windowsPathRegex = /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?[\\/]$/;
834
834
 
835
+ /**
836
+ * Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
837
+ * @param compilerCtx the current compiler context
838
+ * @param diagnostics the diagnostics to normalize
839
+ * @returns the normalize documents
840
+ */
835
841
  const normalizeDiagnostics = (compilerCtx, diagnostics) => {
836
842
  const normalizedErrors = [];
837
843
  const normalizedOthers = [];
@@ -853,6 +859,13 @@ const normalizeDiagnostics = (compilerCtx, diagnostics) => {
853
859
  }
854
860
  return [...normalizedErrors, ...normalizedOthers];
855
861
  };
862
+ /**
863
+ * Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
864
+ * updating build failure contexts
865
+ * @param compilerCtx the current compiler
866
+ * @param diagnostic the diagnostic to normalize
867
+ * @returns the altered diagnostic
868
+ */
856
869
  const normalizeDiagnostic = (compilerCtx, diagnostic) => {
857
870
  if (diagnostic.messageText) {
858
871
  if (typeof diagnostic.messageText.message === 'string') {
@@ -915,6 +928,11 @@ const normalizeDiagnostic = (compilerCtx, diagnostic) => {
915
928
  }
916
929
  return diagnostic;
917
930
  };
931
+ /**
932
+ * Split a corpus by newlines. Carriage returns are treated a newlines.
933
+ * @param sourceText the corpus to split
934
+ * @returns the split text
935
+ */
918
936
  const splitLineBreaks = (sourceText) => {
919
937
  if (typeof sourceText !== 'string')
920
938
  return [];
@@ -938,6 +956,16 @@ const escapeHtml = (unsafe) => {
938
956
  };
939
957
  const MAX_ERRORS = 25;
940
958
 
959
+ /**
960
+ * Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
961
+ * detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
962
+ * to attach the specifics of the error message.
963
+ *
964
+ * The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
965
+ *
966
+ * @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
967
+ * @returns the created `Diagnostic`
968
+ */
941
969
  const buildError = (diagnostics) => {
942
970
  const diagnostic = {
943
971
  level: 'error',
@@ -953,6 +981,16 @@ const buildError = (diagnostics) => {
953
981
  }
954
982
  return diagnostic;
955
983
  };
984
+ /**
985
+ * Builds a template `Diagnostic` entity for a build warning. The created `Diagnostic` is returned, and have little
986
+ * detail attached to it regarding the specifics of the warning - it is the responsibility of the caller of this method
987
+ * to attach the specifics of the warning message.
988
+ *
989
+ * The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
990
+ *
991
+ * @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
992
+ * @returns the created `Diagnostic`
993
+ */
956
994
  const buildWarn = (diagnostics) => {
957
995
  const diagnostic = {
958
996
  level: 'warn',
@@ -1047,12 +1085,23 @@ const catchError = (diagnostics, err, msg) => {
1047
1085
  }
1048
1086
  return diagnostic;
1049
1087
  };
1088
+ /**
1089
+ * Determine if the provided diagnostics have any build errors
1090
+ * @param diagnostics the diagnostics to inspect
1091
+ * @returns true if any of the diagnostics in the list provided are errors that did not occur at runtime. false
1092
+ * otherwise.
1093
+ */
1050
1094
  const hasError = (diagnostics) => {
1051
1095
  if (diagnostics == null || diagnostics.length === 0) {
1052
1096
  return false;
1053
1097
  }
1054
1098
  return diagnostics.some((d) => d.level === 'error' && d.type !== 'runtime');
1055
1099
  };
1100
+ /**
1101
+ * Determine if the provided diagnostics have any warnings
1102
+ * @param diagnostics the diagnostics to inspect
1103
+ * @returns true if any of the diagnostics in the list provided are warnings. false otherwise.
1104
+ */
1056
1105
  const hasWarning = (diagnostics) => {
1057
1106
  if (diagnostics == null || diagnostics.length === 0) {
1058
1107
  return false;
@@ -1355,6 +1404,12 @@ const normalizeFsPathQuery = (importPath) => {
1355
1404
  };
1356
1405
  };
1357
1406
 
1407
+ /**
1408
+ * Augment a `Diagnostic` with information from a `Node` in the AST to provide richer error information
1409
+ * @param d the diagnostic to augment
1410
+ * @param node the node to augment with additional information
1411
+ * @returns the augmented diagnostic
1412
+ */
1358
1413
  const augmentDiagnosticWithNode = (d, node) => {
1359
1414
  if (!node) {
1360
1415
  return d;
@@ -1376,6 +1431,7 @@ const augmentDiagnosticWithNode = (d, node) => {
1376
1431
  errorCharStart: posStart.character,
1377
1432
  errorLength: Math.max(end - start, 1),
1378
1433
  };
1434
+ // store metadata for line number and character index where the error occurred
1379
1435
  d.lineNumber = errorLine.lineNumber;
1380
1436
  d.columnNumber = errorLine.errorCharStart + 1;
1381
1437
  d.lines.push(errorLine);
@@ -1383,6 +1439,8 @@ const augmentDiagnosticWithNode = (d, node) => {
1383
1439
  errorLine.errorLength = 1;
1384
1440
  errorLine.errorCharStart--;
1385
1441
  }
1442
+ // if the error did not occur on the first line of the file, add metadata for the line of code preceding the line
1443
+ // where the error was detected to provide the user with additional context
1386
1444
  if (errorLine.lineIndex > 0) {
1387
1445
  const previousLine = {
1388
1446
  lineIndex: errorLine.lineIndex - 1,
@@ -1393,6 +1451,8 @@ const augmentDiagnosticWithNode = (d, node) => {
1393
1451
  };
1394
1452
  d.lines.unshift(previousLine);
1395
1453
  }
1454
+ // if the error did not occur on the last line of the file, add metadata for the line of code following the line
1455
+ // where the error was detected to provide the user with additional context
1396
1456
  if (errorLine.lineIndex + 1 < srcLines.length) {
1397
1457
  const nextLine = {
1398
1458
  lineIndex: errorLine.lineIndex + 1,
@@ -3917,7 +3977,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
3917
3977
  };
3918
3978
  };
3919
3979
 
3920
- const buildId = '20211213135416';
3980
+ const buildId = '20220104181231';
3921
3981
  const minfyJsId = 'terser5.6.1_7';
3922
3982
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.8_7';
3923
3983
  const parse5Version = '6.0.1';
@@ -3925,8 +3985,8 @@ const rollupVersion = '2.42.3';
3925
3985
  const sizzleVersion = '2.42.3';
3926
3986
  const terserVersion = '5.6.1';
3927
3987
  const typescriptVersion = '4.3.5';
3928
- const vermoji = '';
3929
- const version$3 = '2.12.0';
3988
+ const vermoji = '🍔';
3989
+ const version$3 = '2.12.1';
3930
3990
  const versions = {
3931
3991
  stencil: version$3,
3932
3992
  parse5: parse5Version,
@@ -13769,6 +13829,11 @@ function relativePath$1(config, file) {
13769
13829
  return config.sys.normalizePath(config.sys.platformPath.relative(config.rootDir, file));
13770
13830
  }
13771
13831
 
13832
+ /**
13833
+ * Finish a build as having completed successfully
13834
+ * @param buildCtx the build context for the build being aborted
13835
+ * @returns the build results
13836
+ */
13772
13837
  const buildFinish = async (buildCtx) => {
13773
13838
  const results = await buildDone(buildCtx.config, buildCtx.compilerCtx, buildCtx, false);
13774
13839
  const buildLog = {
@@ -13779,9 +13844,23 @@ const buildFinish = async (buildCtx) => {
13779
13844
  buildCtx.compilerCtx.events.emit('buildLog', buildLog);
13780
13845
  return results;
13781
13846
  };
13847
+ /**
13848
+ * Finish a build early due to failure. During the build process, a fatal error has occurred where the compiler cannot
13849
+ * continue further
13850
+ * @param buildCtx the build context for the build being aborted
13851
+ * @returns the build results
13852
+ */
13782
13853
  const buildAbort = (buildCtx) => {
13783
13854
  return buildDone(buildCtx.config, buildCtx.compilerCtx, buildCtx, true);
13784
13855
  };
13856
+ /**
13857
+ * Mark a build as done
13858
+ * @param config the Stencil configuration used for the build
13859
+ * @param compilerCtx the compiler context associated with the build
13860
+ * @param buildCtx the build context associated with the build to mark as done
13861
+ * @param aborted true if the build ended early due to failure, false otherwise
13862
+ * @returns the build results
13863
+ */
13785
13864
  const buildDone = async (config, compilerCtx, buildCtx, aborted) => {
13786
13865
  if (buildCtx.hasFinished && buildCtx.buildResults) {
13787
13866
  // we've already marked this build as finished and
@@ -13799,7 +13878,7 @@ const buildDone = async (config, compilerCtx, buildCtx, aborted) => {
13799
13878
  if (!buildCtx.hasFinished) {
13800
13879
  // haven't set this build as finished yet
13801
13880
  if (!buildCtx.hasPrintedResults) {
13802
- cleanDiagnostics(config, buildCtx.buildResults.diagnostics);
13881
+ cleanDiagnosticsRelativePath(config, buildCtx.buildResults.diagnostics);
13803
13882
  config.logger.printDiagnostics(buildCtx.buildResults.diagnostics);
13804
13883
  }
13805
13884
  const hasChanges = buildCtx.hasScriptChanges || buildCtx.hasStyleChanges;
@@ -13808,7 +13887,7 @@ const buildDone = async (config, compilerCtx, buildCtx, aborted) => {
13808
13887
  // and this build hasn't been aborted
13809
13888
  logHmr(config.logger, buildCtx);
13810
13889
  }
13811
- // create a nice pretty message stating what happend
13890
+ // create a nice pretty message stating what happened
13812
13891
  const buildText = buildCtx.isRebuild ? 'rebuild' : 'build';
13813
13892
  const watchText = config.watch ? ', watching for changes...' : '';
13814
13893
  let buildStatus = 'finished';
@@ -13894,7 +13973,12 @@ const cleanupUpdateMsg = (logger, msg, fileNames) => {
13894
13973
  logger.info(`${msg}: ${logger.cyan(fileMsg)}`);
13895
13974
  }
13896
13975
  };
13897
- const cleanDiagnostics = (config, diagnostics) => {
13976
+ /**
13977
+ * Update the relative file path for diagnostics. The updates are done in place.
13978
+ * @param config the Stencil configuration associated with the current build
13979
+ * @param diagnostics the diagnostics to update
13980
+ */
13981
+ const cleanDiagnosticsRelativePath = (config, diagnostics) => {
13898
13982
  diagnostics.forEach((diagnostic) => {
13899
13983
  if (!diagnostic.relFilePath && !isRemoteUrl(diagnostic.absFilePath) && diagnostic.absFilePath && config.rootDir) {
13900
13984
  diagnostic.relFilePath = relative$1(config.rootDir, diagnostic.absFilePath);
@@ -63574,7 +63658,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
63574
63658
  const dependencies = [
63575
63659
  {
63576
63660
  name: "@stencil/core",
63577
- version: "2.12.0",
63661
+ version: "2.12.1",
63578
63662
  main: "compiler/stencil.js",
63579
63663
  resources: [
63580
63664
  "package.json",