@tamagui/build 1.0.1-beta.140 → 1.0.1-beta.143
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 +1 -1
- package/tamagui-build.js +33 -15
package/package.json
CHANGED
package/tamagui-build.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
2
3
|
|
|
3
4
|
const exec = require('execa')
|
|
4
5
|
const fs = require('fs-extra')
|
|
@@ -6,12 +7,12 @@ const esbuild = require('esbuild')
|
|
|
6
7
|
const fg = require('fast-glob')
|
|
7
8
|
const createExternalPlugin = require('./externalNodePlugin')
|
|
8
9
|
const debounce = require('lodash.debounce')
|
|
9
|
-
const { dirname
|
|
10
|
-
const { tmpdir } = require('os')
|
|
10
|
+
const { dirname } = require('path')
|
|
11
11
|
|
|
12
12
|
const jsOnly = !!process.env.JS_ONLY
|
|
13
13
|
const skipJS = !!(process.env.SKIP_JS || false)
|
|
14
|
-
const shouldSkipTypes = !!(process.argv.includes('skip-types') || process.env.SKIP_TYPES)
|
|
14
|
+
const shouldSkipTypes = !!(process.argv.includes('--skip-types') || process.env.SKIP_TYPES)
|
|
15
|
+
const shouldBundle = !!process.argv.includes('--bundle')
|
|
15
16
|
const shouldClean = !!process.argv.includes('clean')
|
|
16
17
|
const shouldCleanBuildOnly = !!process.argv.includes('clean:build')
|
|
17
18
|
const shouldWatch = process.argv.includes('--watch')
|
|
@@ -33,14 +34,18 @@ async function clean() {
|
|
|
33
34
|
fs.remove('types'),
|
|
34
35
|
fs.remove('dist'),
|
|
35
36
|
])
|
|
36
|
-
} catch {
|
|
37
|
+
} catch {
|
|
38
|
+
// ok
|
|
39
|
+
}
|
|
37
40
|
if (shouldCleanBuildOnly) {
|
|
38
41
|
console.log('🔹 cleaned', pkg.name)
|
|
39
42
|
process.exit(0)
|
|
40
43
|
}
|
|
41
44
|
try {
|
|
42
45
|
await Promise.allSettled([fs.remove('node_modules')])
|
|
43
|
-
} catch {
|
|
46
|
+
} catch {
|
|
47
|
+
// ok
|
|
48
|
+
}
|
|
44
49
|
console.log('🔹 cleaned', pkg.name)
|
|
45
50
|
process.exit(0)
|
|
46
51
|
}
|
|
@@ -88,6 +93,19 @@ async function build() {
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
// const targetDir = `.types${Math.floor(Math.random() * 1_000_000)}`
|
|
97
|
+
// const cleanup = () => {
|
|
98
|
+
// try {
|
|
99
|
+
// fs.removeSync(targetDir)
|
|
100
|
+
// } catch {
|
|
101
|
+
// // ok
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
|
|
105
|
+
// process.once('beforeExit', cleanup)
|
|
106
|
+
// process.once('SIGINT', cleanup)
|
|
107
|
+
// process.once('SIGTERM', cleanup)
|
|
108
|
+
|
|
91
109
|
async function buildTsc() {
|
|
92
110
|
if (jsOnly || shouldSkipTypes) return
|
|
93
111
|
if (shouldSkipInitialTypes) {
|
|
@@ -99,17 +117,16 @@ async function buildTsc() {
|
|
|
99
117
|
if (!(await fs.pathExists(`tsconfig.json`))) {
|
|
100
118
|
throw new Error(`No tsconfig.json found`)
|
|
101
119
|
}
|
|
102
|
-
const targetDir =
|
|
120
|
+
const targetDir = 'types'
|
|
103
121
|
try {
|
|
104
|
-
// typescripts build cache messes up when doing declarationOnly
|
|
122
|
+
// typescripts build cache messes up when doing declarationOnly
|
|
123
|
+
await fs.remove('tsconfig.tsbuildinfo')
|
|
105
124
|
await fs.ensureDir(targetDir)
|
|
106
125
|
const cmd = `tsc --baseUrl . --outDir ${targetDir} --rootDir src --emitDeclarationOnly --declarationMap`
|
|
107
126
|
// console.log('\x1b[2m$', `npx ${cmd}`)
|
|
108
127
|
await exec('npx', cmd.split(' '))
|
|
109
|
-
await fs.remove('types')
|
|
110
|
-
await fs.copy(targetDir, 'types')
|
|
111
128
|
} finally {
|
|
112
|
-
await fs.remove(
|
|
129
|
+
await fs.remove('tsconfig.tsbuildinfo')
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
|
|
@@ -129,7 +146,7 @@ async function buildJs() {
|
|
|
129
146
|
if (skipJS) {
|
|
130
147
|
return
|
|
131
148
|
}
|
|
132
|
-
let files = (await fg(['src/**/*.(m)?
|
|
149
|
+
let files = (await fg(['src/**/*.(m)?[jt]s(x)?', 'src/**/*.css'])).filter(
|
|
133
150
|
(x) => !x.includes('.d.ts')
|
|
134
151
|
)
|
|
135
152
|
const externalPlugin = createExternalPlugin({
|
|
@@ -141,7 +158,7 @@ async function buildJs() {
|
|
|
141
158
|
? esbuildWriteIfChanged({
|
|
142
159
|
entryPoints: files,
|
|
143
160
|
outdir: flatOut ? 'dist' : 'dist/cjs',
|
|
144
|
-
bundle:
|
|
161
|
+
bundle: shouldBundle,
|
|
145
162
|
sourcemap: true,
|
|
146
163
|
target: 'node14',
|
|
147
164
|
keepNames: false,
|
|
@@ -153,11 +170,11 @@ async function buildJs() {
|
|
|
153
170
|
platform: 'node',
|
|
154
171
|
})
|
|
155
172
|
: null,
|
|
156
|
-
// dont bundle for tree shaking
|
|
157
173
|
pkgModule
|
|
158
174
|
? esbuildWriteIfChanged({
|
|
159
175
|
entryPoints: files,
|
|
160
176
|
outdir: flatOut ? 'dist' : 'dist/esm',
|
|
177
|
+
bundle: shouldBundle,
|
|
161
178
|
sourcemap: true,
|
|
162
179
|
target: 'node16',
|
|
163
180
|
keepNames: false,
|
|
@@ -165,7 +182,7 @@ async function buildJs() {
|
|
|
165
182
|
color: true,
|
|
166
183
|
logLevel: 'error',
|
|
167
184
|
minify: false,
|
|
168
|
-
platform: 'neutral',
|
|
185
|
+
platform: shouldBundle ? 'node' : 'neutral',
|
|
169
186
|
})
|
|
170
187
|
: null,
|
|
171
188
|
pkgModuleJSX
|
|
@@ -174,8 +191,9 @@ async function buildJs() {
|
|
|
174
191
|
jsx: 'preserve',
|
|
175
192
|
outdir: flatOut ? 'dist' : 'dist/jsx',
|
|
176
193
|
entryPoints: files,
|
|
194
|
+
bundle: shouldBundle,
|
|
177
195
|
sourcemap: true,
|
|
178
|
-
target: '
|
|
196
|
+
target: 'es2020',
|
|
179
197
|
keepNames: false,
|
|
180
198
|
format: 'esm',
|
|
181
199
|
color: true,
|