@tamagui/build 1.135.7 → 1.136.1

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,26 @@
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 59 ms
5
+ Watch process output: built tamagui-build-test-watch-package in 64 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 347 ms
10
+ Watch process output: built tamagui-build-test-watch-package in 349 ms
11
11
 
12
12
  Rebuild after file modification complete
13
13
 
14
- ✓ __tests__/integration.test.ts (7 tests) 9478ms
15
- ✓ should build the package correctly  1377ms
16
- ✓ should bundle the package correctly  1083ms
17
- ✓ should skip mjs files when --skip-mjs is used  1121ms
18
- ✓ should ignore base URL when --ignore-base-url is used  1128ms
19
- ✓ should rebuild the package on file change when --watch is used  1323ms
20
- ✓ should generate correct platform-specific output  1151ms
21
- ✓ should minify the output when MINIFY=true is set  2278ms
14
+ ✓ __tests__/integration.test.ts (7 tests) 10037ms
15
+ ✓ should build the package correctly  1451ms
16
+ ✓ should bundle the package correctly  1172ms
17
+ ✓ should skip mjs files when --skip-mjs is used  1266ms
18
+ ✓ should ignore base URL when --ignore-base-url is used  1160ms
19
+ ✓ should rebuild the package on file change when --watch is used  1350ms
20
+ ✓ should generate correct platform-specific output  1222ms
21
+ ✓ should minify the output when MINIFY=true is set  2396ms
22
22
 
23
23
   Test Files  1 passed (1)
24
24
   Tests  7 passed (7)
25
-  Start at  05:32:06
26
-  Duration  9.58s (transform 36ms, setup 0ms, collect 41ms, tests 9.48s, environment 0ms, prepare 2ms)
25
+  Start at  16:45:26
26
+  Duration  10.14s (transform 36ms, setup 0ms, collect 41ms, tests 10.04s, environment 0ms, prepare 2ms)
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.135.7",
3
+ "version": "1.136.1",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@babel/core": "^7.25.2",
16
16
  "@swc/core": "^1.14.0",
17
- "@tamagui/babel-plugin-fully-specified": "1.135.7",
17
+ "@tamagui/babel-plugin-fully-specified": "1.136.1",
18
18
  "@types/fs-extra": "^9.0.13",
19
19
  "chokidar": "^3.5.2",
20
20
  "esbuild": "^0.25.11",
@@ -0,0 +1,130 @@
1
+ /* eslint-disable no-console */
2
+
3
+ /**
4
+ * Pretty print TypeScript diagnostics with file location and error codes
5
+ * @param {import('typescript').Diagnostic[]} diagnostics
6
+ * @param {import('typescript')} ts
7
+ */
8
+ function printTypescriptDiagnostics(diagnostics, ts) {
9
+ console.error('\n❌ TypeScript compilation errors:\n')
10
+
11
+ diagnostics.forEach((diagnostic) => {
12
+ const messageText =
13
+ typeof diagnostic.messageText === 'string'
14
+ ? diagnostic.messageText
15
+ : diagnostic.messageText?.messageText || JSON.stringify(diagnostic.messageText)
16
+
17
+ if (diagnostic.file && diagnostic.start !== undefined) {
18
+ const { line, character } = ts.getLineAndCharacterOfPosition(
19
+ diagnostic.file,
20
+ diagnostic.start
21
+ )
22
+ console.error(
23
+ ` ${diagnostic.file.fileName}:${line + 1}:${character + 1} - error TS${diagnostic.code}: ${messageText}`
24
+ )
25
+ } else {
26
+ console.error(` error TS${diagnostic.code}: ${messageText}`)
27
+ }
28
+ })
29
+
30
+ console.error('')
31
+ }
32
+
33
+ /**
34
+ * Pretty print esbuild errors with file location and code snippets
35
+ * @param {Error & { errors?: any[], warnings?: any[] }} err
36
+ */
37
+ function printEsbuildError(err) {
38
+ console.error('\n❌ Build error:\n')
39
+
40
+ // esbuild errors have a formatted message that's much more readable
41
+ if (err.errors && err.errors.length > 0) {
42
+ err.errors.forEach((error) => {
43
+ if (error.location) {
44
+ console.error(
45
+ ` ${error.location.file}:${error.location.line}:${error.location.column}: ${error.text}`
46
+ )
47
+ if (error.location.lineText) {
48
+ console.error(` ${error.location.lineText}`)
49
+ }
50
+ } else {
51
+ console.error(` ${error.text}`)
52
+ }
53
+ })
54
+ } else {
55
+ // Fallback for non-esbuild errors
56
+ console.error(err.message || err)
57
+ }
58
+
59
+ if (err.warnings && err.warnings.length > 0) {
60
+ console.error('\n⚠️ Warnings:\n')
61
+ err.warnings.forEach((warning) => {
62
+ if (warning.location) {
63
+ console.error(
64
+ ` ${warning.location.file}:${warning.location.line}:${warning.location.column}: ${warning.text}`
65
+ )
66
+ } else {
67
+ console.error(` ${warning.text}`)
68
+ }
69
+ })
70
+ }
71
+
72
+ console.error('')
73
+ }
74
+
75
+ /**
76
+ * Pretty print general build errors with stack traces
77
+ * @param {Error} error
78
+ * @param {string} packageName
79
+ * @param {string} cwd
80
+ */
81
+ function printBuildError(error, packageName, cwd) {
82
+ console.error(`\n❌ Error building ${packageName} in ${cwd}:\n`)
83
+
84
+ if (error.stack) {
85
+ // Show a more readable error with the stack trace
86
+ const lines = error.stack.split('\n')
87
+ console.error(` ${lines[0]}`) // The error message
88
+ if (lines.length > 1) {
89
+ console.error('\nStack trace:')
90
+ lines.slice(1, 6).forEach((line) => console.error(` ${line.trim()}`))
91
+ if (lines.length > 6) {
92
+ console.error(` ... and ${lines.length - 6} more`)
93
+ }
94
+ }
95
+ } else {
96
+ console.error(` ${error.message || error}`)
97
+ }
98
+
99
+ console.error('')
100
+ }
101
+
102
+ /**
103
+ * Pretty print TypeScript compilation errors (network, config, etc)
104
+ * @param {Error & { code?: string }} err
105
+ * @param {string} packageName
106
+ */
107
+ function printTypescriptCompilationError(err, packageName) {
108
+ console.error(`\n❌ Error during TypeScript compilation for ${packageName}:\n`)
109
+
110
+ if (err.code === 'ENOTFOUND' || err.code === 'ECONNREFUSED') {
111
+ console.error(` Network error: ${err.message}`)
112
+ } else if (err.message) {
113
+ console.error(` ${err.message}`)
114
+ if (err.stack && process.env.DEBUG) {
115
+ console.error('\nStack trace (DEBUG mode):')
116
+ err.stack.split('\n').slice(1, 6).forEach((line) => console.error(` ${line.trim()}`))
117
+ }
118
+ } else {
119
+ console.error(` ${err}`)
120
+ }
121
+
122
+ console.error('')
123
+ }
124
+
125
+ module.exports = {
126
+ printTypescriptDiagnostics,
127
+ printEsbuildError,
128
+ printBuildError,
129
+ printTypescriptCompilationError,
130
+ }
package/tamagui-build.js CHANGED
@@ -13,6 +13,12 @@ const { es5Plugin } = require('./esbuild-es5')
13
13
  const ts = require('typescript')
