@tamagui/build 2.0.0-1768530912818 → 2.0.0-1768636514428

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.
@@ -2,26 +2,36 @@
2
2
   RUN  v4.0.4 /Users/n8/tamagui/code/packages/build
3
3
 
4
4
  stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
5
- Watch process output: built tamagui-build-test-watch-package in 75 ms
5
+ Watch process output: built tamagui-build-test-watch-package in 66 ms
6
6
 
7
7
  Initial build complete, modifying file...
8
8
 
9
9
  stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
10
- Watch process output: built tamagui-build-test-watch-package in 374 ms
10
+ Watch process output: built tamagui-build-test-watch-package in 343 ms
11
11
 
12
12
  Rebuild after file modification complete
13
13
 
14
- ✓ __tests__/integration.test.ts (7 tests) 8426ms
15
- ✓ should build the package correctly  1132ms
16
- ✓ should bundle the package correctly  930ms
17
- ✓ should skip mjs files when --skip-mjs is used  970ms
18
- ✓ should ignore base URL when --ignore-base-url is used  970ms
19
- ✓ should rebuild the package on file change when --watch is used  1144ms
20
- ✓ should generate correct platform-specific output  1004ms
21
- ✓ should minify the output when MINIFY=true is set  2251ms
14
+ stdout | __tests__/integration.test.ts > tamagui-build integration test > should generate correct platform-specific output
15
+ Watch process output: built tamagui-build-test-watch-package in 233 ms
16
+
17
+ Rebuild after file modification complete
18
+
19
+ stdout | __tests__/integration.test.ts
20
+ Watch process output: built tamagui-build-test-watch-package in 214 ms
21
+
22
+ Rebuild after file modification complete
23
+
24
+ ✓ __tests__/integration.test.ts (7 tests) 8021ms
25
+ ✓ should build the package correctly  985ms
26
+ ✓ should bundle the package correctly  931ms
27
+ ✓ should skip mjs files when --skip-mjs is used  994ms
28
+ ✓ should ignore base URL when --ignore-base-url is used  997ms
29
+ ✓ should rebuild the package on file change when --watch is used  1143ms
30
+ ✓ should generate correct platform-specific output  989ms
31
+ ✓ should minify the output when MINIFY=true is set  1963ms
22
32
 
23
33
   Test Files  1 passed (1)
24
34
   Tests  7 passed (7)
25
-  Start at  14:57:43
26
-  Duration  8.56s (transform 41ms, setup 0ms, collect 47ms, tests 8.43s, environment 0ms, prepare 2ms)
35
+  Start at  21:55:33
36
+  Duration  8.13s (transform 36ms, setup 0ms, collect 41ms, tests 8.02s, environment 0ms, prepare 2ms)
27
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "2.0.0-1768530912818",
3
+ "version": "2.0.0-1768636514428",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -13,9 +13,12 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@babel/core": "^7.25.2",
16
+ "@babel/preset-typescript": "^7.26.0",
16
17
  "@swc/core": "^1.14.0",
17
- "@tamagui/babel-plugin-fully-specified": "2.0.0-1768530912818",
18
+ "@tamagui/babel-plugin-fully-specified": "2.0.0-1768636514428",
18
19
  "@types/fs-extra": "^9.0.13",
20
+ "babel-plugin-react-compiler": "^1.0.0",
21
+ "baseline-browser-mapping": "^2.9.11",
19
22
  "chokidar": "^3.5.2",
20
23
  "esbuild": "^0.25.11",
21
24
  "esbuild-plugin-es5": "^2.1.1",
package/tamagui-build.js CHANGED
@@ -21,12 +21,70 @@ const {
21
21
 
22
22
  const jsOnly = !!process.env.JS_ONLY
23
23
  const skipJS = !!(process.env.SKIP_JS || false)
24
+
25
+ /**
26
+ * esbuild plugin that runs React Compiler on TS/TSX files before transformation
27
+ */
28
+ const reactCompilerPlugin = {
29
+ name: 'react-compiler',
30
+ setup(build) {
31
+ build.onLoad({ filter: /\.tsx?$/ }, async (args) => {
32
+ const source = await FSE.readFile(args.path, 'utf8')
33
+ const isTSX = args.path.endsWith('.tsx')
34
+
35
+ try {
36
+ const result = transform(source, {
37
+ filename: args.path,
38
+ configFile: false,
39
+ presets: [
40
+ ['@babel/preset-typescript', { isTSX, allExtensions: true }],
41
+ ],
42
+ plugins: [
43
+ [
44
+ require.resolve('babel-plugin-react-compiler'),
45
+ {
46
+ // Target React 19 for optimal output
47
+ target: '19',
48
+ // Log when functions can't be compiled and why
49
+ logger: process.env.REACT_COMPILER_DEBUG
50
+ ? {
51
+ logEvent(filename, event) {
52
+ if (event.kind === 'CompileError' || event.kind === 'CompileSkip') {
53
+ const name = event.fnLoc?.identifierName || 'unknown'
54
+ const reason = event.detail?.reason || event.reason || ''
55
+ console.log(`[RC] ${basename(filename)}:${name} - ${reason}`)
56
+ }
57
+ },
58
+ }
59
+ : undefined,
60
+ },
61
+ ],
62
+ ],
63
+ })
64
+
65
+ return {
66
+ contents: result.code,
67
+ loader: isTSX ? 'jsx' : 'js', // jsx/js since babel stripped TS
68
+ }
69
+ } catch (err) {
70
+ // If React Compiler fails, fall back to original source
71
+ console.warn(`React Compiler skipped for ${args.path}:`, err.message)
72
+ return null // let esbuild handle it normally
73
+ }
74
+ })
75
+ },
76
+ }
77
+
24
78
  const shouldSkipTypes = !!(
25
79
  process.argv.includes('--skip-types') || process.env.SKIP_TYPES
26
80
  )
27
81
 
28
82
  const shouldSkipNative = !!process.argv.includes('--skip-native')
29
83
  const shouldSkipMJS = !!process.argv.includes('--skip-mjs')
84
+ // React Compiler is disabled by default - use --react-compiler to enable
85
+ const shouldEnableCompiler = !!(
86
+ process.argv.includes('--react-compiler') || process.env.REACT_COMPILER
87
+ )
30
88
  const shouldBundleFlag = !!process.argv.includes('--bundle')
31
89
  const shouldBundleNodeModules = !!process.argv.includes('--bundle-modules')
32
90
  const shouldClean = !!process.argv.includes('clean')
@@ -631,6 +689,9 @@ async function esbuildWriteIfChanged(
631
689
  plugins: [
632
690
  ...(opts.plugins || []),
633
691
 
692
+ // React Compiler for automatic memoization (disabled by default, enable with --react-compiler)
693
+ ...(shouldEnableCompiler ? [reactCompilerPlugin] : []),
694
+
634
695
  ...(platform === 'native' && !opts.bundle
635
696
  ? [
636
697
  // class isnt supported by hermes