@tamagui/build 1.0.1-beta.76 → 1.0.1-beta.77

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 cc1d4d16ed3548a4
1
+ @tamagui/build:build: cache hit, replaying output 5244957ac2aedd1a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.0.1-beta.76",
3
+ "version": "1.0.1-beta.77",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
@@ -17,9 +17,8 @@
17
17
  "execa": "^5.0.0",
18
18
  "fast-glob": "^3.2.11",
19
19
  "fs-extra": "^10.1.0",
20
- "json5": "^2.2.0",
21
20
  "lodash.debounce": "^4.0.8",
22
- "typescript": "^4.7.2"
21
+ "typescript": "^4.8.0-beta"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@types/fs-extra": "^9.0.13"
package/tamagui-build.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  const exec = require('execa')
4
4
  const fs = require('fs-extra')
5
- const json5 = require('json5')
6
5
  const esbuild = require('esbuild')
7
6
  const fg = require('fast-glob')
8
7
  const createExternalPlugin = require('./externalNodePlugin')
@@ -75,11 +74,10 @@ async function build() {
75
74
  buildTsc(),
76
75
  buildJs(),
77
76
  ])
78
- if (shouldWatch) {
79
- console.log('built in', Date.now() - start, 'ms')
80
- }
77
+ console.log('built', pkg.name, 'in', Date.now() - start, 'ms')
81
78
  } catch (error) {
82
79
  console.log(error.message)
80
+ process.exit(1)
83
81
  }
84
82
  }
85
83
 
@@ -90,40 +88,36 @@ async function buildTsc() {
90
88
  return
91
89
  }
92
90
 
91
+ function buildNoMap() {
92
+ return exec(
93
+ 'npx',
94
+ `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly`.split(' ')
95
+ )
96
+ }
97
+
98
+ function buildWithMap() {
99
+ return exec(
100
+ 'npx',
101
+ `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly --declarationMap`.split(
102
+ ' '
103
+ )
104
+ )
105
+ }
106
+
93
107
  // NOTE:
94
108
  // for Intellisense to work in monorepo you need baseUrl: "../.."
95
109
  // but to build things nicely we need here to reset a few things:
96
110
  // baseUrl: ., outDir: types, rootDir: src
97
- // now we can have the best of both worlds
98
-
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
+ // for best of both worlds
111
112
  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
- ])
113
+ await buildWithMap()
124
114
  } finally {
125
- // restore
126
- await fs.writeFile('tsconfig.json', tsConfOg)
115
+ // if no types folder, patch a typescript bug...
116
+ if (!(await fs.pathExists('types'))) {
117
+ console.warn('BUG re-run without declaration first fixes no output bug...')
118
+ await buildNoMap()
119
+ await buildWithMap()
120
+ }
127
121
  }
128
122
  }
129
123