@tamagui/native-bundle 2.0.0-rc.4 → 2.0.0-rc.40

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/index.js CHANGED
@@ -20,7 +20,16 @@ async function bundleNative(options) {
20
20
  return name;
21
21
  }
22
22
  };
23
+ const resolvePackageDir = (name) => {
24
+ try {
25
+ const pkgJson = fileURLToPath(import.meta.resolve(`${name}/package.json`));
26
+ return dirname(pkgJson);
27
+ } catch {
28
+ return name;
29
+ }
30
+ };
23
31
  const rnwl = resolvePath("@tamagui/react-native-web-lite");
32
+ const rnwlDir = resolvePackageDir("@tamagui/react-native-web-lite");
24
33
  const fakeRN = resolvePath("@tamagui/fake-react-native");
25
34
  const entryPath = resolve(cwd, entry);
26
35
  const defaultDefine = {
@@ -28,7 +37,14 @@ async function bundleNative(options) {
28
37
  "process.env.NODE_ENV": JSON.stringify("production"),
29
38
  "process.env.TAMAGUI_IS_CORE_NODE": JSON.stringify("1")
30
39
  };
31
- const external = isTest ? [/^react($|\/)/, /^react-native($|\/)/] : [/^react($|\/)/];
40
+ const external = isTest ? [/^react($|\/)/, /^react-native($|\/)/] : [
41
+ /^react($|\/)/,
42
+ /^react-native-reanimated($|\/)/,
43
+ /^react-native-worklets($|\/)/,
44
+ // Reanimated's internal code requires react-native/Libraries/Renderer/shims/ReactFabric
45
+ // which doesn't exist in the web bundle. Externalize it so the bundler doesn't try to resolve it.
46
+ /react-native\/Libraries\//
47
+ ];
32
48
  const alias = isTest ? [
33
49
  // Aliases don't work for pre-bundled deps, so we externalize and alias in vitest config
34
50
  ] : [
@@ -38,7 +54,7 @@ async function bundleNative(options) {
38
54
  },
39
55
  {
40
56
  find: /^react-native\/(.+)$/,
41
- replacement: `${rnwl}/$1`
57
+ replacement: `${rnwlDir}/src/$1`
42
58
  }
43
59
  ];
44
60
  await build({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/native-bundle",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.40",
4
4
  "description": "Vite-based bundler for creating native CommonJS bundles for Tamagui packages",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -21,7 +21,7 @@
21
21
  "watch": "node build.mjs --watch"
22
22
  },
23
23
  "dependencies": {
24
- "vite": "^7.1.12"
24
+ "vite": "^8.0.3"
25
25
  },
26
26
  "devDependencies": {
27
27
  "esbuild": "^0.27.2"
package/src/index.ts CHANGED
@@ -71,7 +71,17 @@ export async function bundleNative(options: BundleOptions): Promise<void> {
71
71
  }
72
72
  }
73
73
 
74
+ const resolvePackageDir = (name: string) => {
75
+ try {
76
+ const pkgJson = fileURLToPath(import.meta.resolve(`${name}/package.json`))
77
+ return dirname(pkgJson)
78
+ } catch {
79
+ return name
80
+ }
81
+ }
82
+
74
83
  const rnwl = resolvePath('@tamagui/react-native-web-lite')
84
+ const rnwlDir = resolvePackageDir('@tamagui/react-native-web-lite')
75
85
  const fakeRN = resolvePath('@tamagui/fake-react-native')
76
86
  const entryPath = resolve(cwd, entry)
77
87
 
@@ -84,7 +94,16 @@ export async function bundleNative(options: BundleOptions): Promise<void> {
84
94
  // For test bundles, bundle a fake react-native implementation
85
95
  // For production bundles, bundle react-native-web-lite
86
96
  // Note: react and all its subpaths (jsx-runtime, compiler-runtime, etc.) must be external
87
- const external = isTest ? [/^react($|\/)/, /^react-native($|\/)/] : [/^react($|\/)/]
97
+ const external = isTest
98
+ ? [/^react($|\/)/, /^react-native($|\/)/]
99
+ : [
100
+ /^react($|\/)/,
101
+ /^react-native-reanimated($|\/)/,
102
+ /^react-native-worklets($|\/)/,
103
+ // Reanimated's internal code requires react-native/Libraries/Renderer/shims/ReactFabric
104
+ // which doesn't exist in the web bundle. Externalize it so the bundler doesn't try to resolve it.
105
+ /react-native\/Libraries\//,
106
+ ]
88
107
  const alias = isTest
89
108
  ? [
90
109
  // Aliases don't work for pre-bundled deps, so we externalize and alias in vitest config
@@ -96,7 +115,7 @@ export async function bundleNative(options: BundleOptions): Promise<void> {
96
115
  },
97
116
  {
98
117
  find: /^react-native\/(.+)$/,
99
- replacement: `${rnwl}/$1`,
118
+ replacement: `${rnwlDir}/src/$1`,
100
119
  },
101
120
  ]
102
121