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

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 26e656fc1b671471
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.79",
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.7.4"
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,12 @@ 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
- console.log(error.message)
79
+ console.error(`Error building:`, error.message)
80
+ if (!shouldWatch) {
81
+ process.exit(1)
82
+ }
83
83
  }
84
84
  }
85
85
 
@@ -90,40 +90,36 @@ async function buildTsc() {
90
90
  return
91
91
  }
92
92
 
93
+ function buildNoMap() {
94
+ return exec(
95
+ 'npx',
96
+ `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly`.split(' ')
97
+ )
98
+ }
99
+
100
+ function buildWithMap() {
101
+ return exec(
102
+ 'npx',
103
+ `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly --declarationMap`.split(
104
+ ' '
105
+ )
106
+ )
107
+ }
108
+
93
109
  // NOTE:
94
110
  // for Intellisense to work in monorepo you need baseUrl: "../.."
95
111
  // but to build things nicely we need here to reset a few things:
96
112
  // 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
- }
113
+ // for best of both worlds
111
114
  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
- ])
115
+ await buildWithMap()
124
116
  } finally {
125
- // restore
126
- await fs.writeFile('tsconfig.json', tsConfOg)
117
+ // if no types folder, patch a typescript bug...
118
+ if (!(await fs.pathExists('types'))) {
119
+ console.warn('BUG re-run without declaration first fixes no output bug...')
120
+ await buildNoMap()
121
+ await buildWithMap()
122
+ }
127
123
  }
128
124
  }
129
125
 
@@ -176,7 +172,7 @@ async function buildJs() {
176
172
  jsx: 'preserve',
177
173
  outdir: flatOut ? 'dist' : 'dist/jsx',
178
174
  entryPoints: files,
179
- sourcemap: false,
175
+ sourcemap: true,
180
176
  target: 'es2019',
181
177
  keepNames: false,
182
178
  format: 'esm',