@tamagui/build 1.64.4 → 1.65.1

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 +2 -2
  2. package/tamagui-build.js +72 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.64.4",
3
+ "version": "1.65.1",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@types/fs-extra": "^9.0.13",
16
16
  "chokidar": "^3.5.2",
17
- "esbuild": "^0.19.0",
17
+ "esbuild": "^0.19.3",
18
18
  "execa": "^5.0.0",
19
19
  "fast-glob": "^3.2.11",
20
20
  "fs-extra": "^11.1.0",
package/tamagui-build.js CHANGED
@@ -37,7 +37,8 @@ const pkg = fs.readJSONSync('./package.json')
37
37
  let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
38
38
  const pkgMain = pkg.main
39
39
  const pkgSource = pkg.source
40
- const bundleNative = pkg.tamagui?.bundleNative
40
+ const bundleNative = pkg.tamagui?.['bundle.native']
41
+ const bundleNativeTest = pkg.tamagui?.['bundle.native.test']
41
42
  const pkgModule = pkg.module
42
43
  const pkgModuleJSX = pkg['module:jsx']
43
44
  const pkgTypes = Boolean(pkg['types'] || pkg['typings'])
@@ -178,6 +179,55 @@ async function buildJs() {
178
179
 
179
180
  const external = shouldBundle ? ['@swc/*', '*.node'] : undefined
180
181
 
182
+ /** @type { import('esbuild').BuildOptions } */
183
+ const esbuildBundleProps =
184
+ bundleNative || bundleNativeTest
185
+ ? {
186
+ entryPoints: [bundleNative],
187
+ bundle: true,
188
+ target: 'node16',
189
+ format: 'cjs',
190
+ jsx: 'automatic',
191
+ platform: 'node',
192
+ plugins: [
193
+ alias({
194
+ '@tamagui/web': require.resolve('@tamagui/web/native'),
195
+ 'react-native': require.resolve('@tamagui/fake-react-native'),
196
+ 'react-native/Libraries/Renderer/shims/ReactFabric': require.resolve(
197
+ '@tamagui/fake-react-native'
198
+ ),
199
+ 'react-native/Libraries/Renderer/shims/ReactNative': require.resolve(
200
+ '@tamagui/fake-react-native'
201
+ ),
202
+ 'react-native/Libraries/Pressability/Pressability': require.resolve(
203
+ '@tamagui/fake-react-native'
204
+ ),
205
+ 'react-native/Libraries/Pressability/usePressability': require.resolve(
206
+ '@tamagui/fake-react-native/idFn'
207
+ ),
208
+ 'react-native-safe-area-context': require.resolve(
209
+ '@tamagui/fake-react-native'
210
+ ),
211
+ 'react-native-gesture-handler': require.resolve('@tamagui/proxy-worm'),
212
+ }),
213
+ ],
214
+ external: ['react', 'react-dom'],
215
+ resolveExtensions: [
216
+ '.native.ts',
217
+ '.native.tsx',
218
+ '.native.js',
219
+ '.ts',
220
+ '.tsx',
221
+ '.js',
222
+ '.jsx',
223
+ ],
224
+ minify: process.env.MINIFY ? true : false,
225
+ define: {
226
+ 'process.env.TAMAGUI_IS_CORE_NODE': '"1"',
227
+ },
228
+ }
229
+ : {}
230
+
181
231
  const start = Date.now()
182
232
  return await Promise.all([
183
233
  // web output to cjs
@@ -226,52 +276,25 @@ async function buildJs() {
226
276
  bundleNative
227
277
  ? esbuildWriteIfChanged(
228
278
  {
229
- entryPoints: [bundleNative],
230
- outdir: 'dist',
231
- bundle: true,
232
- external,
233
- target: 'node16',
234
- format: 'cjs',
235
- jsx: 'automatic',
236
- plugins: [
237
- alias({
238
- '@tamagui/web': require.resolve('@tamagui/web/native'),
239
- 'react-native': require.resolve('@tamagui/fake-react-native'),
240
- 'react-native/Libraries/Renderer/shims/ReactFabric': require.resolve(
241
- '@tamagui/fake-react-native'
242
- ),
243
- 'react-native/Libraries/Renderer/shims/ReactNative': require.resolve(
244
- '@tamagui/fake-react-native'
245
- ),
246
- 'react-native/Libraries/Pressability/Pressability': require.resolve(
247
- '@tamagui/fake-react-native'
248
- ),
249
- 'react-native/Libraries/Pressability/usePressability': require.resolve(
250
- '@tamagui/fake-react-native/idFn'
251
- ),
252
- 'react-native-safe-area-context': require.resolve(
253
- '@tamagui/fake-react-native'
254
- ),
255
- 'react-native-gesture-handler': require.resolve('@tamagui/proxy-worm'),
256
- }),
257
- ],
258
- external: ['react', 'react-dom'],
259
- resolveExtensions: [
260
- '.native.ts',
261
- '.native.tsx',
262
- '.native.js',
263
- '.ts',
264
- '.tsx',
265
- '.js',
266
- '.jsx',
267
- ],
268
- minify: process.env.MINIFY ? true : false,
269
- define: {
270
- 'process.env.TAMAGUI_IS_CORE_NODE': '"1"',
271
- },
279
+ ...esbuildBundleProps,
280
+ outfile: `dist/native.js`,
281
+ },
282
+ {
283
+ platform: 'native',
284
+ }
285
+ )
286
+ : null,
287
+
288
+ // for tests to load native-mode from node
289
+ bundleNativeTest
290
+ ? esbuildWriteIfChanged(
291
+ {
292
+ ...esbuildBundleProps,
293
+ outfile: `dist/test.js`,
272
294
  },
273
295
  {
274
296
  platform: 'native',
297
+ env: 'test',
275
298
  }
276
299
  )
277
300
  : null,
@@ -352,8 +375,9 @@ async function buildJs() {
352
375
  async function esbuildWriteIfChanged(
353
376
  /** @type { import('esbuild').BuildOptions } */
354
377
  opts,
355
- { platform } = {
378
+ { platform, env } = {
356
379
  platform: '',
380
+ env: '',
357
381
  }
358
382
  ) {
359
383
  if (!shouldWatch && !platform) {
@@ -369,8 +393,6 @@ async function esbuildWriteIfChanged(
369
393
  write: false,
370
394
  color: true,
371
395
  allowOverwrite: true,
372
- color: true,
373
- allowOverwrite: true,
374
396
  keepNames: false,
375
397
  sourcemap: true,
376
398
  sourcesContent: false,
@@ -390,6 +412,9 @@ async function esbuildWriteIfChanged(
390
412
  ...(platform && {
391
413
  'process.env.TAMAGUI_TARGET': `"${platform}"`,
392
414
  }),
415
+ ...(env && {
416
+ 'process.env.NODE_ENV': `"${env}"`,
417
+ }),
393
418
  ...opts.define,
394
419
  },
395
420
  })