@tamagui/build 1.0.0-alpha.2 → 1.0.0-alpha.36
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/.ultra.cache.json +1 -1
- package/package.json +9 -7
- package/tamagui-build.js +85 -153
- package/tsconfig.json +7 -0
package/.ultra.cache.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":{"node_modules":"1637314740088.0405","externalNodePlugin.js":"fa1cd57f4fb8bc9a8c7ea03adaabc309b322ae0b","package.json":"
|
|
1
|
+
{"files":{"node_modules":"1637314740088.0405","externalNodePlugin.js":"fa1cd57f4fb8bc9a8c7ea03adaabc309b322ae0b","package.json":"fb165ce522eeadc07d26aaefe482ed150d24db77","tamagui-build.js":"8211d15f554dae57e7936a95f0d61901a3567956.1639092869580.528","tsconfig.json":"9862a02e4684884dd8a070c3b58132d338d0ca79"},"deps":{}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/build",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.36",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tamagui-build": "tamagui-build.js"
|
|
6
6
|
},
|
|
@@ -11,15 +11,17 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
14
|
+
"dependencies": {
|
|
15
15
|
"chokidar": "^3.5.2",
|
|
16
|
-
"
|
|
17
|
-
"dts-bundle-generator": "^5.9.0",
|
|
18
|
-
"esbuild": "^0.13.14",
|
|
16
|
+
"esbuild": "^0.13.12",
|
|
19
17
|
"execa": "^5.0.0",
|
|
20
18
|
"fast-glob": "^3.2.7",
|
|
21
19
|
"fs-extra": "^9.1.0",
|
|
22
|
-
"
|
|
20
|
+
"json5": "^2.2.0",
|
|
21
|
+
"typescript": "^4.5.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/fs-extra": "^9.0.13"
|
|
23
25
|
},
|
|
24
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "d5b75feefe9694ee2f107b69c1be98a5f107eada"
|
|
25
27
|
}
|
package/tamagui-build.js
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
const exec = require('execa')
|
|
4
4
|
const fs = require('fs-extra')
|
|
5
|
+
const json5 = require('json5')
|
|
5
6
|
const esbuild = require('esbuild')
|
|
6
7
|
const fg = require('fast-glob')
|
|
7
8
|
const createExternalPlugin = require('./externalNodePlugin')
|
|
8
9
|
const path = require('path')
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
const jsOnly = !!process.env.JS_ONLY
|
|
12
|
+
const skipJS = !!(process.env.SKIP_JS || false)
|
|
13
|
+
const shouldSkipTypes = !!(process.argv.includes('skip-types') || process.env.SKIP_TYPES)
|
|
14
|
+
const shouldWatch = process.argv.includes('--watch')
|
|
15
|
+
|
|
16
|
+
let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
|
|
15
17
|
|
|
16
18
|
const pkg = fs.readJSONSync('./package.json')
|
|
17
|
-
const pkgSource = pkg.source || 'src/index.ts'
|
|
18
19
|
const pkgMain = pkg.main
|
|
19
20
|
const pkgModule = pkg.module
|
|
20
21
|
|
|
@@ -30,27 +31,47 @@ async function build() {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
async function buildTsc() {
|
|
33
|
-
if (
|
|
34
|
+
if (jsOnly || shouldSkipTypes) return
|
|
35
|
+
if (shouldSkipInitialTypes) {
|
|
36
|
+
shouldSkipInitialTypes = false
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// NOTE:
|
|
41
|
+
// for Intellisense to work in monorepo you need baseUrl: "../.."
|
|
42
|
+
// but to build things nicely we need here to reset a few things:
|
|
43
|
+
// baseUrl: ., outDir: types, rootDir: src
|
|
44
|
+
// now we can have the best of both worlds
|
|
45
|
+
await fs.remove('types')
|
|
46
|
+
|
|
47
|
+
// NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package...
|
|
48
|
+
// (like tamagui does with @tamagui/core...)
|
|
49
|
+
// we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that
|
|
50
|
+
// but then it causes it to not export the types out from index... so....
|
|
51
|
+
// we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after
|
|
52
|
+
// honestly hate typescript config all around but this seems to work so fuck it
|
|
53
|
+
const tsConfOg = await fs.readFile('tsconfig.json')
|
|
54
|
+
const tsConfJSON = json5.parse(tsConfOg)
|
|
55
|
+
if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) {
|
|
56
|
+
tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts')
|
|
57
|
+
await fs.writeJSON('tsconfig.json', tsConfJSON)
|
|
58
|
+
}
|
|
34
59
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
console.log('Errors during tsc build, may be ok')
|
|
53
|
-
console.log(err.message.replace(ignoreSkipLibCheckOutputRNNodeConflicting, ''))
|
|
60
|
+
await exec('npx', [
|
|
61
|
+
'tsc',
|
|
62
|
+
'--baseUrl',
|
|
63
|
+
'.',
|
|
64
|
+
'--outDir',
|
|
65
|
+
'types',
|
|
66
|
+
'--rootDir',
|
|
67
|
+
'src',
|
|
68
|
+
'--declaration',
|
|
69
|
+
'--emitDeclarationOnly',
|
|
70
|
+
'--declarationMap',
|
|
71
|
+
])
|
|
72
|
+
} finally {
|
|
73
|
+
// restore
|
|
74
|
+
await fs.writeFile('tsconfig.json', tsConfOg)
|
|
54
75
|
}
|
|
55
76
|
}
|
|
56
77
|
|
|
@@ -67,11 +88,11 @@ async function build() {
|
|
|
67
88
|
pkgMain
|
|
68
89
|
? esbuild
|
|
69
90
|
.build({
|
|
70
|
-
entryPoints:
|
|
71
|
-
|
|
91
|
+
entryPoints: files,
|
|
92
|
+
outdir: 'dist/cjs',
|
|
93
|
+
bundle: false,
|
|
72
94
|
sourcemap: true,
|
|
73
95
|
target: 'node16',
|
|
74
|
-
bundle: true,
|
|
75
96
|
keepNames: true,
|
|
76
97
|
format: 'cjs',
|
|
77
98
|
color: true,
|
|
@@ -89,9 +110,9 @@ async function build() {
|
|
|
89
110
|
? esbuild
|
|
90
111
|
.build({
|
|
91
112
|
entryPoints: files,
|
|
92
|
-
outdir: 'dist',
|
|
113
|
+
outdir: 'dist/esm',
|
|
93
114
|
sourcemap: true,
|
|
94
|
-
target: '
|
|
115
|
+
target: 'es2019',
|
|
95
116
|
keepNames: true,
|
|
96
117
|
format: 'esm',
|
|
97
118
|
color: true,
|
|
@@ -103,26 +124,24 @@ async function build() {
|
|
|
103
124
|
console.log(' >-> esm')
|
|
104
125
|
})
|
|
105
126
|
: null,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
: null,
|
|
127
|
+
esbuild
|
|
128
|
+
.build({
|
|
129
|
+
// only diff is jsx preserve and outdir
|
|
130
|
+
jsx: 'preserve',
|
|
131
|
+
outdir: 'dist/jsx',
|
|
132
|
+
entryPoints: files,
|
|
133
|
+
sourcemap: false,
|
|
134
|
+
target: 'es2019',
|
|
135
|
+
keepNames: true,
|
|
136
|
+
format: 'esm',
|
|
137
|
+
color: true,
|
|
138
|
+
logLevel: 'error',
|
|
139
|
+
minify: false,
|
|
140
|
+
platform: 'neutral',
|
|
141
|
+
})
|
|
142
|
+
.then(() => {
|
|
143
|
+
console.log(' >-> jsx')
|
|
144
|
+
}),
|
|
126
145
|
]),
|
|
127
146
|
])
|
|
128
147
|
} catch (error) {
|
|
@@ -132,112 +151,25 @@ async function build() {
|
|
|
132
151
|
}
|
|
133
152
|
}
|
|
134
153
|
|
|
135
|
-
if (
|
|
154
|
+
if (shouldWatch) {
|
|
136
155
|
const path = require('path')
|
|
137
156
|
process.env.IS_WATCHING = true
|
|
138
157
|
process.env.DISABLE_AUTORUN = true
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
...new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})]),
|
|
143
|
-
]
|
|
144
|
-
.filter(Boolean)
|
|
145
|
-
.filter((x) => x.includes(`tamagui`))
|
|
146
|
-
|
|
147
|
-
const watchDirs = [
|
|
148
|
-
'src',
|
|
149
|
-
...deps.flatMap((d) => {
|
|
150
|
-
try {
|
|
151
|
-
return path.dirname(require.resolve(d))
|
|
152
|
-
} catch {
|
|
153
|
-
const potentialDir = path.join('..', d.replace('@tamagui/', '') + '/dist')
|
|
154
|
-
if (fs.existsSync(potentialDir)) {
|
|
155
|
-
return potentialDir
|
|
156
|
-
}
|
|
157
|
-
return []
|
|
158
|
-
}
|
|
159
|
-
}),
|
|
160
|
-
]
|
|
161
|
-
|
|
162
|
-
for (const dir of watchDirs) {
|
|
163
|
-
if (dir === 'src') {
|
|
164
|
-
build().then(() => watch())
|
|
165
|
-
} else {
|
|
166
|
-
watch()
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const watchSize = {}
|
|
170
|
-
function watch() {
|
|
171
|
-
const finish = (event, path, stats) => {
|
|
172
|
-
if (dir === 'src' || (stats && stats.size != watchSize[path])) {
|
|
173
|
-
if (stats) watchSize[path] = stats.size
|
|
174
|
-
console.log('watch build', dir)
|
|
175
|
-
build()
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const chokidar = require('chokidar')
|
|
180
|
-
chokidar
|
|
181
|
-
// prevent infinite loop but cause race condition if you just build directly
|
|
182
|
-
.watch(dir, {
|
|
183
|
-
persistent: true,
|
|
184
|
-
alwaysStat: true,
|
|
185
|
-
ignoreInitial: true,
|
|
186
|
-
})
|
|
187
|
-
.on('change', finish)
|
|
188
|
-
.on('add', finish)
|
|
158
|
+
build().then(() => {
|
|
159
|
+
const finish = (_, path, stats) => {
|
|
160
|
+
build()
|
|
189
161
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
162
|
+
const chokidar = require('chokidar')
|
|
163
|
+
chokidar
|
|
164
|
+
// prevent infinite loop but cause race condition if you just build directly
|
|
165
|
+
.watch('src', {
|
|
166
|
+
persistent: true,
|
|
167
|
+
alwaysStat: true,
|
|
168
|
+
ignoreInitial: true,
|
|
169
|
+
})
|
|
170
|
+
.on('change', finish)
|
|
171
|
+
.on('add', finish)
|
|
172
|
+
})
|
|
195
173
|
} else {
|
|
196
|
-
process.on('uncaughtException', console.log.bind(console))
|
|
197
|
-
process.on('unhandledRejection', console.log.bind(console))
|
|
198
174
|
build()
|
|
199
175
|
}
|
|
200
|
-
|
|
201
|
-
function debounce(callback, wait) {
|
|
202
|
-
let timer
|
|
203
|
-
return (...args) => {
|
|
204
|
-
clearTimeout(timer)
|
|
205
|
-
timer = setTimeout(() => callback(...args), wait)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const ignoreSkipLibCheckOutputRNNodeConflicting = `../../node_modules/@types/node/globals.d.ts(47,11): error TS2300: Duplicate identifier 'AbortController'.
|
|
210
|
-
../../node_modules/@types/node/globals.d.ts(60,11): error TS2300: Duplicate identifier 'AbortSignal'.
|
|
211
|
-
../../node_modules/@types/node/globals.d.ts(67,13): error TS2300: Duplicate identifier 'AbortController'.
|
|
212
|
-
../../node_modules/@types/node/globals.d.ts(72,13): error TS2300: Duplicate identifier 'AbortSignal'.
|
|
213
|
-
../../node_modules/@types/react-native/globals.d.ts(50,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'Blob' must be of type '{ new (blobParts?: BlobPart[] | undefined, options?: BlobPropertyBag | undefined): Blob; prototype: Blob; }', but here has type '{ new (blobParts?: (string | Blob)[] | undefined, options?: BlobOptions | undefined): Blob; prototype: Blob; }'.
|
|
214
|
-
../../node_modules/@types/react-native/globals.d.ts(65,15): error TS2300: Duplicate identifier 'FormData'.
|
|
215
|
-
../../node_modules/@types/react-native/globals.d.ts(122,5): error TS2717: Subsequent property declarations must have the same type. Property 'body' must be of type 'BodyInit | null | undefined', but here has type 'BodyInit_ | undefined'.
|
|
216
|
-
../../node_modules/@types/react-native/globals.d.ts(131,5): error TS2717: Subsequent property declarations must have the same type. Property 'signal' must be of type 'AbortSignal | null | undefined', but here has type 'AbortSignal | undefined'.
|
|
217
|
-
../../node_modules/@types/react-native/globals.d.ts(149,14): error TS2300: Duplicate identifier 'RequestInfo'.
|
|
218
|
-
../../node_modules/@types/react-native/globals.d.ts(168,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'Response' must be of type '{ new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response; prototype: Response; error(): Response; redirect(url: string | URL, status?: number | undefined): Response; }', but here has type '{ new (body?: BodyInit_ | undefined, init?: ResponseInit | undefined): Response; prototype: Response; error: () => Response; redirect: (url: string, status?: number | undefined) => Response; }'.
|
|
219
|
-
../../node_modules/@types/react-native/globals.d.ts(245,5): error TS2717: Subsequent property declarations must have the same type. Property 'abort' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
220
|
-
../../node_modules/@types/react-native/globals.d.ts(246,5): error TS2717: Subsequent property declarations must have the same type. Property 'error' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
221
|
-
../../node_modules/@types/react-native/globals.d.ts(247,5): error TS2717: Subsequent property declarations must have the same type. Property 'load' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
222
|
-
../../node_modules/@types/react-native/globals.d.ts(248,5): error TS2717: Subsequent property declarations must have the same type. Property 'loadend' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
223
|
-
../../node_modules/@types/react-native/globals.d.ts(249,5): error TS2717: Subsequent property declarations must have the same type. Property 'loadstart' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
224
|
-
../../node_modules/@types/react-native/globals.d.ts(250,5): error TS2717: Subsequent property declarations must have the same type. Property 'progress' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
225
|
-
../../node_modules/@types/react-native/globals.d.ts(251,5): error TS2717: Subsequent property declarations must have the same type. Property 'timeout' must be of type 'ProgressEvent<XMLHttpRequestEventTarget>', but here has type 'ProgressEvent<EventTarget>'.
|
|
226
|
-
../../node_modules/@types/react-native/globals.d.ts(292,14): error TS2300: Duplicate identifier 'XMLHttpRequestResponseType'.
|
|
227
|
-
../../node_modules/@types/react-native/globals.d.ts(299,15): error TS2300: Duplicate identifier 'URL'.
|
|
228
|
-
../../node_modules/@types/react-native/globals.d.ts(324,15): error TS2300: Duplicate identifier 'URLSearchParams'.
|
|
229
|
-
../../node_modules/@types/react-native/globals.d.ts(368,5): error TS2717: Subsequent property declarations must have the same type. Property 'onopen' must be of type '((this: WebSocket, ev: Event) => any) | null', but here has type '(() => void) | null'.
|
|
230
|
-
../../node_modules/@types/react-native/globals.d.ts(369,5): error TS2717: Subsequent property declarations must have the same type. Property 'onmessage' must be of type '((this: WebSocket, ev: MessageEvent<any>) => any) | null', but here has type '((event: WebSocketMessageEvent) => void) | null'.
|
|
231
|
-
../../node_modules/@types/react-native/globals.d.ts(370,5): error TS2717: Subsequent property declarations must have the same type. Property 'onerror' must be of type '((this: WebSocket, ev: Event) => any) | null', but here has type '((event: WebSocketErrorEvent) => void) | null'.
|
|
232
|
-
../../node_modules/@types/react-native/globals.d.ts(371,5): error TS2717: Subsequent property declarations must have the same type. Property 'onclose' must be of type '((this: WebSocket, ev: CloseEvent) => any) | null', but here has type '((event: WebSocketCloseEvent) => void) | null'.
|
|
233
|
-
../../node_modules/@types/react-native/globals.d.ts(372,5): error TS2717: Subsequent property declarations must have the same type. Property 'addEventListener' must be of type '{ <K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }', but here has type 'WebsocketEventListener'.
|
|
234
|
-
../../node_modules/@types/react-native/globals.d.ts(373,5): error TS2717: Subsequent property declarations must have the same type. Property 'removeEventListener' must be of type '{ <K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }', but here has type 'WebsocketEventListener'.
|
|
235
|
-
../../node_modules/@types/react-native/globals.d.ts(376,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'WebSocket' must be of type '{ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket; prototype: WebSocket; readonly CLOSED: number; readonly CLOSING: number; readonly CONNECTING: number; readonly OPEN: number; }', but here has type '{ new (uri: string, protocols?: string | string[] | null | undefined, options?: { [optionName: string]: any; headers: { [headerName: string]: string; }; } | null | undefined): WebSocket; ... 4 more ...; readonly OPEN: number; }'.
|
|
236
|
-
../../node_modules/@types/react-native/globals.d.ts(400,15): error TS2300: Duplicate identifier 'AbortSignal'.
|
|
237
|
-
../../node_modules/@types/react-native/globals.d.ts(400,15): error TS2420: Class 'AbortSignal' incorrectly implements interface 'EventTarget'.
|
|
238
|
-
Property 'dispatchEvent' is missing in type 'AbortSignal' but required in type 'EventTarget'.
|
|
239
|
-
../../node_modules/@types/react-native/globals.d.ts(435,15): error TS2300: Duplicate identifier 'AbortController'.
|
|
240
|
-
../../node_modules/@types/react-native/globals.d.ts(460,14): error TS2717: Subsequent property declarations must have the same type. Property 'error' must be of type 'DOMException | null', but here has type 'Error | null'.
|
|
241
|
-
../../node_modules/@types/react-native/globals.d.ts(468,14): error TS2717: Subsequent property declarations must have the same type. Property 'result' must be of type 'string | ArrayBuffer | null', but here has type 'string | ArrayBuffer'.
|
|
242
|
-
../../node_modules/@types/react-native/node_modules/@types/react/index.d.ts(3094,14): error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
|
|
243
|
-
../../node_modules/@types/react-native/node_modu`
|