@tamagui/build 1.0.1-beta.134 → 1.0.1-beta.135

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tamagui-build.js +13 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.0.1-beta.134",
3
+ "version": "1.0.1-beta.135",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
package/tamagui-build.js CHANGED
@@ -6,7 +6,8 @@ const esbuild = require('esbuild')
6
6
  const fg = require('fast-glob')
7
7
  const createExternalPlugin = require('./externalNodePlugin')
8
8
  const debounce = require('lodash.debounce')
9
- const { dirname } = require('path')
9
+ const { dirname, join } = require('path')
10
+ const { tmpdir } = require('os')
10
11
 
11
12
  const jsOnly = !!process.env.JS_ONLY
12
13
  const skipJS = !!(process.env.SKIP_JS || false)
@@ -94,20 +95,16 @@ async function buildTsc() {
94
95
  return
95
96
  }
96
97
 
97
- function buildNoMap() {
98
- return exec(
98
+ async function buildThenCopy() {
99
+ const targetDir = join(tmpdir(), `tamagui-${Math.random() * 100000000}`.replace('.', ''))
100
+ await exec(
99
101
  'npx',
100
- `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly`.split(' ')
101
- )
102
- }
103
-
104
- function buildWithMap() {
105
- return exec(
106
- 'npx',
107
- `tsc --baseUrl . --outDir types --rootDir src --declaration --emitDeclarationOnly --declarationMap`.split(
102
+ `tsc --baseUrl . --outDir ${targetDir} --rootDir src --declaration --emitDeclarationOnly --declarationMap`.split(
108
103
  ' '
109
104
  )
110
105
  )
106
+ await fs.remove('types')
107
+ await fs.copy(targetDir, 'types')
111
108
  }
112
109
 
113
110
  // NOTE:
@@ -115,16 +112,11 @@ async function buildTsc() {
115
112
  // but to build things nicely we need here to reset a few things:
116
113
  // baseUrl: ., outDir: types, rootDir: src
117
114
  // for best of both worlds
118
- try {
119
- await buildWithMap()
120
- } finally {
121
- // if no types folder, patch a typescript bug...
122
- if (!(await fs.pathExists('types'))) {
123
- console.warn('BUG re-run without declaration first fixes no output bug...')
124
- await buildNoMap()
125
- await buildWithMap()
126
- }
127
- }
115
+
116
+ // there's a bug with typescript where outputting within the same dir just doesn't output for whatever reason
117
+ // i have a hunch it's some cache thing, because if i give a new outDir it works
118
+ // so fixing by always giving a random tmp outdir, and then copying
119
+ await buildThenCopy()
128
120
  }
129
121
 
130
122
  async function buildJs() {