@tamagui/build 1.0.0-alpha.58 → 1.0.0-beta.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.
@@ -1 +1 @@
1
- @tamagui/build:build: cache hit, replaying output 1b926faeea2823d0
1
+ @tamagui/build:build: cache hit, replaying output f63532eebd5fe683
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.0.0-alpha.58",
3
+ "version": "1.0.0-beta.0",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "chokidar": "^3.5.2",
16
- "esbuild": "^0.13.12",
16
+ "esbuild": "^0.14.36",
17
17
  "execa": "^5.0.0",
18
18
  "fast-glob": "^3.2.7",
19
19
  "fs-extra": "^9.1.0",
@@ -23,5 +23,5 @@
23
23
  "devDependencies": {
24
24
  "@types/fs-extra": "^9.0.13"
25
25
  },
26
- "gitHead": "d0ee3344565501e50d5a1bc2ea85ea542bb71955"
26
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
27
27
  }
package/tamagui-build.js CHANGED
@@ -6,172 +6,190 @@ const json5 = require('json5')
6
6
  const esbuild = require('esbuild')
7
7
  const fg = require('fast-glob')
8
8
  const createExternalPlugin = require('./externalNodePlugin')
9
- const path = require('path')
10
9
 
11
10
  const jsOnly = !!process.env.JS_ONLY
12
11
  const skipJS = !!(process.env.SKIP_JS || false)
13
12
  const shouldSkipTypes = !!(process.argv.includes('skip-types') || process.env.SKIP_TYPES)
13
+ const shouldClean = !!process.argv.includes('clean')
14
+ const shouldCleanBuildOnly = !!process.argv.includes('clean:build')
14
15
  const shouldWatch = process.argv.includes('--watch')
15
16
 
16
- let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
17
-
18
17
  const pkg = fs.readJSONSync('./package.json')
19
- const pkgMain = pkg.main
20
- const pkgModule = pkg.module
21
18
 
