@tamagui/build 1.0.1-beta.133 → 1.0.1-beta.136

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.0.1-beta.133",
3
+ "version": "1.0.1-beta.136",
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,18 @@ async function buildTsc() {
94
95
  return
95
96
  }
96
97
 
97
- function buildNoMap() {
98
- return exec(
99
- '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(
108
- ' '
109
- )
110
- )
98
+ async function buildThenCopy() {
99
+ if (!(await fs.pathExists(`tsconfig.json`))) {
100
+ throw new Error(`No tsconfig.json found`)
101
+ }
102
+ // nest it one extra so permissions of .tsbuildinfo thats written to parent folder arent off
103
+ const targetDir = join(tmpdir(), `tamagui-${Math.random() * 100000000}`.replace('.', ''), 'out')
104
+ await fs.ensureDir(targetDir)
105
+ const cmd = `tsc --baseUrl . --outDir ${targetDir} --rootDir src --declaration --emitDeclarationOnly --declarationMap`
106
+ // console.log('\x1b[2m$', `npx ${cmd}`)
107
+ await exec('npx', cmd.split(' '))
108
+ await fs.remove('types')
109
+ await fs.copy(targetDir, 'types')
111
110
  }
112
111
 
113
112
  // NOTE:
@@ -115,16 +114,11 @@ async function buildTsc() {
115
114
  // but to build things nicely we need here to reset a few things:
116
115
  // baseUrl: ., outDir: types, rootDir: src
117
116
  // 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
- }
117
+
118
+ // there's a bug with typescript where outputting within the same dir just doesn't output for whatever reason
119
+ // i have a hunch it's some cache thing, because if i give a new outDir it works
120
+ // so fixing by always giving a random tmp outdir, and then copying
121
+ await buildThenCopy()
128
122
  }
129
123
 
130
124
  async function buildJs() {
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "include": [],
4
- "files": [],
5
- "compilerOptions": {
6
- "composite": true,
7
- "jsx": "preserve"
8
- },
9
- }