@tamagui/build 1.0.1-beta.75 → 1.0.1-beta.78
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/.turbo/turbo-build.log +1 -1
- package/package.json +4 -5
- package/tamagui-build.js +145 -150
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@tamagui/build:build: cache hit, replaying output
|
|
1
|
+
@tamagui/build:build: cache hit, replaying output 8d9a65547c8e741a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/build",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.78",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tamagui-build": "tamagui-build.js"
|
|
6
6
|
},
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
"chokidar": "^3.5.2",
|
|
16
16
|
"esbuild": "^0.14.36",
|
|
17
17
|
"execa": "^5.0.0",
|
|
18
|
-
"fast-glob": "^3.2.
|
|
19
|
-
"fs-extra": "^
|
|
20
|
-
"json5": "^2.2.0",
|
|
18
|
+
"fast-glob": "^3.2.11",
|
|
19
|
+
"fs-extra": "^10.1.0",
|
|
21
20
|
"lodash.debounce": "^4.0.8",
|
|
22
|
-
"typescript": "^4.7.
|
|
21
|
+
"typescript": "^4.7.4"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@types/fs-extra": "^9.0.13"
|
package/tamagui-build.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const exec = require('execa')
|
|
4
4
|
const fs = require('fs-extra')
|
|
5
|
-
const json5 = require('json5')
|
|
6
5
|
const esbuild = require('esbuild')
|
|
7
6
|
const fg = require('fast-glob')
|
|
8
7
|
const createExternalPlugin = require('./externalNodePlugin')
|
|
@@ -16,126 +15,160 @@ const shouldCleanBuildOnly = !!process.argv.includes('clean:build')
|
|
|
16
15
|
const shouldWatch = process.argv.includes('--watch')
|
|
17
16
|
|
|
18
17
|
const pkg = fs.readJSONSync('./package.json')
|
|
18
|
+
let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
|
|
19
|
+
const pkgMain = pkg.main
|
|
20
|
+
const pkgModule = pkg.module
|
|
21
|
+
const pkgModuleJSX = pkg['module:jsx']
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
process.exit(0)
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
await Promise.allSettled([fs.remove('node_modules')])
|
|
31
|
-
} catch {}
|
|
23
|
+
const flatOut = [pkgMain, pkgModule, pkgModuleJSX].filter(Boolean).length === 1
|
|
24
|
+
|
|
25
|
+
async function clean() {
|
|
26
|
+
try {
|
|
27
|
+
await Promise.allSettled([fs.remove('.turbo'), fs.remove('types'), fs.remove('dist')])
|
|
28
|
+
} catch {}
|
|
29
|
+
if (shouldCleanBuildOnly) {
|
|
32
30
|
console.log('» cleaned', pkg.name)
|
|
33
31
|
process.exit(0)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await Promise.allSettled([fs.remove('node_modules')])
|
|
35
|
+
} catch {}
|
|
36
|
+
console.log('» cleaned', pkg.name)
|
|
37
|
+
process.exit(0)
|
|
38
|
+
}
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
if (shouldClean || shouldCleanBuildOnly) {
|
|
41
|
+
clean().then(() => {
|
|
42
|
+
process.exit(0)
|
|
43
|
+
})
|
|
44
|
+
return
|
|
45
|
+
}
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
+
if (shouldWatch) {
|
|
48
|
+
process.env.IS_WATCHING = true
|
|
49
|
+
process.env.DISABLE_AUTORUN = true
|
|
50
|
+
build().then(() => {
|
|
51
|
+
const rebuild = debounce(build, 100)
|
|
52
|
+
const chokidar = require('chokidar')
|
|
53
|
+
chokidar
|
|
54
|
+
// prevent infinite loop but cause race condition if you just build directly
|
|
55
|
+
.watch('src', {
|
|
56
|
+
persistent: true,
|
|
57
|
+
alwaysStat: true,
|
|
58
|
+
ignoreInitial: true,
|
|
59
|
+
})
|
|
60
|
+
.on('change', rebuild)
|
|
61
|
+
.on('add', rebuild)
|
|
62
|
+
})
|
|
63
|
+
return
|
|
64
|
+
}
|
|
47
65
|
|
|
48
|
-
|
|
49
|
-
console.log('skip typecheck')
|
|
50
|
-
} else {
|
|
51
|
-
fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo')
|
|
52
|
-
}
|
|
66
|
+
build()
|
|
53
67
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
async function build() {
|
|
69
|
+
if (process.env.DEBUG) console.log('»', pkg.name)
|
|
70
|
+
try {
|
|
71
|
+
const start = Date.now()
|
|
72
|
+
await Promise.all([
|
|
73
|
+
//
|
|
74
|
+
buildTsc(),
|
|
75
|
+
buildJs(),
|
|
76
|
+
])
|
|
77
|
+
console.log('built', pkg.name, 'in', Date.now() - start, 'ms')
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.log(error.message)
|
|
80
|
+
process.exit(1)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function buildTsc() {
|
|
85
|
+
if (jsOnly || shouldSkipTypes) return
|
|
86
|
+
if (shouldSkipInitialTypes) {
|
|
87
|
+
shouldSkipInitialTypes = false
|
|
88
|
+
return
|
|
89
|
+
}
|
|
60
90
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
function buildNoMap() {
|
|
92
|
+
return exec(
|
|
93
|
+
'npx',
|
|
94
|
+
`tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly`.split(' ')
|
|
95
|
+
)
|
|
96
|
+
}
|
|
66
97
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'--emitDeclarationOnly',
|
|
90
|
-
'--declarationMap',
|
|
91
|
-
])
|
|
92
|
-
} finally {
|
|
93
|
-
// restore
|
|
94
|
-
await fs.writeFile('tsconfig.json', tsConfOg)
|
|
95
|
-
}
|
|
98
|
+
function buildWithMap() {
|
|
99
|
+
return exec(
|
|
100
|
+
'npx',
|
|
101
|
+
`tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly --declarationMap`.split(
|
|
102
|
+
' '
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// NOTE:
|
|
108
|
+
// for Intellisense to work in monorepo you need baseUrl: "../.."
|
|
109
|
+
// but to build things nicely we need here to reset a few things:
|
|
110
|
+
// baseUrl: ., outDir: types, rootDir: src
|
|
111
|
+
// for best of both worlds
|
|
112
|
+
try {
|
|
113
|
+
await buildWithMap()
|
|
114
|
+
} finally {
|
|
115
|
+
// if no types folder, patch a typescript bug...
|
|
116
|
+
if (!(await fs.pathExists('types'))) {
|
|
117
|
+
console.warn('BUG re-run without declaration first fixes no output bug...')
|
|
118
|
+
await buildNoMap()
|
|
119
|
+
await buildWithMap()
|
|
96
120
|
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
97
123
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
:
|
|
135
|
-
|
|
124
|
+
async function buildJs() {
|
|
125
|
+
if (skipJS) {
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
let files = (await fg(['src/**/*.(m)?ts(x)?', 'src/**/*.css'])).filter(
|
|
129
|
+
(x) => !x.includes('.d.ts')
|
|
130
|
+
)
|
|
131
|
+
const externalPlugin = createExternalPlugin({
|
|
132
|
+
skipNodeModulesBundle: true,
|
|
133
|
+
})
|
|
134
|
+
const start = Date.now()
|
|
135
|
+
return await Promise.all([
|
|
136
|
+
pkgMain
|
|
137
|
+
? esbuild.build({
|
|
138
|
+
entryPoints: files,
|
|
139
|
+
outdir: flatOut ? 'dist' : 'dist/cjs',
|
|
140
|
+
bundle: false,
|
|
141
|
+
sourcemap: true,
|
|
142
|
+
target: 'node14',
|
|
143
|
+
keepNames: false,
|
|
144
|
+
format: 'cjs',
|
|
145
|
+
color: true,
|
|
146
|
+
logLevel: 'error',
|
|
147
|
+
plugins: [externalPlugin],
|
|
148
|
+
minify: false,
|
|
149
|
+
platform: 'node',
|
|
150
|
+
})
|
|
151
|
+
: null,
|
|
152
|
+
// dont bundle for tree shaking
|
|
153
|
+
pkgModule
|
|
154
|
+
? esbuild.build({
|
|
155
|
+
entryPoints: files,
|
|
156
|
+
outdir: flatOut ? 'dist' : 'dist/esm',
|
|
157
|
+
sourcemap: true,
|
|
158
|
+
target: 'node16',
|
|
159
|
+
keepNames: false,
|
|
160
|
+
format: 'esm',
|
|
161
|
+
color: true,
|
|
162
|
+
logLevel: 'error',
|
|
163
|
+
minify: false,
|
|
164
|
+
platform: 'neutral',
|
|
165
|
+
})
|
|
166
|
+
: null,
|
|
167
|
+
pkgModuleJSX
|
|
168
|
+
? esbuild.build({
|
|
136
169
|
// only diff is jsx preserve and outdir
|
|
137
170
|
jsx: 'preserve',
|
|
138
|
-
outdir: 'dist/jsx',
|
|
171
|
+
outdir: flatOut ? 'dist' : 'dist/jsx',
|
|
139
172
|
entryPoints: files,
|
|
140
173
|
sourcemap: false,
|
|
141
174
|
target: 'es2019',
|
|
@@ -145,47 +178,9 @@ if (shouldClean || shouldCleanBuildOnly) {
|
|
|
145
178
|
logLevel: 'error',
|
|
146
179
|
minify: false,
|
|
147
180
|
platform: 'neutral',
|
|
148
|
-
}),
|
|
149
|
-
]).then(() => {
|
|
150
|
-
console.log(`built js in ${Date.now() - start}ms`)
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const externalPlugin = createExternalPlugin({
|
|
155
|
-
skipNodeModulesBundle: true,
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
await Promise.all([
|
|
160
|
-
//
|
|
161
|
-
buildTsc(),
|
|
162
|
-
buildJs(),
|
|
163
|
-
])
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.log('error', error)
|
|
166
|
-
} finally {
|
|
167
|
-
console.log('built in', `${(Date.now() - x) / 1000}s`)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (shouldWatch) {
|
|
172
|
-
const path = require('path')
|
|
173
|
-
process.env.IS_WATCHING = true
|
|
174
|
-
process.env.DISABLE_AUTORUN = true
|
|
175
|
-
build().then(() => {
|
|
176
|
-
const rebuild = debounce(build, 100)
|
|
177
|
-
const chokidar = require('chokidar')
|
|
178
|
-
chokidar
|
|
179
|
-
// prevent infinite loop but cause race condition if you just build directly
|
|
180
|
-
.watch('src', {
|
|
181
|
-
persistent: true,
|
|
182
|
-
alwaysStat: true,
|
|
183
|
-
ignoreInitial: true,
|
|
184
181
|
})
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
build()
|
|
190
|
-
}
|
|
182
|
+
: null,
|
|
183
|
+
]).then(() => {
|
|
184
|
+
if (process.env.DEBUG) console.log(`built js in ${Date.now() - start}ms`)
|
|
185
|
+
})
|
|
191
186
|
}
|