22
- async function build() {
23
- console.log('🥚', pkg.name)
24
- const x = Date.now()
25
- let files = (await fg(['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.css'])).filter(
26
- (x) => !x.includes('.d.ts')
27
- )
19
+ if (shouldClean || shouldCleanBuildOnly) {
20
+ ;(async () => {
21
+ try {
22
+ await Promise.allSettled([fs.remove('.turbo'), fs.remove('types'), fs.remove('dist')])
23
+ } catch {}
24
+ if (shouldCleanBuildOnly) {
25
+ console.log('» cleaned', pkg.name)
26
+ process.exit(0)
27
+ }
28
+ try {
29
+ await Promise.allSettled([fs.remove('node_modules')])
30
+ } catch {}
31
+ console.log('» cleaned', pkg.name)
32
+ process.exit(0)
33
+ })()
34
+ } else {
35
+ let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
28
36
 
29
- if (process.env.NO_CLEAN) {
30
- console.log('skip typecheck')
31
- } else {
32
- fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo')
33
- }
37
+ const pkgMain = pkg.main
38
+ const pkgModule = pkg.module
34
39
 
35
- async function buildTsc() {
36
- if (jsOnly || shouldSkipTypes) return
37
- if (shouldSkipInitialTypes) {
38
- shouldSkipInitialTypes = false
39
- return
40
+ async function build() {
41
+ console.log('»', pkg.name)
42
+ const x = Date.now()
43
+ let files = (await fg(['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.css'])).filter(
44
+ (x) => !x.includes('.d.ts')
45
+ )
46
+
47
+ if (process.env.NO_CLEAN) {
48
+ console.log('skip typecheck')
49
+ } else {
50
+ fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo')
40
51
  }
41
52
 
42
- // NOTE:
43
- // for Intellisense to work in monorepo you need baseUrl: "../.."
44
- // but to build things nicely we need here to reset a few things:
45
- // baseUrl: ., outDir: types, rootDir: src
46
- // now we can have the best of both worlds
47
- await fs.remove('types')
53
+ async function buildTsc() {
54
+ if (jsOnly || shouldSkipTypes) return
55
+ if (shouldSkipInitialTypes) {
56
+ shouldSkipInitialTypes = false
57
+ return
58
+ }
59
+
60
+ // NOTE:
61
+ // for Intellisense to work in monorepo you need baseUrl: "../.."
62
+ // but to build things nicely we need here to reset a few things:
63
+ // baseUrl: ., outDir: types, rootDir: src
64
+ // now we can have the best of both worlds
48
65
 
49
- // NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package...
50
- // (like tamagui does with @tamagui/core...)
51
- // we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that
52
- // but then it causes it to not export the types out from index... so....
53
- // we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after
54
- // honestly hate typescript config all around but this seems to work so fuck it
55
- const tsConfOg = await fs.readFile('tsconfig.json')
56
- const tsConfJSON = json5.parse(tsConfOg)
57
- if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) {
58
- tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts')
59
- await fs.writeJSON('tsconfig.json', tsConfJSON)
66
+ // NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package...
67
+ // (like tamagui does with @tamagui/core...)
68
+ // we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that
69
+ // but then it causes it to not export the types out from index... so....
70
+ // we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after
71
+ // honestly hate typescript config all around but this seems to work so fuck it
72
+ const tsConfOg = await fs.readFile('tsconfig.json')
73
+ const tsConfJSON = json5.parse(tsConfOg)
74
+ if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) {
75
+ tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts')
76
+ await fs.writeJSON('tsconfig.json', tsConfJSON)
77
+ }
78
+ try {
79
+ await exec('npx', [
80
+ 'tsc',
81
+ '--baseUrl',
82
+ '.',
83
+ '--outDir',
84
+ 'types',
85
+ '--rootDir',
86
+ 'src',
87
+ '--declaration',
88
+ '--emitDeclarationOnly',
89
+ '--declarationMap',
90
+ ])
91
+ } finally {
92
+ // restore
93
+ await fs.writeFile('tsconfig.json', tsConfOg)
94
+ }
60
95
  }
96
+
97
+ const externalPlugin = createExternalPlugin({
98
+ skipNodeModulesBundle: true,
99
+ })
100
+
61
101
  try {
62
- await exec('npx', [
63
- 'tsc',
64
- '--baseUrl',
65
- '.',
66
- '--outDir',
67
- 'types',
68
- '--rootDir',
69
- 'src',
70
- '--declaration',
71
- '--emitDeclarationOnly',
72
- '--declarationMap',
102
+ await Promise.all([
103
+ buildTsc(),
104
+ ...(skipJS
105
+ ? []
106
+ : [
107
+ pkgMain
108
+ ? esbuild
109
+ .build({
110
+ entryPoints: files,
111
+ outdir: 'dist/cjs',
112
+ bundle: false,
113
+ sourcemap: true,
114
+ target: 'node14',
115
+ keepNames: true,
116
+ format: 'cjs',
117
+ color: true,
118
+ logLevel: 'error',
119
+ plugins: [externalPlugin],
120
+ minify: false,
121
+ platform: 'node',
122
+ })
123
+ .then(() => {
124
+ console.log(' >-> commonjs')
125
+ })
126
+ : null,
127
+ // dont bundle for tree shaking
128
+ pkgModule
129
+ ? esbuild
130
+ .build({
131
+ entryPoints: files,
132
+ outdir: 'dist/esm',
133
+ sourcemap: true,
134
+ target: 'es2019',
135
+ keepNames: true,
136
+ format: 'esm',
137
+ color: true,
138
+ logLevel: 'error',
139
+ minify: false,
140
+ platform: 'neutral',
141
+ })
142
+ .then(() => {
143
+ console.log(' >-> esm')
144
+ })
145
+ : null,
146
+ esbuild
147
+ .build({
148
+ // only diff is jsx preserve and outdir
149
+ jsx: 'preserve',
150
+ outdir: 'dist/jsx',
151
+ entryPoints: files,
152
+ sourcemap: false,
153
+ target: 'es2019',
154
+ keepNames: true,
155
+ format: 'esm',
156
+ color: true,
157
+ logLevel: 'error',
158
+ minify: false,
159
+ platform: 'neutral',
160
+ })
161
+ .then(() => {
162
+ console.log(' >-> jsx')
163
+ }),
164
+ ]),
73
165
  ])
166
+ } catch (error) {
167
+ console.log('error', error)
74
168
  } finally {
75
- // restore
76
- await fs.writeFile('tsconfig.json', tsConfOg)
169
+ console.log('built in', `${(Date.now() - x) / 1000}s`)
77
170
  }
78
171
  }
79
172
 
80
- const externalPlugin = createExternalPlugin({
81
- skipNodeModulesBundle: true,
82
- })
83
-
84
- try {
85
- await Promise.all([
86
- buildTsc(),
87
- ...(skipJS
88
- ? []
89
- : [
90
- pkgMain
91
- ? esbuild
92
- .build({
93
- entryPoints: files,
94
- outdir: 'dist/cjs',
95
- bundle: false,
96
- sourcemap: true,
97
- target: 'node16',
98
- keepNames: true,
99
- format: 'cjs',
100
- color: true,
101
- logLevel: 'error',
102
- plugins: [externalPlugin],
103
- minify: false,
104
- platform: 'neutral',
105
- })
106
- .then(() => {
107
- console.log(' >-> commonjs')
108
- })
109
- : null,
110
- // dont bundle for tree shaking
111
- pkgModule
112
- ? esbuild
113
- .build({
114
- entryPoints: files,
115
- outdir: 'dist/esm',
116
- sourcemap: true,
117
- target: 'es2019',
118
- keepNames: true,
119
- format: 'esm',
120
- color: true,
121
- logLevel: 'error',
122
- minify: false,
123
- platform: 'neutral',
124
- })
125
- .then(() => {
126
- console.log(' >-> esm')
127
- })
128
- : null,
129
- esbuild
130
- .build({
131
- // only diff is jsx preserve and outdir
132
- jsx: 'preserve',
133
- outdir: 'dist/jsx',
134
- entryPoints: files,
135
- sourcemap: false,
136
- target: 'es2019',
137
- keepNames: true,
138
- format: 'esm',
139
- color: true,
140
- logLevel: 'error',
141
- minify: false,
142
- platform: 'neutral',
143
- })
144
- .then(() => {
145
- console.log(' >-> jsx')
146
- }),
147
- ]),
148
- ])
149
- } catch (error) {
150
- console.log('error', error)
151
- } finally {
152
- console.log('built in', `${(Date.now() - x) / 1000}s`)
173
+ if (shouldWatch) {
174
+ const path = require('path')
175
+ process.env.IS_WATCHING = true
176
+ process.env.DISABLE_AUTORUN = true
177
+ build().then(() => {
178
+ const finish = (_, path, stats) => {
179
+ build()
180
+ }
181
+ const chokidar = require('chokidar')
182
+ chokidar
183
+ // prevent infinite loop but cause race condition if you just build directly
184
+ .watch('src', {
185
+ persistent: true,
186
+ alwaysStat: true,
187
+ ignoreInitial: true,
188
+ })
189
+ .on('change', finish)
190
+ .on('add', finish)
191
+ })
192
+ } else {
193
+ build()
153
194
  }
154
195
  }
155
-
156
- if (shouldWatch) {
157
- const path = require('path')
158
- process.env.IS_WATCHING = true
159
- process.env.DISABLE_AUTORUN = true
160
- build().then(() => {
161
- const finish = (_, path, stats) => {
162
- build()
163
- }
164
- const chokidar = require('chokidar')
165
- chokidar
166
- // prevent infinite loop but cause race condition if you just build directly
167
- .watch('src', {
168
- persistent: true,
169
- alwaysStat: true,
170
- ignoreInitial: true,
171
- })
172
- .on('change', finish)
173
- .on('add', finish)
174
- })
175
- } else {
176
- build()
177
- }
package/tsconfig.json CHANGED
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
+ "include": [],
4
+ "files": [],
3
5
  "compilerOptions": {
4
6
  "composite": true,
5
7
  "jsx": "preserve"
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Nate Wienert
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.