@nx/jest 23.0.0-beta.18 → 23.0.0-beta.19
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.
|
@@ -148,19 +148,34 @@ function collectCallExpressionRewrites(sourceFile, changes) {
|
|
|
148
148
|
// internal entry.
|
|
149
149
|
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
150
150
|
}
|
|
151
|
+
else if (ts.isImportTypeNode(node)) {
|
|
152
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
153
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
154
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
155
|
+
const literal = getImportTypeStringLiteral(node);
|
|
156
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
157
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
151
160
|
ts.forEachChild(node, visit);
|
|
152
161
|
};
|
|
153
162
|
visit(sourceFile);
|
|
154
163
|
}
|
|
164
|
+
function getImportTypeStringLiteral(node) {
|
|
165
|
+
const arg = node.argument;
|
|
166
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
167
|
+
return arg.literal;
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
155
171
|
function shouldRewriteCallExpression(call) {
|
|
156
172
|
const callee = call.expression;
|
|
157
173
|
// `require('...')`
|
|
158
174
|
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
159
175
|
return true;
|
|
160
176
|
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
161
|
-
// callee is the `import` keyword). The type-position
|
|
162
|
-
//
|
|
163
|
-
// we don't touch it.
|
|
177
|
+
// callee is the `import` keyword). The `typeof import('...')` type-position
|
|
178
|
+
// form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
|
|
164
179
|
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
165
180
|
return true;
|
|
166
181
|
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
"semver": "^7.6.3",
|
|
105
105
|
"tslib": "^2.3.0",
|
|
106
106
|
"yargs-parser": "21.1.1",
|
|
107
|
-
"@nx/devkit": "23.0.0-beta.
|
|
108
|
-
"@nx/js": "23.0.0-beta.
|
|
107
|
+
"@nx/devkit": "23.0.0-beta.19",
|
|
108
|
+
"@nx/js": "23.0.0-beta.19"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"nx": "23.0.0-beta.
|
|
111
|
+
"nx": "23.0.0-beta.19"
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": {
|
|
114
114
|
"access": "public"
|