@tamagui/build 1.0.0-alpha.12 → 1.0.0-alpha.31
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 -6
- package/tamagui-build.js +56 -81
- 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":"1a540bebd6c1b0404e01511a8af29cd532436279","tamagui-build.js":"06b3a361913d9bd875ce4eeb7f3cdad6b443ece3.1638416111368.626","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.31",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tamagui-build": "tamagui-build.js"
|
|
6
6
|
},
|
|
@@ -11,14 +11,17 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
14
|
+
"dependencies": {
|
|
15
15
|
"chokidar": "^3.5.2",
|
|
16
|
-
"
|
|
17
|
-
"esbuild": "^0.13.14",
|
|
16
|
+
"esbuild": "^0.13.12",
|
|
18
17
|
"execa": "^5.0.0",
|
|
19
18
|
"fast-glob": "^3.2.7",
|
|
20
19
|
"fs-extra": "^9.1.0",
|
|
21
|
-
"
|
|
20
|
+
"json5": "^2.2.0",
|
|
21
|
+
"typescript": "^4.5.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/fs-extra": "^9.0.13"
|
|
22
25
|
},
|
|
23
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "3593d13742ae284776db7fbe0486d622312c7c15"
|
|
24
27
|
}
|
package/tamagui-build.js
CHANGED
|
@@ -2,17 +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
|
|
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)
|
|
12
14
|
const shouldWatch = process.argv.includes('--watch')
|
|
13
15
|
|
|
16
|
+
let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
|
|
17
|
+
|
|
14
18
|
const pkg = fs.readJSONSync('./package.json')
|
|
15
|
-
const pkgSource = pkg.source || 'src/index.ts'
|
|
16
19
|
const pkgMain = pkg.main
|
|
17
20
|
const pkgModule = pkg.module
|
|
18
21
|
|
|
@@ -28,25 +31,48 @@ async function build() {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
async function buildTsc() {
|
|
31
|
-
if (
|
|
34
|
+
if (jsOnly || shouldSkipTypes) return
|
|
35
|
+
if (shouldSkipInitialTypes) {
|
|
36
|
+
shouldSkipInitialTypes = false
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
// NOTE:
|
|
33
41
|
// for Intellisense to work in monorepo you need baseUrl: "../.."
|
|
34
42
|
// but to build things nicely we need here to reset a few things:
|
|
35
43
|
// baseUrl: ., outDir: types, rootDir: src
|
|
36
44
|
// now we can have the best of both worlds
|
|
37
45
|
await fs.remove('types')
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'
|
|
49
|
-
|
|
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
|
+
}
|
|
59
|
+
try {
|
|
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)
|
|
75
|
+
}
|
|
50
76
|
}
|
|
51
77
|
|
|
52
78
|
const externalPlugin = createExternalPlugin({
|
|
@@ -129,72 +155,21 @@ if (shouldWatch) {
|
|
|
129
155
|
const path = require('path')
|
|
130
156
|
process.env.IS_WATCHING = true
|
|
131
157
|
process.env.DISABLE_AUTORUN = true
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
...new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})]),
|
|
136
|
-
]
|
|
137
|
-
.filter(Boolean)
|
|
138
|
-
.filter((x) => x.includes(`tamagui`))
|
|
139
|
-
|
|
140
|
-
const watchDirs = [
|
|
141
|
-
'src',
|
|
142
|
-
...deps.flatMap((d) => {
|
|
143
|
-
try {
|
|
144
|
-
return path.dirname(require.resolve(d))
|
|
145
|
-
} catch {
|
|
146
|
-
const potentialDir = path.join('..', d.replace('@tamagui/', '') + '/dist')
|
|
147
|
-
if (fs.existsSync(potentialDir)) {
|
|
148
|
-
return potentialDir
|
|
149
|
-
}
|
|
150
|
-
return []
|
|
151
|
-
}
|
|
152
|
-
}),
|
|
153
|
-
]
|
|
154
|
-
|
|
155
|
-
for (const dir of watchDirs) {
|
|
156
|
-
if (dir === 'src') {
|
|
157
|
-
build().then(() => doWatch())
|
|
158
|
-
} else {
|
|
159
|
-
doWatch()
|
|
158
|
+
build().then(() => {
|
|
159
|
+
const finish = (_, path, stats) => {
|
|
160
|
+
build()
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const chokidar = require('chokidar')
|
|
173
|
-
chokidar
|
|
174
|
-
// prevent infinite loop but cause race condition if you just build directly
|
|
175
|
-
.watch(dir, {
|
|
176
|
-
persistent: true,
|
|
177
|
-
alwaysStat: true,
|
|
178
|
-
ignoreInitial: true,
|
|
179
|
-
})
|
|
180
|
-
.on('change', finish)
|
|
181
|
-
.on('add', finish)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (deps.length) {
|
|
186
|
-
console.log(' ', pkg.name, '👀', deps.join(', '))
|
|
187
|
-
}
|
|
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
|
+
})
|
|
188
173
|
} else {
|
|
189
|
-
process.on('uncaughtException', console.log.bind(console))
|
|
190
|
-
process.on('unhandledRejection', console.log.bind(console))
|
|
191
174
|
build()
|
|
192
175
|
}
|
|
193
|
-
|
|
194
|
-
function debounce(callback, wait) {
|
|
195
|
-
let timer
|
|
196
|
-
return (...args) => {
|
|
197
|
-
clearTimeout(timer)
|
|
198
|
-
timer = setTimeout(() => callback(...args), wait)
|
|
199
|
-
}
|
|
200
|
-
}
|