knip 5.73.3 → 5.74.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/ConfigurationChief.d.ts +6 -0
- package/dist/ProjectPrincipal.d.ts +0 -1
- package/dist/ProjectPrincipal.js +18 -13
- package/dist/binaries/package-manager/bun.js +10 -0
- package/dist/compilers/index.d.ts +10 -0
- package/dist/compilers/scss.js +1 -1
- package/dist/constants.d.ts +6 -1
- package/dist/constants.js +6 -1
- package/dist/graph/build.js +18 -9
- package/dist/graph-explorer/visitors.js +3 -3
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/swc/index.d.ts +3 -0
- package/dist/plugins/swc/index.js +18 -0
- package/dist/plugins/swc/types.d.ts +7 -0
- package/dist/plugins/swc/types.js +1 -0
- package/dist/schema/configuration.d.ts +10 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/exports.d.ts +14 -13
- package/dist/types/imports.d.ts +7 -7
- package/dist/types/module-graph.d.ts +27 -26
- package/dist/typescript/ast-helpers.d.ts +5 -3
- package/dist/typescript/ast-helpers.js +5 -2
- package/dist/typescript/create-hosts.d.ts +1 -2
- package/dist/typescript/create-hosts.js +2 -2
- package/dist/typescript/get-imports-and-exports.js +18 -15
- package/dist/typescript/pragmas/custom.js +11 -3
- package/dist/typescript/pragmas/typescript.js +20 -4
- package/dist/typescript/resolve-module-names.d.ts +1 -1
- package/dist/typescript/resolve-module-names.js +5 -9
- package/dist/typescript/visitors/dynamic-imports/importCall.js +100 -14
- package/dist/typescript/visitors/dynamic-imports/importType.js +5 -2
- package/dist/typescript/visitors/dynamic-imports/jsDocType.js +13 -4
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +52 -8
- package/dist/typescript/visitors/dynamic-imports/resolveCall.js +5 -2
- package/dist/typescript/visitors/dynamic-imports/urlConstructor.js +5 -2
- package/dist/typescript/visitors/exports/exportAssignment.js +7 -9
- package/dist/typescript/visitors/exports/exportDeclaration.js +2 -2
- package/dist/typescript/visitors/exports/exportKeyword.js +49 -10
- package/dist/typescript/visitors/exports/exportsAccessExpression.js +4 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +27 -3
- package/dist/typescript/visitors/imports/importDeclaration.js +19 -3
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +3 -2
- package/dist/typescript/visitors/imports/reExportDeclaration.js +15 -5
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/errors.js +2 -0
- package/dist/util/get-referenced-inputs.js +3 -3
- package/dist/util/module-graph.d.ts +0 -1
- package/dist/util/module-graph.js +3 -2
- package/dist/util/modules.js +7 -1
- package/dist/util/resolve.js +3 -3
- package/dist/util/to-source-path.d.ts +2 -2
- package/dist/util/to-source-path.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/schema.json +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS, IMPORT_STAR } from '../../../constants.js';
|
|
3
3
|
import { findAncestor, findDescendants, isModuleExportsAccess, isRequireCall, isTopLevel } from '../../ast-helpers.js';
|
|
4
4
|
import { isNotJS } from '../helpers.js';
|
|
5
5
|
import { importVisitor as visit } from '../index.js';
|
|
@@ -7,7 +7,7 @@ export default visit(() => true, node => {
|
|
|
7
7
|
if (isRequireCall(node)) {
|
|
8
8
|
if (ts.isStringLiteralLike(node.arguments[0])) {
|
|
9
9
|
const specifier = node.arguments[0].text;
|
|
10
|
-
const modifiers = isNotJS(node.getSourceFile()) ?
|
|
10
|
+
const modifiers = isNotJS(node.getSourceFile()) ? IMPORT_FLAGS.BRIDGE : IMPORT_FLAGS.NONE;
|
|
11
11
|
if (specifier) {
|
|
12
12
|
const propertyAccessExpression = findAncestor(node, _node => {
|
|
13
13
|
if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
|
|
@@ -16,7 +16,15 @@ export default visit(() => true, node => {
|
|
|
16
16
|
});
|
|
17
17
|
if (propertyAccessExpression) {
|
|
18
18
|
const identifier = String(propertyAccessExpression.name.escapedText);
|
|
19
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
identifier,
|
|
21
|
+
specifier,
|
|
22
|
+
pos: propertyAccessExpression.name.getStart(),
|
|
23
|
+
modifiers,
|
|
24
|
+
alias: undefined,
|
|
25
|
+
namespace: undefined,
|
|
26
|
+
symbol: undefined,
|
|
27
|
+
};
|
|
20
28
|
}
|
|
21
29
|
const variableDeclaration = node.parent;
|
|
22
30
|
if (ts.isVariableDeclaration(variableDeclaration) &&
|
|
@@ -30,6 +38,7 @@ export default visit(() => true, node => {
|
|
|
30
38
|
symbol: isTLA ? variableDeclaration.symbol : undefined,
|
|
31
39
|
specifier,
|
|
32
40
|
pos: variableDeclaration.name.getStart(),
|
|
41
|
+
namespace: undefined,
|
|
33
42
|
modifiers,
|
|
34
43
|
};
|
|
35
44
|
}
|
|
@@ -39,10 +48,26 @@ export default visit(() => true, node => {
|
|
|
39
48
|
const identifier = (element.propertyName ?? element.name).getText();
|
|
40
49
|
const alias = element.propertyName ? element.name.getText() : undefined;
|
|
41
50
|
const symbol = isTLA ? element.symbol : undefined;
|
|
42
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
identifier,
|
|
53
|
+
specifier,
|
|
54
|
+
alias,
|
|
55
|
+
symbol,
|
|
56
|
+
pos: element.name.getStart(),
|
|
57
|
+
modifiers,
|
|
58
|
+
namespace: undefined,
|
|
59
|
+
};
|
|
43
60
|
});
|
|
44
61
|
}
|
|
45
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
identifier: 'default',
|
|
64
|
+
specifier,
|
|
65
|
+
pos: node.arguments[0].pos,
|
|
66
|
+
modifiers,
|
|
67
|
+
alias: undefined,
|
|
68
|
+
namespace: undefined,
|
|
69
|
+
symbol: undefined,
|
|
70
|
+
};
|
|
46
71
|
}
|
|
47
72
|
if (ts.isBinaryExpression(node.parent) &&
|
|
48
73
|
ts.isPropertyAccessExpression(node.parent.left) &&
|
|
@@ -51,13 +76,32 @@ export default visit(() => true, node => {
|
|
|
51
76
|
identifier: IMPORT_STAR,
|
|
52
77
|
specifier,
|
|
53
78
|
pos: node.arguments[0].pos,
|
|
54
|
-
modifiers:
|
|
79
|
+
modifiers: IMPORT_FLAGS.RE_EXPORT,
|
|
80
|
+
alias: undefined,
|
|
81
|
+
namespace: undefined,
|
|
82
|
+
symbol: undefined,
|
|
55
83
|
};
|
|
56
84
|
}
|
|
57
85
|
if (ts.isCallExpression(node.parent)) {
|
|
58
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
identifier: 'default',
|
|
88
|
+
specifier,
|
|
89
|
+
pos: node.getEnd(),
|
|
90
|
+
modifiers,
|
|
91
|
+
alias: undefined,
|
|
92
|
+
namespace: undefined,
|
|
93
|
+
symbol: undefined,
|
|
94
|
+
};
|
|
59
95
|
}
|
|
60
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
identifier: 'default',
|
|
98
|
+
specifier,
|
|
99
|
+
pos: node.getStart(),
|
|
100
|
+
modifiers,
|
|
101
|
+
alias: undefined,
|
|
102
|
+
namespace: undefined,
|
|
103
|
+
symbol: undefined,
|
|
104
|
+
};
|
|
61
105
|
}
|
|
62
106
|
}
|
|
63
107
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS } from '../../../constants.js';
|
|
3
3
|
import { isPropertyAccessCall } from '../../ast-helpers.js';
|
|
4
4
|
import { importVisitor as visit } from '../index.js';
|
|
5
5
|
export default visit(() => true, node => {
|
|
@@ -11,7 +11,10 @@ export default visit(() => true, node => {
|
|
|
11
11
|
specifier,
|
|
12
12
|
identifier: undefined,
|
|
13
13
|
pos: node.arguments[0].pos,
|
|
14
|
-
modifiers:
|
|
14
|
+
modifiers: IMPORT_FLAGS.ENTRY,
|
|
15
|
+
alias: undefined,
|
|
16
|
+
namespace: undefined,
|
|
17
|
+
symbol: undefined,
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS } from '../../../constants.js';
|
|
3
3
|
import { importVisitor as visit } from '../index.js';
|
|
4
4
|
export default visit(() => true, node => {
|
|
5
5
|
if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'URL') {
|
|
@@ -17,7 +17,10 @@ export default visit(() => true, node => {
|
|
|
17
17
|
specifier,
|
|
18
18
|
identifier: undefined,
|
|
19
19
|
pos: node.arguments[0].pos,
|
|
20
|
-
modifiers:
|
|
20
|
+
modifiers: IMPORT_FLAGS.ENTRY | IMPORT_FLAGS.OPTIONAL,
|
|
21
|
+
alias: undefined,
|
|
22
|
+
namespace: undefined,
|
|
23
|
+
symbol: undefined,
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS } from '../../../constants.js';
|
|
3
|
-
import { getClassMember, getEnumMember, getNodeType,
|
|
2
|
+
import { EMPTY_ARRAY, FIX_FLAGS } from '../../../constants.js';
|
|
3
|
+
import { getClassMember, getEnumMember, getNodeType, isNonPrivateDeclaration } from '../../ast-helpers.js';
|
|
4
4
|
import { isModule } from '../helpers.js';
|
|
5
5
|
import { exportVisitor as visit } from '../index.js';
|
|
6
6
|
export default visit(isModule, (node, { isFixExports, isReportClassMembers, isFixTypes }) => {
|
|
@@ -13,17 +13,15 @@ export default visit(isModule, (node, { isFixExports, isReportClassMembers, isFi
|
|
|
13
13
|
const decl = symbol.valueDeclaration;
|
|
14
14
|
if (ts.isEnumDeclaration(decl)) {
|
|
15
15
|
const members = decl.members.map(member => getEnumMember(member, isFixExports));
|
|
16
|
-
return { node, symbol, identifier: 'default', type, pos, fix, members };
|
|
16
|
+
return { node, symbol, identifier: 'default', type, pos, fix, members, jsDocTags: undefined };
|
|
17
17
|
}
|
|
18
18
|
if (ts.isClassDeclaration(decl)) {
|
|
19
19
|
const members = isReportClassMembers
|
|
20
|
-
? decl.members
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
: [];
|
|
24
|
-
return { node, symbol, identifier: 'default', type, pos, fix, members };
|
|
20
|
+
? decl.members.filter(isNonPrivateDeclaration).map(member => getClassMember(member, isFixTypes))
|
|
21
|
+
: EMPTY_ARRAY;
|
|
22
|
+
return { node, symbol, identifier: 'default', type, pos, fix, members, jsDocTags: undefined };
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
return { node, symbol, identifier: 'default', type, pos, fix };
|
|
25
|
+
return { node, symbol, identifier: 'default', type, pos, fix, members: EMPTY_ARRAY, jsDocTags: undefined };
|
|
28
26
|
}
|
|
29
27
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
2
|
+
import { EMPTY_ARRAY, FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
3
3
|
import { isModule } from '../helpers.js';
|
|
4
4
|
import { exportVisitor as visit } from '../index.js';
|
|
5
5
|
export default visit(isModule, (node, { isFixExports, isFixTypes }) => {
|
|
@@ -17,7 +17,7 @@ export default visit(isModule, (node, { isFixExports, isFixTypes }) => {
|
|
|
17
17
|
const fix = (isFixExports && type !== SYMBOL_TYPE.TYPE) || (isFixTypes && type === SYMBOL_TYPE.TYPE)
|
|
18
18
|
? [element.getStart(), element.getEnd(), FIX_FLAGS.OBJECT_BINDING | FIX_FLAGS.EMPTY_DECLARATION]
|
|
19
19
|
: undefined;
|
|
20
|
-
return { node: element, symbol, identifier, type, pos, fix };
|
|
20
|
+
return { node: element, symbol, identifier, type, pos, fix, members: EMPTY_ARRAY, jsDocTags: undefined };
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
2
|
+
import { EMPTY_ARRAY, FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
3
3
|
import { compact } from '../../../util/array.js';
|
|
4
|
-
import { getClassMember, getDefaultKeywordNode, getEnumMember, getExportKeywordNode,
|
|
4
|
+
import { getClassMember, getDefaultKeywordNode, getEnumMember, getExportKeywordNode, isNonPrivateDeclaration, } from '../../ast-helpers.js';
|
|
5
5
|
import { isModule } from '../helpers.js';
|
|
6
6
|
import { exportVisitor as visit } from '../index.js';
|
|
7
7
|
export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassMembers }) => {
|
|
@@ -22,6 +22,8 @@ export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassM
|
|
|
22
22
|
type: SYMBOL_TYPE.UNKNOWN,
|
|
23
23
|
pos: element.name.getStart(),
|
|
24
24
|
fix,
|
|
25
|
+
members: EMPTY_ARRAY,
|
|
26
|
+
jsDocTags: undefined,
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
}));
|
|
@@ -37,6 +39,8 @@ export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassM
|
|
|
37
39
|
type: SYMBOL_TYPE.UNKNOWN,
|
|
38
40
|
pos: element.getStart(),
|
|
39
41
|
fix,
|
|
42
|
+
members: EMPTY_ARRAY,
|
|
43
|
+
jsDocTags: undefined,
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
}));
|
|
@@ -44,7 +48,15 @@ export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassM
|
|
|
44
48
|
const identifier = declaration.name.getText();
|
|
45
49
|
const pos = declaration.name.getStart();
|
|
46
50
|
const fix = getFix(exportKeyword);
|
|
47
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
node: declaration,
|
|
53
|
+
identifier,
|
|
54
|
+
type: SYMBOL_TYPE.UNKNOWN,
|
|
55
|
+
pos,
|
|
56
|
+
fix,
|
|
57
|
+
members: EMPTY_ARRAY,
|
|
58
|
+
jsDocTags: undefined,
|
|
59
|
+
};
|
|
48
60
|
});
|
|
49
61
|
}
|
|
50
62
|
const defaultKeyword = getDefaultKeywordNode(node);
|
|
@@ -52,35 +64,62 @@ export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassM
|
|
|
52
64
|
const identifier = defaultKeyword ? 'default' : node.name.getText();
|
|
53
65
|
const pos = (node.name ?? node.body ?? node).getStart();
|
|
54
66
|
const fix = getFix(exportKeyword, defaultKeyword);
|
|
55
|
-
return {
|
|
67
|
+
return {
|
|
68
|
+
node,
|
|
69
|
+
symbol: undefined,
|
|
70
|
+
identifier,
|
|
71
|
+
pos,
|
|
72
|
+
type: SYMBOL_TYPE.FUNCTION,
|
|
73
|
+
fix,
|
|
74
|
+
members: EMPTY_ARRAY,
|
|
75
|
+
jsDocTags: undefined,
|
|
76
|
+
};
|
|
56
77
|
}
|
|
57
78
|
if (ts.isClassDeclaration(node) && node.name) {
|
|
58
79
|
const identifier = defaultKeyword ? 'default' : node.name.getText();
|
|
59
80
|
const pos = (node.name ?? node).getStart();
|
|
60
81
|
const fix = getFix(exportKeyword, defaultKeyword);
|
|
61
82
|
const members = isReportClassMembers
|
|
62
|
-
? node.members.filter(
|
|
63
|
-
:
|
|
64
|
-
return { node, identifier, type: SYMBOL_TYPE.CLASS, pos, members,
|
|
83
|
+
? node.members.filter(isNonPrivateDeclaration).map(member => getClassMember(member, isFixTypes))
|
|
84
|
+
: EMPTY_ARRAY;
|
|
85
|
+
return { node, symbol: undefined, identifier, type: SYMBOL_TYPE.CLASS, pos, fix, members, jsDocTags: undefined };
|
|
65
86
|
}
|
|
66
87
|
if (ts.isTypeAliasDeclaration(node)) {
|
|
67
88
|
const identifier = node.name.getText();
|
|
68
89
|
const pos = node.name.getStart();
|
|
69
90
|
const fix = getTypeFix(exportKeyword);
|
|
70
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
node,
|
|
93
|
+
symbol: undefined,
|
|
94
|
+
identifier,
|
|
95
|
+
type: SYMBOL_TYPE.TYPE,
|
|
96
|
+
pos,
|
|
97
|
+
fix,
|
|
98
|
+
members: EMPTY_ARRAY,
|
|
99
|
+
jsDocTags: undefined,
|
|
100
|
+
};
|
|
71
101
|
}
|
|
72
102
|
if (ts.isInterfaceDeclaration(node)) {
|
|
73
103
|
const identifier = defaultKeyword ? 'default' : node.name.getText();
|
|
74
104
|
const pos = node.name.getStart();
|
|
75
105
|
const fix = getTypeFix(exportKeyword);
|
|
76
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
node,
|
|
108
|
+
symbol: undefined,
|
|
109
|
+
identifier,
|
|
110
|
+
type: SYMBOL_TYPE.INTERFACE,
|
|
111
|
+
pos,
|
|
112
|
+
fix,
|
|
113
|
+
members: EMPTY_ARRAY,
|
|
114
|
+
jsDocTags: undefined,
|
|
115
|
+
};
|
|
77
116
|
}
|
|
78
117
|
if (ts.isEnumDeclaration(node)) {
|
|
79
118
|
const identifier = node.name.getText();
|
|
80
119
|
const pos = node.name.getStart();
|
|
81
120
|
const fix = getTypeFix(exportKeyword);
|
|
82
121
|
const members = node.members.map(member => getEnumMember(member, isFixExports));
|
|
83
|
-
return { node, identifier, type: SYMBOL_TYPE.ENUM, pos, members, fix };
|
|
122
|
+
return { node, symbol: undefined, identifier, type: SYMBOL_TYPE.ENUM, pos, members, fix, jsDocTags: undefined };
|
|
84
123
|
}
|
|
85
124
|
}
|
|
86
125
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
2
|
+
import { EMPTY_ARRAY, FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
3
3
|
import { isJS } from '../helpers.js';
|
|
4
4
|
import { exportVisitor as visit } from '../index.js';
|
|
5
5
|
export default visit(isJS, (node, { isFixExports }) => {
|
|
@@ -10,10 +10,13 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
10
10
|
const fix = isFixExports ? [node.getStart(), node.getEnd(), FIX_FLAGS.NONE] : undefined;
|
|
11
11
|
return {
|
|
12
12
|
node: node.left.name,
|
|
13
|
+
symbol: undefined,
|
|
13
14
|
identifier,
|
|
14
15
|
type: SYMBOL_TYPE.UNKNOWN,
|
|
15
16
|
pos,
|
|
16
17
|
fix,
|
|
18
|
+
members: EMPTY_ARRAY,
|
|
19
|
+
jsDocTags: undefined,
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
2
|
+
import { EMPTY_ARRAY, FIX_FLAGS, SYMBOL_TYPE } from '../../../constants.js';
|
|
3
3
|
import { hasRequireCall, isModuleExportsAccess, stripQuotes } from '../../ast-helpers.js';
|
|
4
4
|
import { isJS } from '../helpers.js';
|
|
5
5
|
import { exportVisitor as visit } from '../index.js';
|
|
@@ -14,10 +14,13 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
14
14
|
const fix = isFixExports ? [node.getStart(), node.getEnd(), FIX_FLAGS.NONE] : undefined;
|
|
15
15
|
return {
|
|
16
16
|
node: node.expression.left.name,
|
|
17
|
+
symbol: undefined,
|
|
17
18
|
identifier,
|
|
18
19
|
type: SYMBOL_TYPE.UNKNOWN,
|
|
19
20
|
pos,
|
|
20
21
|
fix,
|
|
22
|
+
members: EMPTY_ARRAY,
|
|
23
|
+
jsDocTags: undefined,
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
if (isModuleExportsAccess(node.expression.left)) {
|
|
@@ -25,13 +28,31 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
25
28
|
if (ts.isObjectLiteralExpression(expr) && expr.properties.every(ts.isShorthandPropertyAssignment)) {
|
|
26
29
|
return expr.properties.map(node => {
|
|
27
30
|
const fix = isFixExports ? [node.getStart(), node.getEnd(), FIX_FLAGS.NONE] : undefined;
|
|
28
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
node,
|
|
33
|
+
symbol: undefined,
|
|
34
|
+
identifier: node.getText(),
|
|
35
|
+
type: SYMBOL_TYPE.UNKNOWN,
|
|
36
|
+
pos: node.getStart(),
|
|
37
|
+
fix,
|
|
38
|
+
members: EMPTY_ARRAY,
|
|
39
|
+
jsDocTags: undefined,
|
|
40
|
+
};
|
|
29
41
|
});
|
|
30
42
|
}
|
|
31
43
|
if (ts.isCallExpression(node.expression.right) && hasRequireCall(node.expression.right)) {
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
34
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
node,
|
|
48
|
+
symbol: undefined,
|
|
49
|
+
identifier: 'default',
|
|
50
|
+
type: SYMBOL_TYPE.UNKNOWN,
|
|
51
|
+
pos: expr.pos + 1,
|
|
52
|
+
fix: undefined,
|
|
53
|
+
members: EMPTY_ARRAY,
|
|
54
|
+
jsDocTags: undefined,
|
|
55
|
+
};
|
|
35
56
|
}
|
|
36
57
|
}
|
|
37
58
|
else if (ts.isElementAccessExpression(node.expression.left) &&
|
|
@@ -43,10 +64,13 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
43
64
|
const fix = isFixExports ? [node.getStart(), node.getEnd(), FIX_FLAGS.NONE] : undefined;
|
|
44
65
|
return {
|
|
45
66
|
node: node.expression.left.argumentExpression,
|
|
67
|
+
symbol: undefined,
|
|
46
68
|
identifier,
|
|
47
69
|
type: SYMBOL_TYPE.UNKNOWN,
|
|
48
70
|
pos,
|
|
49
71
|
fix,
|
|
72
|
+
members: EMPTY_ARRAY,
|
|
73
|
+
jsDocTags: undefined,
|
|
50
74
|
};
|
|
51
75
|
}
|
|
52
76
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS, IMPORT_STAR } from '../../../constants.js';
|
|
3
3
|
import { isDefaultImport } from '../../ast-helpers.js';
|
|
4
4
|
import { importVisitor as visit } from '../index.js';
|
|
5
5
|
export default visit(() => true, node => {
|
|
6
6
|
if (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {
|
|
7
7
|
const specifier = node.moduleSpecifier.text;
|
|
8
8
|
if (!node.importClause) {
|
|
9
|
-
return {
|
|
9
|
+
return {
|
|
10
|
+
specifier,
|
|
11
|
+
identifier: undefined,
|
|
12
|
+
pos: node.pos,
|
|
13
|
+
modifiers: IMPORT_FLAGS.SIDE_EFFECTS,
|
|
14
|
+
alias: undefined,
|
|
15
|
+
namespace: undefined,
|
|
16
|
+
symbol: undefined,
|
|
17
|
+
};
|
|
10
18
|
}
|
|
11
19
|
const imports = [];
|
|
12
|
-
const modifiers = node.importClause.isTypeOnly ?
|
|
20
|
+
const modifiers = node.importClause.isTypeOnly ? IMPORT_FLAGS.TYPE_ONLY : IMPORT_FLAGS.NONE;
|
|
13
21
|
if (isDefaultImport(node)) {
|
|
14
22
|
imports.push({
|
|
15
23
|
identifier: 'default',
|
|
@@ -18,6 +26,7 @@ export default visit(() => true, node => {
|
|
|
18
26
|
symbol: node.importClause.symbol,
|
|
19
27
|
pos: node.importClause.name?.getStart() ?? node.getStart(),
|
|
20
28
|
modifiers,
|
|
29
|
+
namespace: undefined,
|
|
21
30
|
});
|
|
22
31
|
}
|
|
23
32
|
if (node.importClause?.namedBindings) {
|
|
@@ -29,6 +38,8 @@ export default visit(() => true, node => {
|
|
|
29
38
|
identifier: IMPORT_STAR,
|
|
30
39
|
pos: node.importClause.namedBindings.name.getStart(),
|
|
31
40
|
modifiers,
|
|
41
|
+
alias: undefined,
|
|
42
|
+
namespace: undefined,
|
|
32
43
|
});
|
|
33
44
|
}
|
|
34
45
|
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
@@ -40,6 +51,8 @@ export default visit(() => true, node => {
|
|
|
40
51
|
symbol: element.symbol,
|
|
41
52
|
pos: element.name.getStart(),
|
|
42
53
|
modifiers,
|
|
54
|
+
alias: undefined,
|
|
55
|
+
namespace: undefined,
|
|
43
56
|
});
|
|
44
57
|
}
|
|
45
58
|
}
|
|
@@ -49,6 +62,9 @@ export default visit(() => true, node => {
|
|
|
49
62
|
identifier: undefined,
|
|
50
63
|
pos: node.importClause.namedBindings.pos,
|
|
51
64
|
modifiers,
|
|
65
|
+
alias: undefined,
|
|
66
|
+
symbol: undefined,
|
|
67
|
+
namespace: undefined,
|
|
52
68
|
});
|
|
53
69
|
}
|
|
54
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS } from '../../../constants.js';
|
|
3
3
|
import { isNotJS } from '../helpers.js';
|
|
4
4
|
import { importVisitor as visit } from '../index.js';
|
|
5
5
|
export default visit(isNotJS, node => {
|
|
@@ -14,7 +14,8 @@ export default visit(isNotJS, node => {
|
|
|
14
14
|
identifier: 'default',
|
|
15
15
|
symbol: node.symbol,
|
|
16
16
|
pos: node.name.getStart(),
|
|
17
|
-
modifiers:
|
|
17
|
+
modifiers: IMPORT_FLAGS.NONE,
|
|
18
|
+
namespace: undefined,
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { IMPORT_FLAGS, IMPORT_STAR } from '../../../constants.js';
|
|
3
3
|
import { importVisitor as visit } from '../index.js';
|
|
4
4
|
export default visit(() => true, node => {
|
|
5
5
|
if (ts.isExportDeclaration(node)) {
|
|
@@ -9,7 +9,10 @@ export default visit(() => true, node => {
|
|
|
9
9
|
identifier: IMPORT_STAR,
|
|
10
10
|
specifier: node.moduleSpecifier.text,
|
|
11
11
|
pos: node.moduleSpecifier.getStart() - 7,
|
|
12
|
-
modifiers:
|
|
12
|
+
modifiers: IMPORT_FLAGS.RE_EXPORT,
|
|
13
|
+
alias: undefined,
|
|
14
|
+
namespace: undefined,
|
|
15
|
+
symbol: undefined,
|
|
13
16
|
};
|
|
14
17
|
}
|
|
15
18
|
if (node.exportClause.kind === ts.SyntaxKind.NamespaceExport) {
|
|
@@ -18,7 +21,9 @@ export default visit(() => true, node => {
|
|
|
18
21
|
namespace: String(node.exportClause.name.text),
|
|
19
22
|
specifier: node.moduleSpecifier.text,
|
|
20
23
|
pos: node.exportClause.name.getStart(),
|
|
21
|
-
modifiers:
|
|
24
|
+
modifiers: IMPORT_FLAGS.RE_EXPORT,
|
|
25
|
+
alias: undefined,
|
|
26
|
+
symbol: undefined,
|
|
22
27
|
};
|
|
23
28
|
}
|
|
24
29
|
const specifier = node.moduleSpecifier;
|
|
@@ -29,14 +34,19 @@ export default visit(() => true, node => {
|
|
|
29
34
|
alias: String(element.name.text),
|
|
30
35
|
specifier: specifier.text,
|
|
31
36
|
pos: element.propertyName.getStart(),
|
|
32
|
-
modifiers:
|
|
37
|
+
modifiers: IMPORT_FLAGS.RE_EXPORT,
|
|
38
|
+
namespace: undefined,
|
|
39
|
+
symbol: undefined,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
return {
|
|
36
43
|
identifier: (element.propertyName ?? element.name).getText(),
|
|
37
44
|
specifier: specifier.text,
|
|
38
45
|
pos: element.name.getStart(),
|
|
39
|
-
modifiers:
|
|
46
|
+
modifiers: IMPORT_FLAGS.RE_EXPORT,
|
|
47
|
+
alias: undefined,
|
|
48
|
+
namespace: undefined,
|
|
49
|
+
symbol: undefined,
|
|
40
50
|
};
|
|
41
51
|
});
|
|
42
52
|
}
|
|
@@ -531,6 +531,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
531
531
|
entry?: string | string[] | undefined;
|
|
532
532
|
project?: string | string[] | undefined;
|
|
533
533
|
} | undefined;
|
|
534
|
+
swc?: string | boolean | string[] | {
|
|
535
|
+
config?: string | string[] | undefined;
|
|
536
|
+
entry?: string | string[] | undefined;
|
|
537
|
+
project?: string | string[] | undefined;
|
|
538
|
+
} | undefined;
|
|
534
539
|
syncpack?: string | boolean | string[] | {
|
|
535
540
|
config?: string | string[] | undefined;
|
|
536
541
|
entry?: string | string[] | undefined;
|
|
@@ -1142,6 +1147,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
|
|
|
1142
1147
|
entry?: string | string[] | undefined;
|
|
1143
1148
|
project?: string | string[] | undefined;
|
|
1144
1149
|
} | undefined;
|
|
1150
|
+
swc?: string | boolean | string[] | {
|
|
1151
|
+
config?: string | string[] | undefined;
|
|
1152
|
+
entry?: string | string[] | undefined;
|
|
1153
|
+
project?: string | string[] | undefined;
|
|
1154
|
+
} | undefined;
|
|
1145
1155
|
syncpack?: string | boolean | string[] | {
|
|
1146
1156
|
config?: string | string[] | undefined;
|
|
1147
1157
|
entry?: string | string[] | undefined;
|
package/dist/util/errors.js
CHANGED
|
@@ -16,6 +16,8 @@ export const getKnownErrors = (error) => {
|
|
|
16
16
|
details.push(`location: ${error.path.join('.')}`);
|
|
17
17
|
if (typeof error.expected === 'string')
|
|
18
18
|
details.push(`expected: ${error.expected}`);
|
|
19
|
+
if (Array.isArray(error.keys))
|
|
20
|
+
details.push(`${error.code}: ${error.keys.join(', ')}`);
|
|
19
21
|
if (details.length > 0)
|
|
20
22
|
message += ` (${details.join(', ')})`;
|
|
21
23
|
return new Error(message);
|
|
@@ -47,9 +47,9 @@ export const getReferencedInputsHandler = (deputy, chief, isGitIgnored, addIssue
|
|
|
47
47
|
}
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
50
|
+
const internalPath = _resolveSync(specifier, dirname(containingFilePath));
|
|
51
|
+
if (internalPath && isInternal(internalPath) && !isGitIgnored(internalPath))
|
|
52
|
+
return internalPath;
|
|
53
53
|
}
|
|
54
54
|
if (isHandled)
|
|
55
55
|
return;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FileNode, IdToFileMap, IdToNsToFileMap, ImportMap, ImportMaps, ModuleGraph } from '../types/module-graph.js';
|
|
2
|
-
export declare const getOrCreateFileNode: (graph: ModuleGraph, filePath: string) => FileNode;
|
|
3
2
|
export declare const updateImportMap: (file: FileNode, importMap: ImportMap, graph: ModuleGraph) => void;
|
|
4
3
|
export declare const createImports: () => ImportMaps;
|
|
5
4
|
export declare const addValue: (map: IdToFileMap, id: string, value: string) => void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export const getOrCreateFileNode = (graph, filePath) => graph.get(filePath) ?? createFileNode();
|
|
2
1
|
const updateImportMaps = (fromImportMaps, toImportMaps) => {
|
|
3
2
|
for (const id of fromImportMaps.refs)
|
|
4
3
|
toImportMaps.refs.add(id);
|
|
@@ -22,7 +21,7 @@ export const updateImportMap = (file, importMap, graph) => {
|
|
|
22
21
|
file.imports.internal.set(importedFilePath, fileImportMaps);
|
|
23
22
|
else
|
|
24
23
|
updateImportMaps(fileImportMaps, importMaps);
|
|
25
|
-
const importedFile =
|
|
24
|
+
const importedFile = graph.get(importedFilePath) ?? createFileNode();
|
|
26
25
|
if (!importedFile.imported)
|
|
27
26
|
importedFile.imported = createImports();
|
|
28
27
|
updateImportMaps(fileImportMaps, importedFile.imported);
|
|
@@ -41,6 +40,8 @@ const createFileNode = () => ({
|
|
|
41
40
|
exports: new Map(),
|
|
42
41
|
duplicates: new Set(),
|
|
43
42
|
scripts: new Set(),
|
|
43
|
+
imported: undefined,
|
|
44
|
+
internalImportCache: undefined,
|
|
44
45
|
});
|
|
45
46
|
export const createImports = () => ({
|
|
46
47
|
refs: new Set(),
|
package/dist/util/modules.js
CHANGED
|
@@ -17,7 +17,13 @@ export const getPackageNameFromFilePath = (value) => {
|
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
19
|
export const getPackageNameFromSpecifier = (specifier) => isInNodeModules(specifier) ? getPackageNameFromFilePath(specifier) : getPackageNameFromModuleSpecifier(specifier);
|
|
20
|
-
|
|
20
|
+
const matchPackageNameStart = /^(@[a-z0-9._]|[a-z0-9])/i;
|
|
21
|
+
export const isStartsLikePackageName = (specifier) => {
|
|
22
|
+
const ch = specifier.charCodeAt(0);
|
|
23
|
+
if (ch === 46 || ch === 47 || ch === 35 || ch === 126 || ch === 36)
|
|
24
|
+
return false;
|
|
25
|
+
return matchPackageNameStart.test(specifier);
|
|
26
|
+
};
|
|
21
27
|
export const stripVersionFromSpecifier = (specifier) => specifier.replace(/(\S+)@.*/, '$1');
|
|
22
28
|
const stripNodeModulesFromPath = (command) => command.replace(/(?:\.{0,2}\/)*node_modules\//, '');
|
|
23
29
|
export const extractBinary = (command) => stripVersionFromSpecifier(stripNodeModulesFromPath(command)
|
package/dist/util/resolve.js
CHANGED
|
@@ -24,8 +24,8 @@ const createSyncModuleResolver = (extensions) => {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
const resolveModuleSync = createSyncModuleResolver([...DEFAULT_EXTENSIONS, '.json', '.jsonc']);
|
|
27
|
-
export const _resolveModuleSync = timerify(resolveModuleSync);
|
|
28
|
-
export const _createSyncModuleResolver = extensions => timerify(createSyncModuleResolver(extensions));
|
|
27
|
+
export const _resolveModuleSync = timerify(resolveModuleSync, 'resolveModuleSync');
|
|
28
|
+
export const _createSyncModuleResolver = extensions => timerify(createSyncModuleResolver(extensions), 'resolveModuleSync');
|
|
29
29
|
const createSyncResolver = (extensions) => {
|
|
30
30
|
const resolver = new ResolverFactory({
|
|
31
31
|
extensions,
|
|
@@ -40,5 +40,5 @@ const createSyncResolver = (extensions) => {
|
|
|
40
40
|
catch (_error) { }
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
const resolveSync = createSyncResolver(DEFAULT_EXTENSIONS);
|
|
43
|
+
const resolveSync = createSyncResolver([...DEFAULT_EXTENSIONS, '.d.ts', '.d.mts', '.d.cts', '.json', '.jsonc']);
|
|
44
44
|
export const _resolveSync = timerify(resolveSync);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CompilerOptions } from 'typescript';
|
|
2
2
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
|
|
3
3
|
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const getModuleSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
5
5
|
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions: string | undefined, label: string) => Promise<string[]>;
|
|
6
|
-
export type ToSourceFilePath = ReturnType<typeof
|
|
6
|
+
export type ToSourceFilePath = ReturnType<typeof getModuleSourcePathHandler>;
|