@granite-js/vitest 1.0.21 → 1.0.22
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/CHANGELOG.md +6 -0
- package/dist/index.js +12 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import * as vite from "vitest/node";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
|
-
import
|
|
8
|
+
import flowRemoveTypes from "flow-remove-types";
|
|
9
9
|
|
|
10
10
|
//#region src/transpile.ts
|
|
11
11
|
const REACT_NATIVE_TRANSFORM_EXTENSIONS = [
|
|
@@ -40,16 +40,12 @@ function shouldInlineReactNativeDependency(filename, packageRoots = []) {
|
|
|
40
40
|
if (packageRoots.length > 0) return isWithinPackageRoots(normalized, packageRoots);
|
|
41
41
|
return REACT_NATIVE_TRANSFORM_ALLOWLIST.some((allowlistEntry) => normalized.includes(`/${allowlistEntry}/`));
|
|
42
42
|
}
|
|
43
|
-
async function transformReactNativeSource(
|
|
44
|
-
return (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
comments: false,
|
|
50
|
-
reactRuntimeTarget: "19",
|
|
51
|
-
sourcemap: false
|
|
52
|
-
})).code;
|
|
43
|
+
async function transformReactNativeSource(_sourcePath, source) {
|
|
44
|
+
return flowRemoveTypes(source, {
|
|
45
|
+
all: true,
|
|
46
|
+
pretty: true,
|
|
47
|
+
removeEmptyImports: true
|
|
48
|
+
}).toString();
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
//#endregion
|
|
@@ -73,11 +69,9 @@ const DEFAULT_VITEST_CACHE_DIRECTORY = ".vitest";
|
|
|
73
69
|
const MIRROR_CACHE_KEY_VERSION = "v1";
|
|
74
70
|
const currentMirrorModulePath = fs.realpathSync(fileURLToPath(import.meta.url));
|
|
75
71
|
const currentMirrorModuleDirectory = path.dirname(currentMirrorModulePath);
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const fastFlowTransformPackageJsonPath = path.join(fastFlowTransformPackageRoot, "package.json");
|
|
80
|
-
return JSON.parse(fs.readFileSync(fastFlowTransformPackageJsonPath, "utf8")).version ?? "unknown";
|
|
72
|
+
function getFlowRemoveTypesVersion() {
|
|
73
|
+
const flowRemoveTypesPackageJsonPath = createRequire(import.meta.url).resolve("flow-remove-types/package.json");
|
|
74
|
+
return JSON.parse(fs.readFileSync(flowRemoveTypesPackageJsonPath, "utf8")).version ?? "unknown";
|
|
81
75
|
}
|
|
82
76
|
function getPackageManifestDependencyNames(packageManifest) {
|
|
83
77
|
return Object.keys({
|
|
@@ -140,10 +134,10 @@ function computeReactNativeMirrorCacheKey(workspaceRoot) {
|
|
|
140
134
|
const hasher = createHash("sha256");
|
|
141
135
|
const packageRoots = resolveReactNativePackageRoots(workspaceRoot).sort();
|
|
142
136
|
const transformImplementationHash = hashImplementationFiles();
|
|
143
|
-
const transformDependencyVersions = {
|
|
137
|
+
const transformDependencyVersions = { flowRemoveTypes: getFlowRemoveTypesVersion() };
|
|
144
138
|
hasher.update(`granite-vitest-rn-cache:${MIRROR_CACHE_KEY_VERSION}`);
|
|
145
139
|
hasher.update("\0");
|
|
146
|
-
hasher.update(`
|
|
140
|
+
hasher.update(`flow-remove-types:${transformDependencyVersions.flowRemoveTypes}`);
|
|
147
141
|
hasher.update("\0");
|
|
148
142
|
hasher.update(`transform:${transformImplementationHash}`);
|
|
149
143
|
hasher.update("\0");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/vitest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vitest helpers for React Native",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build": "tsdown"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"
|
|
29
|
+
"flow-remove-types": "2.291.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "24.10.12",
|