14
14
  const path = require('node:path')
15
15
  const childProcess = require('node:child_process')
16
+ const {
17
+ printTypescriptDiagnostics,
18
+ printEsbuildError,
19
+ printBuildError,
20
+ printTypescriptCompilationError,
21
+ } = require('./pretty-print-errors')
16
22
 
17
23
  const jsOnly = !!process.env.JS_ONLY
18
24
  const skipJS = !!(process.env.SKIP_JS || false)
@@ -178,7 +184,7 @@ async function build({ skipTypes } = {}) {
178
184
  // Run afterBuild script if defined
179
185
  await runAfterBuild()
180
186
  } catch (error) {
181
- console.error(` Error building in ${process.cwd()}:\n\n`, error.stack + '\n')
187
+ printBuildError(error, pkg.name, process.cwd())
182
188
  if (!shouldWatch) {
183
189
  process.exit(1)
184
190
  }
@@ -267,9 +273,7 @@ async function buildTsc(allFiles) {
267
273
 
268
274
  // exit on errors
269
275
  if (diagnostics.some((x) => x.code) && !shouldWatch) {
270
- console.error(
271
- `Error building: ${diagnostics.map((x) => JSON.stringify(x.messageText)).join('\n')}`
272
- )
276
+ printTypescriptDiagnostics(diagnostics, ts)
273
277
  if (shouldWatch) {
274
278
  return
275
279
  }
@@ -282,11 +286,7 @@ async function buildTsc(allFiles) {
282
286
  throw new Error('TypeScript compilation failed')
283
287
  }
284
288
  } catch (err) {
285
- if (err.code === 'ENOTFOUND' || err.code === 'ECONNREFUSED') {
286
- console.error(`Network error during compilation for ${pkg.name}:`, err.message)
287
- } else {
288
- console.error(`Error during TypeScript compilation for ${pkg.name}:`, err)
289
- }
289
+ printTypescriptCompilationError(err, pkg.name)
290
290
  if (!shouldWatch) {
291
291
  process.exit(1)
292
292
  }
@@ -653,7 +653,7 @@ async function esbuildWriteIfChanged(
653
653
  try {
654
654
  built = await esbuild.build(buildSettings)
655
655
  } catch (err) {
656
- console.error(`Error building`, err)
656
+ printEsbuildError(err)
657
657
  if (!shouldWatch) {
658
658
  process.exit(1)
659
659
  }