@cplieger/deadset-ts 8.0.0-dev.15 → 8.0.0-dev.16
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/src/analysis.js +41 -37
- package/dist/src/commands/read.js +6 -7
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +3 -1
- package/dist/src/contract/config.generated.js +1 -1
- package/dist/src/contract/contract.generated.js +119 -2
- package/dist/src/dependencies.js +79 -48
- package/dist/src/entries/build-scripts.js +222 -0
- package/dist/src/{configuration-files.js → entries/configuration-files.js} +20 -58
- package/dist/src/{convention-rows.js → entries/convention-rows.js} +120 -27
- package/dist/src/entries/conventions.js +739 -0
- package/dist/src/{html-entries.js → entries/html-entries.js} +3 -3
- package/dist/src/{mdx-entries.js → entries/mdx-entries.js} +2 -2
- package/dist/src/entries/run-directories.js +77 -0
- package/dist/src/entries/sources.js +144 -0
- package/dist/src/entries/static-module.js +669 -0
- package/dist/src/entries/test-runners.js +684 -0
- package/dist/src/{workflow-steps.js → entries/workflow-steps.js} +18 -8
- package/dist/src/extensions.js +37 -0
- package/dist/src/facts.js +38 -0
- package/dist/src/findings/emitters.js +5 -8
- package/dist/src/findings/self-check.js +36 -20
- package/dist/src/findings-pass.js +5 -6
- package/dist/src/framework-lifecycle.js +1 -1
- package/dist/src/fs/manifest.js +15 -20
- package/dist/src/generated-file.js +172 -29
- package/dist/src/graph.js +2 -4
- package/dist/src/index.js +1 -1
- package/dist/src/injection-container.js +1 -1
- package/dist/src/inventory/commonjs.js +62 -17
- package/dist/src/inventory/enumerate.js +2 -1
- package/dist/src/javascript-file.js +26 -11
- package/dist/src/load/classify.js +28 -9
- package/dist/src/load/diagnostics.js +8 -1
- package/dist/src/load/discover.js +15 -7
- package/dist/src/load/plan.js +2 -2
- package/dist/src/load/synthesize.js +5 -5
- package/dist/src/load/workspace-manifests.js +1 -1
- package/dist/src/matrix.js +6 -13
- package/dist/src/outside-tests.js +1 -1
- package/dist/src/paths.js +16 -0
- package/dist/src/platform-calls.js +78 -0
- package/dist/src/platform-symbols.js +140 -0
- package/dist/src/references.js +202 -32
- package/dist/src/resolve.js +1 -1
- package/dist/src/{configured-declarations.js → roots/configured-declarations.js} +4 -4
- package/dist/src/{entry-point-gaps.js → roots/entry-point-gaps.js} +5 -8
- package/dist/src/{manifest.js → roots/manifest.js} +4 -4
- package/dist/src/roots/published-reach.js +412 -0
- package/dist/src/roots/root-set.js +489 -0
- package/dist/src/roots/unseen-loads.js +208 -0
- package/dist/src/serialization-contract.js +1 -1
- package/dist/src/source-files.js +5 -9
- package/dist/src/suppress.js +30 -32
- package/dist/src/test-support.js +4 -2
- package/dist/src/verbs/analyze.js +13 -1
- package/dist/src/verbs/describe.js +5 -3
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/analysis.ts +75 -52
- package/src/automatic-types.ts +1 -1
- package/src/commands/read.ts +6 -8
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +4 -0
- package/src/contract/config.generated.ts +1 -1
- package/src/contract/contract.generated.ts +138 -2
- package/src/dependencies.ts +96 -49
- package/src/entries/build-scripts.ts +292 -0
- package/src/{configuration-files.ts → entries/configuration-files.ts} +23 -75
- package/src/{convention-rows.ts → entries/convention-rows.ts} +167 -28
- package/src/{conventions.ts → entries/conventions.ts} +347 -522
- package/src/{html-entries.ts → entries/html-entries.ts} +5 -5
- package/src/{mdx-entries.ts → entries/mdx-entries.ts} +4 -4
- package/src/entries/run-directories.ts +108 -0
- package/src/entries/sources.ts +266 -0
- package/src/entries/static-module.ts +857 -0
- package/src/entries/test-runners.ts +868 -0
- package/src/{workflow-steps.ts → entries/workflow-steps.ts} +29 -11
- package/src/exempt.ts +3 -2
- package/src/extensions.ts +45 -0
- package/src/facts.ts +44 -0
- package/src/file-facts.ts +1 -1
- package/src/findings/emitters.ts +14 -10
- package/src/findings/self-check.ts +41 -22
- package/src/findings/visibility-narrowing.ts +1 -1
- package/src/findings-pass.ts +5 -12
- package/src/framework-lifecycle.ts +1 -1
- package/src/fs/manifest.ts +25 -21
- package/src/generated-file.ts +240 -36
- package/src/graph.ts +3 -5
- package/src/index.ts +1 -1
- package/src/injection-container.ts +1 -1
- package/src/inventory/commonjs.ts +102 -17
- package/src/inventory/enumerate.ts +2 -1
- package/src/javascript-file.ts +29 -12
- package/src/load/classify.ts +49 -13
- package/src/load/diagnostics.ts +11 -1
- package/src/load/discover.ts +27 -11
- package/src/load/plan.ts +11 -2
- package/src/load/synthesize.ts +6 -6
- package/src/load/test-globals.ts +1 -1
- package/src/load/workspace-manifests.ts +1 -1
- package/src/load/workspace-run.ts +1 -1
- package/src/matrix.ts +7 -14
- package/src/outside-tests.ts +1 -1
- package/src/paths.ts +18 -0
- package/src/platform-calls.ts +119 -0
- package/src/platform-symbols.ts +205 -0
- package/src/references.ts +281 -34
- package/src/report.ts +1 -1
- package/src/resolve.ts +1 -1
- package/src/{configured-declarations.ts → roots/configured-declarations.ts} +7 -7
- package/src/{entry-point-gaps.ts → roots/entry-point-gaps.ts} +5 -8
- package/src/{manifest.ts → roots/manifest.ts} +5 -5
- package/src/roots/published-reach.ts +481 -0
- package/src/{roots.ts → roots/root-set.ts} +203 -630
- package/src/roots/unseen-loads.ts +307 -0
- package/src/serialization-contract.ts +1 -1
- package/src/source-files.ts +5 -10
- package/src/suppress.ts +48 -33
- package/src/test-support.ts +8 -3
- package/src/verbs/analyze.ts +17 -4
- package/src/verbs/describe.ts +5 -2
- package/src/verbs/explain.ts +1 -1
- package/dist/src/build-scripts.js +0 -418
- package/dist/src/conventions.js +0 -907
- package/dist/src/entry-points.js +0 -444
- package/dist/src/own-body.js +0 -28
- package/dist/src/roots.js +0 -865
- package/dist/src/unseen-loads.js +0 -189
- package/src/build-scripts.ts +0 -536
- package/src/entry-points.ts +0 -584
- package/src/own-body.ts +0 -42
- package/src/unseen-loads.ts +0 -282
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { isArrayBindingPattern, isArrowFunction, isAssignmentOperator, isAwaitExpression, isBinaryExpression, isBindingElement, isCallExpression, isClassDeclaration, isClassExpression, isClassStaticBlockDeclaration, isComputedPropertyName, isDeleteExpression, isElementAccessExpression, isEqualityOperator, isExpressionStatement, isForOfStatement, isFunctionDeclaration, isFunctionExpression, isFunctionLikeDeclaration, isGetAccessorDeclaration, isIdentifier, isIfStatement, isMetaProperty, isMethodDeclaration, isNoSubstitutionTemplateLiteral, isNumericLiteral, isObjectBindingPattern, isObjectLiteralExpression, isPostfixUnaryExpression, isPrefixUnaryExpression, isPropertyAccessExpression, isPropertyAssignment, isSetAccessorDeclaration, isShorthandPropertyAssignment, isSourceFile, isSpreadAssignment, isStringLiteral, isTypeOfExpression, isVariableDeclaration, isVariableDeclarationList, isVariableStatement, ModifierFlags, NodeFlags, SyntaxKind, } from "@typescript/native/ast";
|
|
2
2
|
import { componentOf, modifiersOf, } from "../inventory.js";
|
|
3
|
+
import { callsPlatformBy, lexicalBinding, writtenName } from "../platform-calls.js";
|
|
3
4
|
import { spellsNoBinding } from "../spelled-names.js";
|
|
4
5
|
import { unwrapped } from "../unwrap.js";
|
|
5
6
|
/**
|
|
6
7
|
* The export table of a CommonJS file: the module value `module.exports` is assigned and
|
|
7
8
|
* the properties written on it, read from the top-level unconditional statements in order,
|
|
8
9
|
* as Node runs them (https://nodejs.org/api/modules.html#moduleexports). Each entry is
|
|
9
|
-
* keyed by the node that writes it,
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* keyed by the node that writes it, the checker's declaration of the export where it binds
|
|
11
|
+
* one. Any other write of the exports opens the table: its entries are kept and the file is
|
|
12
|
+
* listed open. `declarationOf` reads a `require()` call through the file's own scopes.
|
|
12
13
|
*/
|
|
13
|
-
export function commonJS(typeIsModule, resolved) {
|
|
14
|
+
export function commonJS(typeIsModule, resolved, declarationOf) {
|
|
14
15
|
return {
|
|
15
16
|
declare(file, owner, into) {
|
|
16
17
|
if (!isCommonJS(file, owner.position.path, typeIsModule)) {
|
|
@@ -18,7 +19,7 @@ export function commonJS(typeIsModule, resolved) {
|
|
|
18
19
|
}
|
|
19
20
|
const bound = boundOccurrences(file, resolved);
|
|
20
21
|
const free = (node) => !bound.has(node);
|
|
21
|
-
const table = readTable(file, free, topLevelDeclarations(file));
|
|
22
|
+
const table = readTable(file, free, topLevelDeclarations(file), lexicalBinding(declarationOf));
|
|
22
23
|
const open = table.open || opens(file, free, table.modelled);
|
|
23
24
|
for (const entry of table.entries.values()) {
|
|
24
25
|
const record = into.declare(entry.node, owner, entry.kind, entry.name, {
|
|
@@ -176,24 +177,33 @@ function topLevelDeclarations(file) {
|
|
|
176
177
|
}
|
|
177
178
|
const DEFAULT = { text: "default", computed: false };
|
|
178
179
|
/** The table one file's top-level unconditional statements write, in order. */
|
|
179
|
-
function readTable(file, isFree, declarations) {
|
|
180
|
+
function readTable(file, isFree, declarations, bindingOf) {
|
|
180
181
|
const entries = new Map();
|
|
181
182
|
const modelled = new Set();
|
|
183
|
+
// Written inside the closures below, which the compiler's narrowing does not follow.
|
|
182
184
|
let open = false;
|
|
183
185
|
let aliasing = true;
|
|
186
|
+
let whole;
|
|
187
|
+
let wholeOpen = false;
|
|
184
188
|
const free = (node, name) => isIdentifier(node) && node.text === name && isFree(node);
|
|
185
189
|
const isModuleExports = (node) => isPropertyAccessExpression(node) &&
|
|
186
190
|
free(node.expression, "module") &&
|
|
187
191
|
node.name.text === "exports";
|
|
188
|
-
const isRequire = (node) =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
const isRequire = (node) => {
|
|
193
|
+
if (!isCallExpression(node) || node.arguments.length !== 1) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
const [argument] = node.arguments;
|
|
197
|
+
const callee = writtenName(node.expression);
|
|
198
|
+
return (argument !== undefined &&
|
|
199
|
+
isLiteralText(argument) &&
|
|
200
|
+
callee !== undefined &&
|
|
201
|
+
callsPlatformBy("require", callee, bindingOf));
|
|
202
|
+
};
|
|
193
203
|
/** What a value written under one key declares. */
|
|
194
204
|
const entryOf = (component, node, name, value) => {
|
|
195
205
|
const held = value === undefined ? undefined : unwrapped(value);
|
|
196
|
-
const base = { node, name, component, localName: undefined };
|
|
206
|
+
const base = { node, name, component, localName: undefined, value };
|
|
197
207
|
if (held === undefined) {
|
|
198
208
|
return { ...base, kind: "variable" };
|
|
199
209
|
}
|
|
@@ -245,6 +255,7 @@ function readTable(file, isFree, declarations) {
|
|
|
245
255
|
/** The module value one assignment writes, placed at the `exports` name it assigns. */
|
|
246
256
|
const moduleValue = (node, name) => {
|
|
247
257
|
entries.clear();
|
|
258
|
+
whole = node.right;
|
|
248
259
|
const value = unwrapped(node.right);
|
|
249
260
|
if (isRequire(value)) {
|
|
250
261
|
return;
|
|
@@ -253,7 +264,7 @@ function readTable(file, isFree, declarations) {
|
|
|
253
264
|
value.properties.forEach(literalProperty);
|
|
254
265
|
return;
|
|
255
266
|
}
|
|
256
|
-
const base = { node, name, component: DEFAULT };
|
|
267
|
+
const base = { node, name, component: DEFAULT, value: node.right };
|
|
257
268
|
const target = isIdentifier(value) ? declarations.get(value.text) : undefined;
|
|
258
269
|
if (target !== undefined) {
|
|
259
270
|
entries.set("default", { ...base, localName: undefined, kind: "export-alias", target });
|
|
@@ -273,7 +284,7 @@ function readTable(file, isFree, declarations) {
|
|
|
273
284
|
});
|
|
274
285
|
}
|
|
275
286
|
else {
|
|
276
|
-
|
|
287
|
+
wholeOpen = true;
|
|
277
288
|
}
|
|
278
289
|
};
|
|
279
290
|
/** Whether one expression is the exports object a top-level write may name here. */
|
|
@@ -300,8 +311,17 @@ function readTable(file, isFree, declarations) {
|
|
|
300
311
|
}
|
|
301
312
|
else if (isModuleExports(left)) {
|
|
302
313
|
modelled.add(expression);
|
|
303
|
-
|
|
304
|
-
|
|
314
|
+
const inner = unwrapped(expression.right);
|
|
315
|
+
const chained = isBinaryExpression(inner) &&
|
|
316
|
+
inner.operatorToken.kind === SyntaxKind.EqualsToken &&
|
|
317
|
+
free(inner.left, "exports")
|
|
318
|
+
? inner
|
|
319
|
+
: undefined;
|
|
320
|
+
if (chained !== undefined) {
|
|
321
|
+
modelled.add(chained);
|
|
322
|
+
}
|
|
323
|
+
moduleValue(chained ?? expression, left.name);
|
|
324
|
+
aliasing = chained !== undefined;
|
|
305
325
|
}
|
|
306
326
|
else if (isPropertyAccessExpression(left) || isElementAccessExpression(left)) {
|
|
307
327
|
const object = exportsObject(left.expression);
|
|
@@ -332,7 +352,32 @@ function readTable(file, isFree, declarations) {
|
|
|
332
352
|
}
|
|
333
353
|
}
|
|
334
354
|
}
|
|
335
|
-
return { entries, open, modelled };
|
|
355
|
+
return { entries, open: open || wholeOpen, modelled, whole, membersOpen: open };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The module value one file leaves where Node runs it as CommonJS, read by the one table
|
|
359
|
+
* the inventory's export table reads, or undefined where the file writes module syntax.
|
|
360
|
+
* `declarationOf` names the declaration each name resolves to, undefined for none, as a
|
|
361
|
+
* lexical reading of a file outside every program answers it.
|
|
362
|
+
*/
|
|
363
|
+
export function commonJSModuleValue(file, declarationOf) {
|
|
364
|
+
if (writesModuleSyntax(file)) {
|
|
365
|
+
return undefined;
|
|
366
|
+
}
|
|
367
|
+
const free = (node) => {
|
|
368
|
+
const declaration = isIdentifier(node) ? declarationOf(node) : undefined;
|
|
369
|
+
return declaration === undefined || !bindsOwn(declaration, file);
|
|
370
|
+
};
|
|
371
|
+
const table = readTable(file, free, topLevelDeclarations(file), lexicalBinding(declarationOf));
|
|
372
|
+
const held = table.whole === undefined ? undefined : unwrapped(table.whole);
|
|
373
|
+
const members = [...table.entries.values()].flatMap((entry) => entry.component === DEFAULT && held !== undefined && !isObjectLiteralExpression(held)
|
|
374
|
+
? []
|
|
375
|
+
: [{ key: entry.component.text, value: entry.value, node: entry.node }]);
|
|
376
|
+
return {
|
|
377
|
+
whole: held === undefined || isObjectLiteralExpression(held) ? undefined : table.whole,
|
|
378
|
+
members,
|
|
379
|
+
open: table.membersOpen || opens(file, free, table.modelled),
|
|
380
|
+
};
|
|
336
381
|
}
|
|
337
382
|
/** Whether one node is `Object.defineProperty`. */
|
|
338
383
|
function isDefineProperty(node) {
|
|
@@ -4,6 +4,7 @@ import { packageScope, packageTypeIsModule } from "../load/package-scope.js";
|
|
|
4
4
|
import { relativePath } from "../paths.js";
|
|
5
5
|
import { renderPosition } from "../position.js";
|
|
6
6
|
import { isAnswered, UNANSWERED } from "../query.js";
|
|
7
|
+
import { declarationOf } from "../entries/static-module.js";
|
|
7
8
|
import { commonJS } from "./commonjs.js";
|
|
8
9
|
import { SYNTAX } from "./syntax.js";
|
|
9
10
|
/**
|
|
@@ -18,7 +19,7 @@ export function inventory(project, host, targetRoot) {
|
|
|
18
19
|
const moduleOf = packageScope(host, targetRoot);
|
|
19
20
|
const sources = [
|
|
20
21
|
SYNTAX,
|
|
21
|
-
commonJS(packageTypeIsModule(host, targetRoot), resolvedIn(project)),
|
|
22
|
+
commonJS(packageTypeIsModule(host, targetRoot), resolvedIn(project), declarationOf),
|
|
22
23
|
];
|
|
23
24
|
const into = new Builder(targetRoot);
|
|
24
25
|
for (const file of files) {
|
|
@@ -1,26 +1,41 @@
|
|
|
1
|
+
import { LANGUAGE_ROWS } from "./contract/contract.generated.js";
|
|
2
|
+
import { globExpression } from "./text/glob.js";
|
|
1
3
|
export const JAVASCRIPT_FILE = /\.(?:js|jsx|mjs|cjs)$/u;
|
|
2
|
-
/**
|
|
3
|
-
const
|
|
4
|
+
/** The patterns the TypeScript row of `languages.json` skips files by, each matched against a name alone. */
|
|
5
|
+
const MINIFIED_NAMES = LANGUAGE_ROWS.ts.skippedFiles.map((pattern) => ({
|
|
6
|
+
pattern,
|
|
7
|
+
expression: globExpression(pattern),
|
|
8
|
+
}));
|
|
4
9
|
const MINIFIED_BYTES = 10_240;
|
|
5
10
|
const MINIFIED_LINE = 500;
|
|
6
|
-
/**
|
|
11
|
+
/** What a minified file is decided by where its text is not read. */
|
|
12
|
+
const LONG_LINES = "long lines";
|
|
13
|
+
/** The skipped-file pattern one file's name matches, which decides it minified without its text. */
|
|
7
14
|
export function minifiedByName(fileName) {
|
|
8
|
-
|
|
15
|
+
const name = fileName.slice(fileName.lastIndexOf("/") + 1);
|
|
16
|
+
return MINIFIED_NAMES.find((one) => one.expression.test(name))?.pattern;
|
|
9
17
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* What decides one JavaScript file minified: the skipped-file pattern its name matches, or
|
|
20
|
+
* {@link LONG_LINES} for a text of the size whose mean line is longer than the limit;
|
|
21
|
+
* undefined for a file that is not minified.
|
|
22
|
+
*/
|
|
23
|
+
export function minifiedBy(fileName, text) {
|
|
12
24
|
if (!JAVASCRIPT_FILE.test(fileName)) {
|
|
13
|
-
return
|
|
25
|
+
return undefined;
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
const named = minifiedByName(fileName);
|
|
28
|
+
if (named !== undefined) {
|
|
29
|
+
return named;
|
|
17
30
|
}
|
|
18
31
|
// A UTF-16 unit encodes to at most three UTF-8 bytes, so a shorter text is below the size.
|
|
19
32
|
if (text.length * 3 < MINIFIED_BYTES) {
|
|
20
|
-
return
|
|
33
|
+
return undefined;
|
|
21
34
|
}
|
|
22
35
|
const lines = text.split(/\r?\n/u).length;
|
|
23
|
-
return utf8Bytes(text) >= MINIFIED_BYTES && text.length / lines > MINIFIED_LINE
|
|
36
|
+
return utf8Bytes(text) >= MINIFIED_BYTES && text.length / lines > MINIFIED_LINE
|
|
37
|
+
? LONG_LINES
|
|
38
|
+
: undefined;
|
|
24
39
|
}
|
|
25
40
|
/** The length of a text in UTF-8, a lone surrogate counting as the three bytes of U+FFFD. */
|
|
26
41
|
function utf8Bytes(text) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { conventionFailuresFor } from "../conventions.js";
|
|
1
|
+
import { conventionFailuresFor } from "../entries/conventions.js";
|
|
2
2
|
import { relativePath, resolvePath } from "../paths.js";
|
|
3
3
|
import { diagnosticsOf, ownedAs } from "../session.js";
|
|
4
4
|
import { skipAt } from "../type-errors.js";
|
|
5
5
|
import { classOf, MISSING_GLOBAL_TYPE, projectErrors, renderDiagnostic, } from "./diagnostics.js";
|
|
6
|
-
import { targetRelative } from "./discover.js";
|
|
6
|
+
import { targetRelative, unreadableDetail, } from "./discover.js";
|
|
7
7
|
import { missingModule, pathsOf } from "./expected-module.js";
|
|
8
8
|
import { FailureExit, failureLine } from "../failure.js";
|
|
9
9
|
import { JAVASCRIPT_FILE } from "../javascript-file.js";
|
|
@@ -80,7 +80,7 @@ function classifyTarget(engine, host, run, plan, view, unfound) {
|
|
|
80
80
|
const raw = projectErrors(diagnosticsOf(project));
|
|
81
81
|
const load = nonEmpty(raw.load);
|
|
82
82
|
if (load !== undefined) {
|
|
83
|
-
return { kind: "load", errors: load };
|
|
83
|
+
return { kind: "load", errors: load, unreadable: raw.unreadable };
|
|
84
84
|
}
|
|
85
85
|
const reading = readErrors(project, plan, ownErrors(raw.check, referenceOnly), {
|
|
86
86
|
host,
|
|
@@ -134,7 +134,7 @@ function classifyConsumer(engine, host, run, plan, consumer, project) {
|
|
|
134
134
|
const raw = projectErrors(diagnosticsOf(project));
|
|
135
135
|
const load = nonEmpty(raw.load);
|
|
136
136
|
if (load !== undefined) {
|
|
137
|
-
return { kind: "load", errors: load };
|
|
137
|
+
return { kind: "load", errors: load, unreadable: raw.unreadable };
|
|
138
138
|
}
|
|
139
139
|
let faulted;
|
|
140
140
|
const reading = readErrors(project, plan, raw.check, {
|
|
@@ -173,7 +173,7 @@ function ending(plan, failed, root) {
|
|
|
173
173
|
return plan.consumer === undefined
|
|
174
174
|
? [
|
|
175
175
|
{
|
|
176
|
-
failureClass: "no-program",
|
|
176
|
+
failureClass: failed.kind === "load" && failed.unreadable ? "unreadable-configuration" : "no-program",
|
|
177
177
|
detail: `${what}: correct the configuration, or name the configurations to analyze`,
|
|
178
178
|
},
|
|
179
179
|
]
|
|
@@ -184,6 +184,22 @@ function ending(plan, failed, root) {
|
|
|
184
184
|
},
|
|
185
185
|
];
|
|
186
186
|
}
|
|
187
|
+
/** The setup failures a dropped derived configuration counts as, where it counts as any. */
|
|
188
|
+
function droppedFailures(failed, plan, root) {
|
|
189
|
+
if (failed.kind === "setup") {
|
|
190
|
+
return { failures: failed.failures };
|
|
191
|
+
}
|
|
192
|
+
return failed.kind === "load" && failed.unreadable
|
|
193
|
+
? {
|
|
194
|
+
failures: [
|
|
195
|
+
{
|
|
196
|
+
failureClass: "unreadable-configuration",
|
|
197
|
+
detail: unreadableDetail(plan.id, `cannot be read as a compiler configuration: ${droppedBy(failed, root)}`),
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
}
|
|
201
|
+
: {};
|
|
202
|
+
}
|
|
187
203
|
/** The first line of the error that drops one derived configuration. */
|
|
188
204
|
function droppedBy(failed, root) {
|
|
189
205
|
return failed.kind === "load"
|
|
@@ -206,7 +222,6 @@ export function classify(engine, host, run, views) {
|
|
|
206
222
|
const analyzed = [];
|
|
207
223
|
const consumed = [];
|
|
208
224
|
const ended = new Map();
|
|
209
|
-
const dropped = [];
|
|
210
225
|
const unopened = run.plans.filter((plan) => !views.has(plan.configFile));
|
|
211
226
|
const outcomes = [
|
|
212
227
|
...run.plans.flatMap((plan) => {
|
|
@@ -237,8 +252,12 @@ export function classify(engine, host, run, views) {
|
|
|
237
252
|
ended.set(outcome.kind, [...(ended.get(outcome.kind) ?? []), { plan, failed: outcome }]);
|
|
238
253
|
}
|
|
239
254
|
else {
|
|
240
|
-
|
|
241
|
-
|
|
255
|
+
notBuilt.push({
|
|
256
|
+
id: plan.id,
|
|
257
|
+
configFile: plan.configFile,
|
|
258
|
+
error: droppedBy(outcome, root),
|
|
259
|
+
...droppedFailures(outcome, plan, root),
|
|
260
|
+
});
|
|
242
261
|
}
|
|
243
262
|
}
|
|
244
263
|
for (const kind of ["unopened", "setup", "load"]) {
|
|
@@ -248,7 +267,7 @@ export function classify(engine, host, run, views) {
|
|
|
248
267
|
throw new FailureExit(kind === "unopened" ? [failures[0]] : failures, all.flatMap(({ failed }) => (failed.kind === "load" ? failed.errors : [])));
|
|
249
268
|
}
|
|
250
269
|
}
|
|
251
|
-
const setupDropped = nonEmpty(
|
|
270
|
+
const setupDropped = nonEmpty(notBuilt.flatMap((one) => one.failures ?? []));
|
|
252
271
|
const [first] = notBuilt;
|
|
253
272
|
if (analyzed.length === 0 && first !== undefined) {
|
|
254
273
|
throw new FailureExit(setupDropped ?? [
|
|
@@ -68,12 +68,19 @@ function locatedIn(diagnostics, locate) {
|
|
|
68
68
|
export function diagnosticErrors(sets) {
|
|
69
69
|
return [...sets.configParsing, ...sets.syntactic, ...sets.semantic].filter(isError);
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The code of a configuration whose only parse error is that its inputs name no file: it reads
|
|
73
|
+
* as written and holds no program.
|
|
74
|
+
*/
|
|
75
|
+
const NO_INPUTS = 18003;
|
|
71
76
|
/** The errors one open project carries, each located in the file it names. */
|
|
72
77
|
export function projectErrors(sets) {
|
|
73
78
|
const unplaced = (kind) => sets.unplaced.filter((diagnostic) => classOf(diagnostic, false) === kind);
|
|
74
|
-
const
|
|
79
|
+
const parsing = sets.configParsing.filter(isError);
|
|
80
|
+
const load = [...parsing, ...unplaced("load")];
|
|
75
81
|
return {
|
|
76
82
|
load: locatedIn(load, sets.locate),
|
|
83
|
+
unreadable: parsing.some(({ code }) => code !== NO_INPUTS),
|
|
77
84
|
check: load.length > 0 ? [] : locatedIn(diagnosticErrors(sets), sets.locate),
|
|
78
85
|
unfound: load.length > 0 ? [] : locatedIn(unplaced("unfound-library"), sets.locate),
|
|
79
86
|
};
|
|
@@ -66,11 +66,9 @@ function readConfiguration(engine, configFile) {
|
|
|
66
66
|
try {
|
|
67
67
|
const parsed = engine.parseConfigFile(configFile);
|
|
68
68
|
const circular = parsed.errors.find(({ code }) => code === CIRCULAR_EXTENDS);
|
|
69
|
-
// The compiler leaves the message's `{0}` unfilled:
|
|
70
|
-
// https://github.com/microsoft/TypeScript/pull/64755
|
|
71
69
|
return circular === undefined
|
|
72
70
|
? { parsed }
|
|
73
|
-
: { reason: `TS${String(circular.code)}: ${circular.text
|
|
71
|
+
: { reason: `TS${String(circular.code)}: ${circular.text}` };
|
|
74
72
|
}
|
|
75
73
|
catch (error) {
|
|
76
74
|
return { reason: message(error) };
|
|
@@ -137,8 +135,12 @@ export function targetWithoutSources(target) {
|
|
|
137
135
|
return failureExit("no-program", `${target} holds no compiler configuration, no file named ${MARKERS.join(", ")}, and no JavaScript file: run from the directory that holds one, or name the languages to analyze`);
|
|
138
136
|
}
|
|
139
137
|
/** A target configuration a matrix or the invocation names that cannot be built, ending the run. */
|
|
140
|
-
function unbuilt(named, reason) {
|
|
141
|
-
throw failureExit(
|
|
138
|
+
function unbuilt(named, reason, failureClass = "no-program") {
|
|
139
|
+
throw failureExit(failureClass, unreadableDetail(named, reason));
|
|
140
|
+
}
|
|
141
|
+
/** What fails and the fix, for a configuration `named` that `reason` keeps from being built. */
|
|
142
|
+
export function unreadableDetail(named, reason) {
|
|
143
|
+
return `${named} ${reason}: correct the configuration, or name the configurations to analyze`;
|
|
142
144
|
}
|
|
143
145
|
/**
|
|
144
146
|
* The projects a build matrix declares, in its order, each a file below the target root, a
|
|
@@ -172,7 +174,7 @@ function declaredProjects(engine, host, targetRoot, entries) {
|
|
|
172
174
|
}
|
|
173
175
|
const read = readConfiguration(engine, configFile);
|
|
174
176
|
if ("reason" in read) {
|
|
175
|
-
unbuilt(named, `cannot be read as a compiler configuration: ${read.reason}
|
|
177
|
+
unbuilt(named, `cannot be read as a compiler configuration: ${read.reason}`, "unreadable-configuration");
|
|
176
178
|
}
|
|
177
179
|
references.set(configFile, referencesOf(read.parsed));
|
|
178
180
|
const configuration = {
|
|
@@ -212,13 +214,19 @@ function derivedProjects(engine, host, scope) {
|
|
|
212
214
|
const idOf = (configFile) => relativePath(targetRoot, configFile) ?? configFile;
|
|
213
215
|
const notBuilt = [];
|
|
214
216
|
const found = derivedFrom(engine, host, [...fromScope, ...configFilesUnder(host, targetRoot)], (reference) => relativePath(rootDir, reference) !== undefined, (configFile, reason) => {
|
|
217
|
+
const why = `cannot be read as a compiler configuration: ${reason}`;
|
|
215
218
|
if (fromScope.includes(configFile)) {
|
|
216
|
-
unbuilt(configFile,
|
|
219
|
+
unbuilt(configFile, why, "unreadable-configuration");
|
|
217
220
|
}
|
|
221
|
+
const failure = {
|
|
222
|
+
failureClass: "unreadable-configuration",
|
|
223
|
+
detail: targetRelative(unreadableDetail(idOf(configFile), why), absoluteRoot),
|
|
224
|
+
};
|
|
218
225
|
notBuilt.push({
|
|
219
226
|
id: idOf(configFile),
|
|
220
227
|
configFile,
|
|
221
228
|
error: targetRelative(reason, absoluteRoot),
|
|
229
|
+
failures: [failure],
|
|
222
230
|
});
|
|
223
231
|
});
|
|
224
232
|
const configurations = found.map(({ configFile, parsed }) => ({
|
package/dist/src/load/plan.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readConventions } from "../conventions.js";
|
|
1
|
+
import { readConventions, } from "../entries/conventions.js";
|
|
2
2
|
import { holdsManifest, inInstalledPackages, MANIFEST, readManifestAt } from "../fs/manifest.js";
|
|
3
3
|
import { gitIgnored } from "../git-ignore.js";
|
|
4
|
-
import { packageEntries, readManifest } from "../manifest.js";
|
|
4
|
+
import { packageEntries, readManifest, } from "../roots/manifest.js";
|
|
5
5
|
import { ancestors, dirnamePath, joinPath, normalizePath, relativePath, resolvePath, } from "../paths.js";
|
|
6
6
|
import { bytewise } from "../text/compare.js";
|
|
7
7
|
import { globExpression } from "../text/glob.js";
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* is written for.
|
|
6
6
|
*/
|
|
7
7
|
import { readCommands } from "../commands/read.js";
|
|
8
|
-
import { CONVENTION_ROWS } from "../convention-rows.js";
|
|
8
|
+
import { CONVENTION_ROWS } from "../entries/convention-rows.js";
|
|
9
9
|
import { holdsManifest, MANIFEST, readManifestAt } from "../fs/manifest.js";
|
|
10
10
|
import { filesBelow } from "../fs/tree.js";
|
|
11
|
-
import { JAVASCRIPT_FILE,
|
|
11
|
+
import { JAVASCRIPT_FILE, minifiedBy, minifiedByName } from "../javascript-file.js";
|
|
12
12
|
import { isRecord } from "../json-document.js";
|
|
13
|
-
import { manifestCommands } from "../manifest.js";
|
|
13
|
+
import { manifestCommands } from "../roots/manifest.js";
|
|
14
14
|
import { ancestors, dirnamePath, joinPath, relativePath } from "../paths.js";
|
|
15
15
|
import { bytewise } from "../text/compare.js";
|
|
16
16
|
import { writtenPath } from "./workspace-programs.js";
|
|
@@ -33,11 +33,11 @@ const FORMED_OPTIONS = {
|
|
|
33
33
|
};
|
|
34
34
|
/** Whether one file is minified build output; one that cannot be read is left to the compiler. */
|
|
35
35
|
function minifiedFile(host, file) {
|
|
36
|
-
if (minifiedByName(file)) {
|
|
36
|
+
if (minifiedByName(file) !== undefined) {
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
|
-
return
|
|
40
|
+
return minifiedBy(file, host.readFile(file)) !== undefined;
|
|
41
41
|
}
|
|
42
42
|
catch {
|
|
43
43
|
return false;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* workspace imports, so only its commands are entry points.
|
|
7
7
|
*/
|
|
8
8
|
import { emittedFrom } from "./emit-map.js";
|
|
9
|
-
import { readManifest } from "../manifest.js";
|
|
9
|
+
import { readManifest } from "../roots/manifest.js";
|
|
10
10
|
import { joinPath, relativePath } from "../paths.js";
|
|
11
11
|
import { MANIFEST } from "../fs/manifest.js";
|
|
12
12
|
/** The one character a subpath pattern of a manifest's `exports` holds. */
|
package/dist/src/matrix.js
CHANGED
|
@@ -81,19 +81,12 @@ export function matrixOf(per) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* reference under one configuration is a reference, so what one project uses is never
|
|
91
|
-
* reported, and a configuration that does not hold a declaration says nothing about it.
|
|
92
|
-
* The candidate's relation is reference counting where every configuration found it so,
|
|
93
|
-
* and reachability otherwise; its counts are the union's, one per reference.
|
|
94
|
-
*
|
|
95
|
-
* The components are computed once, over the union and the intersected dead set, so one
|
|
96
|
-
* dead component is one entry of the run with one identifier.
|
|
84
|
+
* Which declarations of the run are dead in every configuration that holds them. Each
|
|
85
|
+
* configuration is swept on its own graph, since a file it does not compile references nothing
|
|
86
|
+
* there and a root it does not hold seeds nothing. A declaration is a candidate when every
|
|
87
|
+
* configuration holding it judged it one; its relation is reference counting where every one
|
|
88
|
+
* found it so, else reachability, and its counts are the union's. Components are computed once,
|
|
89
|
+
* over the union and the intersected dead set, so one dead component has one identifier.
|
|
97
90
|
*/
|
|
98
91
|
export function sweepMatrix(matrix, input) {
|
|
99
92
|
const per = matrix.graphs.map((graph) => sweep(graph, input));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* it names is not known.
|
|
8
8
|
*/
|
|
9
9
|
import { isCallExpression, isExportDeclaration, isImportDeclaration, isNamespaceExport, isNamespaceImport, isNoSubstitutionTemplateLiteral, isStringLiteral, SyntaxKind, } from "@typescript/native/ast";
|
|
10
|
-
import { RESOLVED_EXTENSIONS } from "./configuration-files.js";
|
|
10
|
+
import { RESOLVED_EXTENSIONS } from "./entries/configuration-files.js";
|
|
11
11
|
import { emittedFrom } from "./load/emit-map.js";
|
|
12
12
|
import { namesImported } from "./module-declarations.js";
|
|
13
13
|
import { dirnamePath, joinPath, normalizePath, queriedModulePath } from "./paths.js";
|
package/dist/src/paths.js
CHANGED
|
@@ -88,6 +88,22 @@ export function extensionOf(path) {
|
|
|
88
88
|
export function resolvePath(against, path) {
|
|
89
89
|
return isAbsolutePath(path) ? normalizePath(path) : joinPath(against, path);
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* A URL reference's scheme. A reference with none that does not start with a solidus is
|
|
93
|
+
* relative, the bare name included: https://url.spec.whatwg.org/#relative-url-string
|
|
94
|
+
*/
|
|
95
|
+
const URL_SCHEME = /^[a-z][a-z\d+.-]*:/iu;
|
|
96
|
+
/**
|
|
97
|
+
* The path a relative URL reference names against `dir`, its query and its fragment
|
|
98
|
+
* removed, which name no part of the file; undefined where the reference is not relative.
|
|
99
|
+
*/
|
|
100
|
+
export function relativeURLPath(dir, reference) {
|
|
101
|
+
if (reference === "" || reference.startsWith("/") || URL_SCHEME.test(reference)) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const cut = reference.search(/[?#]/u);
|
|
105
|
+
return resolvePath(dir, cut < 0 ? reference : reference.slice(0, cut));
|
|
106
|
+
}
|
|
91
107
|
/**
|
|
92
108
|
* The relative path before the query of a relative module specifier such as
|
|
93
109
|
* `./worker.ts?worker`, the module a bundler loads; undefined for a specifier with no
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which calls are the platform's `require` and which constructions its `URL` (roots.23,
|
|
3
|
+
* references-ts.1), decided once over the bindings of the names a callee is written with: the
|
|
4
|
+
* checker's in a program, the file's own scopes in a module read outside every program.
|
|
5
|
+
*/
|
|
6
|
+
import { isBindingElement, isCallExpression, isExportSpecifier, isIdentifier, isImportSpecifier, isPropertyAccessExpression, isStringLiteral, isVariableDeclaration, } from "@typescript/native/ast";
|
|
7
|
+
import { parenthesesRemoved, unwrapped } from "./unwrap.js";
|
|
8
|
+
/** The name one declaration carries a binding by beside its own: the export an import or a re-export names, or the property a destructuring reads. */
|
|
9
|
+
export function carriedNames(node) {
|
|
10
|
+
if (isImportSpecifier(node) || isExportSpecifier(node)) {
|
|
11
|
+
return [(node.propertyName ?? node.name).text];
|
|
12
|
+
}
|
|
13
|
+
const property = isBindingElement(node) ? node.propertyName : undefined;
|
|
14
|
+
return property !== undefined && (isIdentifier(property) || isStringLiteral(property))
|
|
15
|
+
? [property.text]
|
|
16
|
+
: [];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A written name's binding as a file states it, with no checker to ask, so nothing is
|
|
20
|
+
* proven the target's own (conventions.3): `declarationOf` names the declaration a name
|
|
21
|
+
* resolves to, and a property is read by how it is written alone.
|
|
22
|
+
*/
|
|
23
|
+
export function lexicalBinding(declarationOf) {
|
|
24
|
+
return (written) => {
|
|
25
|
+
const parent = written.parent;
|
|
26
|
+
if (isPropertyAccessExpression(parent) && parent.name === written) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const declaration = declarationOf(written);
|
|
30
|
+
return {
|
|
31
|
+
names: new Set([
|
|
32
|
+
written.text,
|
|
33
|
+
...(declaration === undefined ? [] : carriedNames(declaration)),
|
|
34
|
+
]),
|
|
35
|
+
own: declaration === undefined ? [] : [declaration],
|
|
36
|
+
provenOwn: false,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The name a callee or a constructor is written with, parentheses removed: an identifier or a property name. */
|
|
41
|
+
export function writtenName(expression) {
|
|
42
|
+
const at = parenthesesRemoved(expression);
|
|
43
|
+
if (isIdentifier(at)) {
|
|
44
|
+
return at;
|
|
45
|
+
}
|
|
46
|
+
return isPropertyAccessExpression(at) && isIdentifier(at.name) ? at.name : undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether a call or construction through `callee` is one of the platform's `name`: never
|
|
50
|
+
* where its binding is proven the target's own; otherwise where it is written or carried
|
|
51
|
+
* by that name, or resolves to a variable of the target whose initializer is such a
|
|
52
|
+
* callee or, for `require`, a call of a `createRequire`. A callee nothing binds is read by
|
|
53
|
+
* how it is written.
|
|
54
|
+
*/
|
|
55
|
+
export function callsPlatformBy(name, callee, bindingOf, seen = new Set()) {
|
|
56
|
+
const bound = bindingOf(callee);
|
|
57
|
+
if (bound?.provenOwn === true) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (callee.text === name || bound?.names.has(name) === true) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return (bound?.own ?? []).some((node) => {
|
|
64
|
+
if (seen.has(node) || !isVariableDeclaration(node) || node.initializer === undefined) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
seen.add(node);
|
|
68
|
+
const value = unwrapped(node.initializer);
|
|
69
|
+
if (isCallExpression(value)) {
|
|
70
|
+
const called = writtenName(value.expression);
|
|
71
|
+
return (name === "require" &&
|
|
72
|
+
called !== undefined &&
|
|
73
|
+
callsPlatformBy("createRequire", called, bindingOf, seen));
|
|
74
|
+
}
|
|
75
|
+
const written = writtenName(value);
|
|
76
|
+
return written !== undefined && callsPlatformBy(name, written, bindingOf, seen);
|
|
77
|
+
});
|
|
78
|
+
}
|