@tsslint/core 1.1.3 → 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 +50 -9
  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,20 +15,61 @@ 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;
26
70
  logger.log(`Built ${_path.relative(process.cwd(), configFilePath)} in ${t1}ms, loaded ${config ? 'successfully' : 'with errors'} in ${t2}ms`);
27
71
  onBuild(config, result);
28
72
  };
29
- const cacheDir = _path.resolve(outDir, 'http_resources');
30
- const cachePathToOriginalPath = new Map();
31
73
  const ctx = await esbuild.context({
32
74
  entryPoints: [configFilePath],
33
75
  bundle: true,
@@ -42,8 +84,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
42
84
  start = Date.now();
43
85
  });
44
86
  build.onResolve({ filter: /^https?:\/\// }, async ({ path: url }) => {
45
- const cachePath = _path.join(cacheDir, createHash(_path.posix.dirname(url)), _path.posix.basename(url));
46
- cachePathToOriginalPath.set(cachePath, url);
87
+ const cachePath = _path.join(outDir, url.split('://')[0], ...url.split('://')[1].split('/'));
47
88
  if (!fs.existsSync(cachePath)) {
48
89
  console.time('Download ' + url);
49
90
  const response = await fetch(url);
@@ -56,7 +97,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
56
97
  fs.writeFileSync(cachePath, text, 'utf8');
57
98
  }
58
99
  return {
59
- path: cachePath,
100
+ path: _url.pathToFileURL(cachePath).toString(),
60
101
  external: true,
61
102
  };
62
103
  });
@@ -66,7 +107,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
66
107
  const maybeJsPath = require.resolve(path, { paths: [resolveDir] });
67
108
  if (!isTsFile(maybeJsPath) && fs.existsSync(maybeJsPath)) {
68
109
  return {
69
- path: url.pathToFileURL(maybeJsPath).toString(),
110
+ path: _url.pathToFileURL(maybeJsPath).toString(),
70
111
  external: true,
71
112
  };
72
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/core",
3
- "version": "1.1.3",
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.3",
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": "2711b634ed851fe9b1dcaad2cf7d7cf1b42871b2"
21
+ "gitHead": "7aa702de750c8efee2681fbabafcab3da344df03"
22
22
  }