@marko/type-check 2.0.1 → 2.1.0
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/dist/cli.js +42 -8
- package/dist/run.d.ts +1 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -49,7 +49,7 @@ var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
|
49
49
|
var isRemapExtensionReg = /\.ts$/;
|
|
50
50
|
var isSourceMapExtensionReg = /\.map$/;
|
|
51
51
|
var skipRemapExtensionsReg = /\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/;
|
|
52
|
-
var extractCache = /* @__PURE__ */ new
|
|
52
|
+
var extractCache = /* @__PURE__ */ new Map();
|
|
53
53
|
var requiredTSCompilerOptions = {
|
|
54
54
|
allowJs: true,
|
|
55
55
|
composite: true,
|
|
@@ -60,12 +60,42 @@ var requiredTSCompilerOptions = {
|
|
|
60
60
|
allowNonTsExtensions: true
|
|
61
61
|
};
|
|
62
62
|
function run(opts) {
|
|
63
|
+
var _a, _b;
|
|
63
64
|
const {
|
|
64
65
|
display = Display.codeframe,
|
|
65
66
|
project: configFile = findRootConfigFile("tsconfig.json") || findRootConfigFile("jsconfig.json")
|
|
66
67
|
} = opts;
|
|
67
|
-
if (!configFile)
|
|
68
|
+
if (!configFile) {
|
|
68
69
|
throw new Error("Could not find tsconfig.json or jsconfig.json");
|
|
70
|
+
}
|
|
71
|
+
if (opts.generateTrace) {
|
|
72
|
+
(_b = (_a = import_tsserverlibrary.default).startTracing) == null ? void 0 : _b.call(
|
|
73
|
+
_a,
|
|
74
|
+
"build",
|
|
75
|
+
import_path.default.resolve(opts.generateTrace),
|
|
76
|
+
configFile
|
|
77
|
+
);
|
|
78
|
+
const tracing = import_tsserverlibrary.default.tracing;
|
|
79
|
+
if (!tracing) {
|
|
80
|
+
throw new Error("generateTrace not available in TypeScript compiler.");
|
|
81
|
+
}
|
|
82
|
+
const { push } = tracing;
|
|
83
|
+
tracing.push = (phase, name, args2, separateBeginAndEnd) => {
|
|
84
|
+
if (args2 && typeof args2 === "object" && "pos" in args2 && typeof args2.pos === "number" && "end" in args2 && typeof args2.end === "number") {
|
|
85
|
+
const fileName = "path" in args2 ? args2.path : "fileName" in args2 ? args2.fileName : void 0;
|
|
86
|
+
if (typeof fileName === "string") {
|
|
87
|
+
const extracted = extractCache.get(getCanonicalFileName(fileName));
|
|
88
|
+
if (extracted) {
|
|
89
|
+
args2.generatedPos = args2.pos;
|
|
90
|
+
args2.generatedEnd = args2.end;
|
|
91
|
+
args2.pos = extracted.sourceOffsetAt(args2.pos);
|
|
92
|
+
args2.end = extracted.sourceOffsetAt(args2.end);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return push.call(tracing, phase, name, args2, separateBeginAndEnd);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
69
99
|
const formatSettings = import_tsserverlibrary.default.getDefaultFormatCodeSettings(
|
|
70
100
|
import_tsserverlibrary.default.sys.newLine
|
|
71
101
|
);
|
|
@@ -255,7 +285,7 @@ function run(opts) {
|
|
|
255
285
|
processor.getScriptKind(fileName)
|
|
256
286
|
);
|
|
257
287
|
sourceFile.version = import_crypto.default.createHash("md5").update(extractedCode).digest("hex");
|
|
258
|
-
extractCache.set(
|
|
288
|
+
extractCache.set(getCanonicalFileName(fileName), extracted);
|
|
259
289
|
return sourceFile;
|
|
260
290
|
}
|
|
261
291
|
return getSourceFile(
|
|
@@ -317,7 +347,7 @@ function run(opts) {
|
|
|
317
347
|
outFileName = fileName.slice(0, -inExt.length) + (isDts ? ".d" : "") + processorExt;
|
|
318
348
|
}
|
|
319
349
|
const extracted = extractCache.get(
|
|
320
|
-
|
|
350
|
+
getCanonicalFileName(sourceFile.fileName)
|
|
321
351
|
);
|
|
322
352
|
const printContext = {
|
|
323
353
|
extracted,
|
|
@@ -368,7 +398,7 @@ function run(opts) {
|
|
|
368
398
|
return ext ? processors[ext] : void 0;
|
|
369
399
|
};
|
|
370
400
|
solutionHost.getParsedCommandLine = (fileName) => {
|
|
371
|
-
var
|
|
401
|
+
var _a2, _b2;
|
|
372
402
|
const parsedCommandLine = import_tsserverlibrary.default.getParsedCommandLineOfConfigFile(
|
|
373
403
|
fileName,
|
|
374
404
|
requiredTSCompilerOptions,
|
|
@@ -385,7 +415,7 @@ function run(opts) {
|
|
|
385
415
|
if (!parsedCommandLine) return;
|
|
386
416
|
const finalRootNames = new Set(parsedCommandLine.fileNames);
|
|
387
417
|
for (const name in processors) {
|
|
388
|
-
const rootNames = (
|
|
418
|
+
const rootNames = (_b2 = (_a2 = processors[name]).getRootNames) == null ? void 0 : _b2.call(_a2);
|
|
389
419
|
if (rootNames) {
|
|
390
420
|
for (const rootName of rootNames) {
|
|
391
421
|
finalRootNames.add(rootName);
|
|
@@ -413,7 +443,9 @@ function reportDiagnostic(report, diag) {
|
|
|
413
443
|
let code = diag.file.text;
|
|
414
444
|
let loc = void 0;
|
|
415
445
|
if (diag.start !== void 0) {
|
|
416
|
-
const extracted = extractCache.get(
|
|
446
|
+
const extracted = extractCache.get(
|
|
447
|
+
getCanonicalFileName(diag.file.fileName)
|
|
448
|
+
);
|
|
417
449
|
if (extracted) {
|
|
418
450
|
loc = extracted.sourceLocationAt(
|
|
419
451
|
diag.start,
|
|
@@ -515,6 +547,7 @@ var args = (0, import_arg.default)(
|
|
|
515
547
|
{
|
|
516
548
|
"--project": String,
|
|
517
549
|
"--display": String,
|
|
550
|
+
"--generateTrace": String,
|
|
518
551
|
"--help": Boolean,
|
|
519
552
|
"--version": Boolean,
|
|
520
553
|
"-p": "--project",
|
|
@@ -575,6 +608,7 @@ For more information, visit ${import_kleur2.default.blue(
|
|
|
575
608
|
);
|
|
576
609
|
} else {
|
|
577
610
|
const {
|
|
611
|
+
"--generateTrace": generateTrace,
|
|
578
612
|
"--display": display = process.env.CI ? Display.condensed : Display.codeframe
|
|
579
613
|
} = args;
|
|
580
614
|
let { "--project": project } = args;
|
|
@@ -585,7 +619,7 @@ For more information, visit ${import_kleur2.default.blue(
|
|
|
585
619
|
}
|
|
586
620
|
}
|
|
587
621
|
checkDisplay(display);
|
|
588
|
-
run({ project, display });
|
|
622
|
+
run({ generateTrace, project, display });
|
|
589
623
|
}
|
|
590
624
|
function checkDisplay(display) {
|
|
591
625
|
if (display && Display[display] === void 0) {
|
package/dist/run.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/type-check",
|
|
3
3
|
"description": "A CLI to type check Marko projects",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/code-frame": "^7.27.1",
|
|
8
8
|
"@luxass/strip-json-comments": "^1.4.0",
|
|
9
|
-
"@marko/language-tools": "^2.5.
|
|
9
|
+
"@marko/language-tools": "^2.5.27",
|
|
10
10
|
"arg": "^5.0.2",
|
|
11
11
|
"kleur": "^4.1.5",
|
|
12
12
|
"typescript": "^5.8.3"
|