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