@tsslint/core 1.1.4 → 1.1.5

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.
Files changed (2) hide show
  1. package/lib/watch.js +49 -5
  2. package/package.json +3 -3
package/lib/watch.js CHANGED
@@ -4,7 +4,8 @@ exports.watchConfigFile = watchConfigFile;
4
4
  const esbuild = require("esbuild");
5
5
  const _path = require("path");
6
6
  const fs = require("fs");
7
- const url = require("url");
7
+ const _url = require("url");
8
+ const ErrorStackParser = require("error-stack-parser");
8
9
  async function watchConfigFile(configFilePath, onBuild, watch = true, createHash = btoa, logger = console) {
9
10
  let start;
10
11
  const outDir = _path.resolve(configFilePath, '..', 'node_modules', '.tsslint');
@@ -14,12 +15,55 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
14
15
  const t1 = Date.now() - start;
15
16
  start = Date.now();
16
17
  let config;
18
+ for (const error of [
19
+ ...result.errors,
20
+ ...result.warnings,
21
+ ]) {
22
+ if (error.id) {
23
+ error.id = 'esbuild:' + error.id;
24
+ }
25
+ else {
26
+ error.id = 'config-build-error';
27
+ }
28
+ }
17
29
  if (!result.errors.length) {
18
30
  try {
19
- config = (await import(url.pathToFileURL(outFile).toString() + '?time=' + Date.now())).default;
31
+ config = (await import(_url.pathToFileURL(outFile).toString() + '?time=' + Date.now())).default;
20
32
  }
21
33
  catch (e) {
22
- result.errors.push({ text: String(e) });
34
+ if (e.stack) {
35
+ const stack = ErrorStackParser.parse(e)[0];
36
+ if (stack.fileName && stack.lineNumber !== undefined && stack.columnNumber !== undefined) {
37
+ let fileName = stack.fileName
38
+ .replace(/\\/g, '/')
39
+ .split('?time=')[0];
40
+ if (fileName.startsWith('file://')) {
41
+ fileName = fileName.substring('file://'.length);
42
+ }
43
+ result.errors.push({
44
+ id: 'config-import-error',
45
+ text: String(e),
46
+ location: {
47
+ file: fileName,
48
+ line: stack.lineNumber,
49
+ column: stack.columnNumber - 1,
50
+ lineText: '',
51
+ },
52
+ });
53
+ }
54
+ else {
55
+ result.errors.push({
56
+ id: 'config-import-error',
57
+ text: String(e),
58
+ });
59
+ }
60
+ }
61
+ else {
62
+ result.errors.push({
63
+ id: 'config-import-error',
64
+ text: String(e),
65
+ });
66
+ }
23
67
  }
24
68
  }
25
69
  const t2 = Date.now() - start;
@@ -53,7 +97,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
53
97
  fs.writeFileSync(cachePath, text, 'utf8');
54
98
  }
55
99
  return {
56
- path: cachePath,
100
+ path: _url.pathToFileURL(cachePath).toString(),
57
101
  external: true,
58
102
  };
59
103
  });
@@ -63,7 +107,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
63
107
  const maybeJsPath = require.resolve(path, { paths: [resolveDir] });
64
108
  if (!isTsFile(maybeJsPath) && fs.existsSync(maybeJsPath)) {
65
109
  return {
66
- path: url.pathToFileURL(maybeJsPath).toString(),
110
+ path: _url.pathToFileURL(maybeJsPath).toString(),
67
111
  external: true,
68
112
  };
69
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/core",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,11 +12,11 @@
12
12
  "directory": "packages/core"
13
13
  },
14
14
  "dependencies": {
15
- "@tsslint/types": "1.1.4",
15
+ "@tsslint/types": "1.1.5",
16
16
  "error-stack-parser": "^2.1.4",
17
17
  "esbuild": ">=0.17.0",
18
18
  "minimatch": "^10.0.1",
19
19
  "source-map-support": "^0.5.21"
20
20
  },
21
- "gitHead": "03d4e7480fc96c6322d436d34a4af73cb5bc25f2"
21
+ "gitHead": "7aa702de750c8efee2681fbabafcab3da344df03"
22
22
  }