@tamagui/build 1.0.0-alpha.2 → 1.0.0-alpha.22

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 CHANGED
@@ -1 +1 @@
1
- {"files":{"node_modules":"1637314740088.0405","externalNodePlugin.js":"fa1cd57f4fb8bc9a8c7ea03adaabc309b322ae0b","package.json":"1f64427e6ff4d05435038f5640160c049cd1a882","tamagui-build.js":"05b9862d7b7019904cd3c34ec444b259cdc8d6aa"},"deps":{}}
1
+ {"files":{"node_modules":"1637314740088.0405","externalNodePlugin.js":"fa1cd57f4fb8bc9a8c7ea03adaabc309b322ae0b","package.json":"debcb00839a9a83a4779764d057c3584db919d43","tamagui-build.js":"7820f3c95f0fb219b6981e6a8d704f9df4fd9c31.1637967515169.9587"},"deps":{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.22",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
@@ -11,15 +11,17 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "devDependencies": {
14
+ "dependencies": {
15
15
  "chokidar": "^3.5.2",
16
- "chokidar-cli": "^2.1.0",
17
- "dts-bundle-generator": "^5.9.0",
18
- "esbuild": "^0.13.14",
16
+ "esbuild": "^0.13.12",
19
17
  "execa": "^5.0.0",
20
18
  "fast-glob": "^3.2.7",
21
19
  "fs-extra": "^9.1.0",
22
- "typescript": "^4.2.4"
20
+ "json5": "^2.2.0",
21
+ "typescript": "^4.5.2"
22
+ },
23
+ "devDependencies": {
24
+ "@types/fs-extra": "^9.0.13"
23
25
  },
24
- "gitHead": "a9f30fdf4ebd448961a6e133741cd4b903185559"
26
+ "gitHead": "f247aca6f00c201efbc317bb24b22a62b08d1033"
25
27
  }
package/tamagui-build.js CHANGED
@@ -2,16 +2,15 @@
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
11
  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')
12
+ const shouldSkipTypes = process.argv.includes('skip-types') || process.env.SKIP_TYPES
13
+ const shouldWatch = process.argv.includes('--watch')
15
14
 
16
15
  const pkg = fs.readJSONSync('./package.json')
17
16
  const pkgSource = pkg.source || 'src/index.ts'
@@ -30,27 +29,42 @@ async function build() {
30
29
  }
31
30
 
32
31
  async function buildTsc() {
33
- if (process.env.JS_ONLY || skipTypes) return
32
+ if (process.env.JS_ONLY || shouldSkipTypes) return
33
+ // NOTE:
34
+ // for Intellisense to work in monorepo you need baseUrl: "../.."
35
+ // but to build things nicely we need here to reset a few things:
36
+ // baseUrl: ., outDir: types, rootDir: src
37
+ // now we can have the best of both worlds
38
+ await fs.remove('types')
39
+
40
+ // NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package...
41
+ // (like tamagui does with @tamagui/core...)
42
+ // we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that
43
+ // but then it causes it to not export the types out from index... so....
44
+ // we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after
45
+ // honestly hate typescript config all around but this seems to work so fuck it
46
+ const tsConfOg = await fs.readFile('tsconfig.json')
47
+ const tsConfJSON = json5.parse(tsConfOg)
48
+ if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) {
49
+ tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts')
50
+ await fs.writeJSON('tsconfig.json', tsConfJSON)
51
+ }
34
52
  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, ''))
53
+ await exec('npx', [
54
+ 'tsc',
55
+ '--baseUrl',
56
+ '.',
57
+ '--outDir',
58
+ 'types',
59
+ '--rootDir',
60
+ 'src',
61
+ '--declaration',
62
+ '--emitDeclarationOnly',
63
+ '--declarationMap',
64
+ ])
65
+ } finally {
66
+ // restore
67
+ await fs.writeFile('tsconfig.json', tsConfOg)
54
68
  }
55
69
  }
56
70
 
@@ -67,11 +81,11 @@ async function build() {
67
81
  pkgMain
68
82
  ? esbuild
69
83
  .build({
70
- entryPoints: ['./src/index'],
71
- outfile: pkgMain,
84
+ entryPoints: files,
85
+ outdir: 'dist/cjs',
86
+ bundle: false,
72
87
  sourcemap: true,
73
88
  target: 'node16',
74
- bundle: true,
75
89
  keepNames: true,
76
90
  format: 'cjs',
77
91
  color: true,
@@ -89,7 +103,7 @@ async function build() {
89
103
  ? esbuild
90
104
  .build({
91
105
  entryPoints: files,
92
- outdir: 'dist',
106
+ outdir: 'dist/esm',
93
107
  sourcemap: true,
94
108
  target: 'es2020',
95
109
  keepNames: true,
@@ -103,26 +117,24 @@ async function build() {
103
117
  console.log(' >-> esm')
104
118
  })
105
119
  : 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,
120
+ esbuild
121
+ .build({
122
+ // only diff is jsx preserve and outdir
123
+ jsx: 'preserve',
124
+ outdir: 'dist/jsx',
125
+ entryPoints: files,
126
+ sourcemap: false,
127
+ target: 'es2020',
128
+ keepNames: true,
129
+ format: 'esm',
130
+ color: true,
131
+ logLevel: 'error',
132
+ minify: false,
133
+ platform: 'neutral',
134
+ })
135
+ .then(() => {
136
+ console.log(' >-> jsx')
137
+ }),
126
138
  ]),
127
139
  ])
128
140
  } catch (error) {
@@ -132,7 +144,7 @@ async function build() {
132
144
  }
133
145
  }
134
146
 
135
- if (watch) {
147
+ if (shouldWatch) {
136
148
  const path = require('path')
137
149
  process.env.IS_WATCHING = true
138
150
  process.env.DISABLE_AUTORUN = true
@@ -161,13 +173,13 @@ if (watch) {
161
173
 
162
174
  for (const dir of watchDirs) {
163
175
  if (dir === 'src') {
164
- build().then(() => watch())
176
+ build().then(() => doWatch())
165
177
  } else {
166
- watch()
178
+ doWatch()
167
179
  }
168
180
 
169
181
  const watchSize = {}
170
- function watch() {
182
+ function doWatch() {
171
183
  const finish = (event, path, stats) => {
172
184
  if (dir === 'src' || (stats && stats.size != watchSize[path])) {
173
185
  if (stats) watchSize[path] = stats.size
@@ -205,39 +217,3 @@ function debounce(callback, wait) {
205
217
  timer = setTimeout(() => callback(...args), wait)
206
218
  }
207
219
  }
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`
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "jsx": "preserve"
6
+ },
7
+ }