@tamagui/build 1.136.0 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.136.0",
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.136.0",
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
  }