@granite-js/vitest 1.0.20 → 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 ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## 1.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 3553158: feat(vitest): fast-flow-transform -> flow-remove-types
8
+
9
+ ## 1.0.21
10
+
11
+ ### Patch Changes
12
+
13
+ - abce9e2: feat: vitest
14
+ - e2f5dee: feat: remove dependency(@react-native/js-polyfill)
15
+
16
+ ## 1.0.20
17
+
18
+ - Initial release.
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 transform from "fast-flow-transform";
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(sourcePath, source) {
44
- return (await transform({
45
- filename: sourcePath,
46
- source,
47
- dialect: "flow-detect",
48
- format: "compact",
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 getFastFlowTransformVersion() {
77
- const fastFlowTransformEntryPath = createRequire(import.meta.url).resolve("fast-flow-transform");
78
- const fastFlowTransformPackageRoot = path.dirname(path.dirname(fastFlowTransformEntryPath));
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 = { fastFlowTransform: getFastFlowTransformVersion() };
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(`fast-flow-transform:${transformDependencyVersions.fastFlowTransform}`);
140
+ hasher.update(`flow-remove-types:${transformDependencyVersions.flowRemoveTypes}`);
147
141
  hasher.update("\0");
148
142
  hasher.update(`transform:${transformImplementationHash}`);
149
143
  hasher.update("\0");
@@ -1,4 +1,3 @@
1
- import "@react-native/js-polyfills/error-guard";
2
1
  import * as react from "react";
3
2
 
4
3
  //#region src/reactNativeRuntime.d.ts
@@ -3,7 +3,6 @@ import { n as installNativeModuleProxy, r as installReactNativeGlobals, t as def
3
3
  import Module, { createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import "@react-native/js-polyfills/error-guard";
7
6
  import { vi } from "vitest";
8
7
 
9
8
  //#region src/reactNativeRuntime.ts
@@ -1702,6 +1701,7 @@ function patchReactNativeResolution() {
1702
1701
  };
1703
1702
  runtimeGlobals.__rntlVitestRnResolverPatched__ = true;
1704
1703
  }
1704
+ runtimeRequire(path.join(reactNativeMirrorRoot, "@react-native", "js-polyfills", "error-guard.js"));
1705
1705
  vi.mock("react-native", () => getSharedReactNativeExports());
1706
1706
  installReactNativeGlobals(runtimeGlobals);
1707
1707
  installNativeModuleProxy(runtimeGlobals);
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "@granite-js/vitest",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "type": "module",
5
5
  "description": "Vitest helpers for React Native",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
6
  "types": "./dist/index.d.ts",
9
7
  "repository": {
10
8
  "type": "git",
@@ -12,21 +10,9 @@
12
10
  "directory": "packages/vitest"
13
11
  },
14
12
  "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js",
18
- "default": "./dist/index.js"
19
- },
20
- "./setup": {
21
- "types": "./dist/setup.d.ts",
22
- "import": "./dist/setup.js",
23
- "default": "./dist/setup.js"
24
- },
25
- "./react-native-runtime": {
26
- "types": "./dist/reactNativeRuntime.d.ts",
27
- "import": "./dist/reactNativeRuntime.js",
28
- "default": "./dist/reactNativeRuntime.js"
29
- },
13
+ ".": "./dist/index.js",
14
+ "./reactNativeRuntime": "./dist/reactNativeRuntime.js",
15
+ "./setup": "./dist/setup.js",
30
16
  "./package.json": "./package.json"
31
17
  },
32
18
  "files": [
@@ -40,16 +26,15 @@
40
26
  "build": "tsdown"
41
27
  },
42
28
  "dependencies": {
43
- "@react-native/js-polyfills": "0.84.0",
44
- "fast-flow-transform": "0.0.3"
29
+ "flow-remove-types": "2.291.0"
45
30
  },
46
31
  "devDependencies": {
47
- "@types/node": "catalog:tools",
48
- "@types/react": "catalog:react-native",
49
- "react": "catalog:react-native",
50
- "react-native": "catalog:react-native",
51
- "tsdown": "catalog:tools",
52
- "typescript": "catalog:tools",
32
+ "@types/node": "24.10.12",
33
+ "@types/react": "19.2.0",
34
+ "react": "19.2.3",
35
+ "react-native": "0.84.0",
36
+ "tsdown": "0.20.3",
37
+ "typescript": "5.9.3",
53
38
  "vitest": "4.1.3"
54
39
  },
55
40
  "peerDependencies": {
@@ -61,4 +46,4 @@
61
46
  "./dist/reactNativeRuntime.js",
62
47
  "./dist/setup.js"
63
48
  ]
64
- }
49
+ }