@tamagui/build 1.0.0-alpha.0

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.
@@ -0,0 +1 @@
1
+ {"files":{"node_modules":"1637314740088.0405","esdx.js":"c41ee3117238f7b7cfacdbc47822337be6442571","etc/.swcrc-modern":"04f4635a63c4ab2a354a3653ac21f2c224418c26","etc/.swcrc-node":"99d19d89115c5d73b0f54c2f2a6a9023a158090d","externalNodePlugin.js":"fa1cd57f4fb8bc9a8c7ea03adaabc309b322ae0b","package.json":"cb1a2de2b5a550ee39283fbd18eaa07b1e78e292"},"deps":{}}
@@ -0,0 +1,29 @@
1
+ // Must not start with "/" or "./" or "../"
2
+ const NON_NODE_MODULE_RE = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/
3
+
4
+ module.exports = ({ patterns, skipNodeModulesBundle, disabled }) => {
5
+ return {
6
+ name: `external`,
7
+ setup(build) {
8
+ if (disabled) return
9
+ if (skipNodeModulesBundle) {
10
+ build.onResolve({ filter: NON_NODE_MODULE_RE }, (args) => ({
11
+ path: args.path,
12
+ external: true,
13
+ }))
14
+ }
15
+ if (!patterns || patterns.length === 0) return
16
+ build.onResolve({ filter: /.*/ }, (args) => {
17
+ const external = patterns.some((p) => {
18
+ if (p instanceof RegExp) {
19
+ return p.test(args.path)
20
+ }
21
+ return args.path === p
22
+ })
23
+ if (external) {
24
+ return { path: args.path, external }
25
+ }
26
+ })
27
+ },
28
+ }
29
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@tamagui/build",
3
+ "version": "1.0.0-alpha.0",
4
+ "bin": {
5
+ "tamagui-build": "tamagui-build.js"
6
+ },
7
+ "scripts": {
8
+ "build": "true",
9
+ "watch": "true"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "devDependencies": {
15
+ "chokidar": "^3.5.2",
16
+ "chokidar-cli": "^2.1.0",
17
+ "dts-bundle-generator": "^5.9.0",
18
+ "esbuild": "^0.13.14",
19
+ "execa": "^5.0.0",
20
+ "fast-glob": "^3.2.7",
21
+ "fs-extra": "^9.1.0",
22
+ "typescript": "^4.2.4"
23
+ }
24
+ }
@@ -0,0 +1,243 @@
1
+ #!/usr/bin/env node
2
+
3
+ const exec = require('execa')
4
+ const fs = require('fs-extra')
5
+ const esbuild = require('esbuild')
6
+ const fg = require('fast-glob')
7
+ const createExternalPlugin = require('./externalNodePlugin')
8
+ const path = require('path')
9
+
10
+ const skipJS = process.env.SKIP_JS || false
11
+ const skipTypes = process.argv.includes('skip-types') || process.env.SKIP_TYPES
12
+ const jsx = process.argv.includes('--jsx')
13
+ const watch = process.argv.includes('--watch')
14
+ const legacy = process.argv.includes('legacy')
15
+
16
+ const pkg = fs.readJSONSync('./package.json')
17
+ const pkgSource = pkg.source || 'src/index.ts'
18
+ const pkgMain = pkg.main
19
+ const pkgModule = pkg.module
20
+
21
+ async function build() {
22
+ console.log('🥚', pkg.name)
23
+ const x = Date.now()
24
+ let files = (await fg(['src/**/*.ts', 'src/**/*.tsx'])).filter((x) => !x.includes('.d.ts'))
25
+
26
+ if (process.env.NO_CLEAN) {
27
+ console.log('skip typecheck')
28
+ } else {
29
+ fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo')
30
+ }
31
+
32
+ async function buildTsc() {
33
+ if (process.env.JS_ONLY || skipTypes) return
34
+ try {
35
+ if (legacy) {
36
+ await exec('npx', [
37
+ 'tsc',
38
+ '--declaration',
39
+ '--emitDeclarationOnly',
40
+ '--declarationMap',
41
+ '--declarationDir',
42
+ 'types',
43
+ ])
44
+ } else {
45
+ await exec(
46
+ 'npx',
47
+ // was going super slow... --no-check for now..?
48
+ ['dts-bundle-generator', watch ? '--no-check' : [], '-o', 'types.d.ts', pkgSource].flat()
49
+ )
50
+ }
51
+ } catch (err) {
52
+ console.log('Errors during tsc build, may be ok')
53
+ console.log(err.message.replace(ignoreSkipLibCheckOutputRNNodeConflicting, ''))
54
+ }
55
+ }
56
+
57
+ const externalPlugin = createExternalPlugin({
58
+ skipNodeModulesBundle: true,
59
+ })
60
+
61
+ try {
62
+ await Promise.all([
63
+ buildTsc(),
64
+ ...(skipJS
65
+ ? []
66
+ : [
67
+ pkgMain
68
+ ? esbuild
69
+ .build({
70
+ entryPoints: ['./src/index'],
71
+ outfile: pkgMain,
72
+ sourcemap: true,
73
+ target: 'node16',
74
+ bundle: true,
75
+ keepNames: true,
76
+ format: 'cjs',
77
+ color: true,
78
+ logLevel: 'error',
79
+ plugins: [externalPlugin],
80
+ minify: false,
81
+ platform: 'neutral',
82
+ })
83
+ .then(() => {
84
+ console.log(' >-> commonjs')
85
+ })
86
+ : null,
87
+ // dont bundle for tree shaking
88
+ pkgModule
89
+ ? esbuild
90
+ .build({
91
+ entryPoints: files,
92
+ outdir: 'dist',
93
+ sourcemap: true,
94
+ target: 'es2020',
95
+ keepNames: true,
96
+ format: 'esm',
97
+ color: true,
98
+ logLevel: 'error',
99
+ minify: false,
100
+ platform: 'neutral',
101
+ })
102
+ .then(() => {
103
+ console.log(' >-> esm')
104
+ })
105
+ : null,
106
+ jsx
107
+ ? esbuild
108
+ .build({
109
+ // only diff is jsx preserve and outdir
110
+ jsx: 'preserve',
111
+ outdir: '_jsx',
112
+ entryPoints: files,
113
+ sourcemap: false,
114
+ target: 'es2020',
115
+ keepNames: true,
116
+ format: 'esm',
117
+ color: true,
118
+ logLevel: 'error',
119
+ minify: false,
120
+ platform: 'neutral',
121
+ })
122
+ .then(() => {
123
+ console.log(' >-> jsx')
124
+ })
125
+ : null,
126
+ ]),
127
+ ])
128
+ } catch (error) {
129
+ console.log('error', error)
130
+ } finally {
131
+ console.log('built in', `${(Date.now() - x) / 1000}s`)
132
+ }
133
+ }
134
+
135
+ if (watch) {
136
+ const path = require('path')
137
+ process.env.IS_WATCHING = true
138
+ process.env.DISABLE_AUTORUN = true
139
+
140
+ // TODO determine internal packages smarter
141
+ const deps = [
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)
189
+ }
190
+ }
191
+
192
+ if (deps.length) {
193
+ console.log(' ', pkg.name, '👀', deps.join(', '))
194
+ }
195
+ } else {
196
+ process.on('uncaughtException', console.log.bind(console))
197
+ process.on('unhandledRejection', console.log.bind(console))
198
+ build()
199
+ }
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`