@tamagui/build 1.135.4 → 1.135.5

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,27 +1,27 @@
1
1
 
2
- RUN v3.2.4 /Users/n8/tamagui/code/packages/build
2
+  RUN  v4.0.4 /Users/n8/tamagui/code/packages/build
3
3
 
4
- stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
5
- Watch process output: built tamagui-build-test-watch-package in 61 ms
4
+ stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
5
+ Watch process output: built tamagui-build-test-watch-package in 70 ms
6
6
 
7
7
  Initial build complete, modifying file...
8
8
 
9
- stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
10
- Watch process output: built tamagui-build-test-watch-package in 335 ms
9
+ stdout | __tests__/integration.test.ts > tamagui-build integration test > should rebuild the package on file change when --watch is used
10
+ Watch process output: built tamagui-build-test-watch-package in 374 ms
11
11
 
12
12
  Rebuild after file modification complete
13
13
 
14
- __tests__/integration.test.ts (7 tests) 10340ms
15
- tamagui-build integration test > should build the package correctly 1433ms
16
- tamagui-build integration test > should bundle the package correctly 1173ms
17
- tamagui-build integration test > should skip mjs files when --skip-mjs is used 1217ms
18
- tamagui-build integration test > should ignore base URL when --ignore-base-url is used 1275ms
19
- tamagui-build integration test > should rebuild the package on file change when --watch is used 1414ms
20
- tamagui-build integration test > should generate correct platform-specific output 1189ms
21
- tamagui-build integration test > should minify the output when MINIFY=true is set 2615ms
22
-
23
- Test Files 1 passed (1)
24
- Tests 7 passed (7)
25
- Start at 09:56:41
26
- Duration 10.55s (transform 48ms, setup 0ms, collect 42ms, tests 10.34s, environment 0ms, prepare 48ms)
14
+ ✓ __tests__/integration.test.ts (7 tests) 9752ms
15
+ ✓ should build the package correctly  1507ms
16
+ ✓ should bundle the package correctly  1113ms
17
+ ✓ should skip mjs files when --skip-mjs is used  1164ms
18
+ ✓ should ignore base URL when --ignore-base-url is used  1125ms
19
+ ✓ should rebuild the package on file change when --watch is used  1328ms
20
+ ✓ should generate correct platform-specific output  1181ms
21
+ ✓ should minify the output when MINIFY=true is set  2313ms
22
+
23
+  Test Files  1 passed (1)
24
+  Tests  7 passed (7)
25
+  Start at  06:15:53
26
+  Duration  9.86s (transform 37ms, setup 0ms, collect 42ms, tests 9.75s, environment 0ms, prepare 2ms)
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.135.4",
3
+ "version": "1.135.5",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -13,22 +13,22 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@babel/core": "^7.25.2",
16
- "@swc/core": "^1.7.21",
17
- "@tamagui/babel-plugin-fully-specified": "1.135.4",
16
+ "@swc/core": "^1.14.0",
17
+ "@tamagui/babel-plugin-fully-specified": "1.135.5",
18
18
  "@types/fs-extra": "^9.0.13",
19
19
  "chokidar": "^3.5.2",
20
- "esbuild": "^0.25.0",
20
+ "esbuild": "^0.25.11",
21
21
  "esbuild-plugin-es5": "^2.1.1",
22
22
  "esbuild-register": "^3.6.0",
23
23
  "execa": "^5.0.0",
24
24
  "fast-glob": "^3.2.11",
25
25
  "fs-extra": "^11.2.0",
26
26
  "lodash.debounce": "^4.0.8",
27
- "oxc-transform": "^0.74.0",
27
+ "oxc-transform": "^0.95.0",
28
28
  "typescript": "^5.8.2"
29
29
  },
30
30
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
31
31
  "devDependencies": {
32
- "vitest": "^3.2.4"
32
+ "vitest": "^4.0.4"
33
33
  }
34
34
  }
package/tamagui-build.js CHANGED
@@ -56,8 +56,6 @@ const pkg = FSE.readJSONSync('./package.json')
56
56
  let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL
57
57
  const pkgMain = pkg.main
58
58
  const pkgSource = pkg.source
59
- const bundleNative = pkg.tamagui?.['bundle.native']
60
- const bundleNativeTest = pkg.tamagui?.['bundle.native.test']
61
59
  const pkgModule = pkg.module
62
60
  const pkgModuleJSX = pkg['module:jsx']
63
61
  const pkgTypes = Boolean(pkg.types || pkg.typings)
@@ -176,6 +174,9 @@ async function build({ skipTypes } = {}) {
176
174
  ])
177
175
 
178
176
  console.info('built', pkg.name, 'in', Date.now() - start, 'ms')
177
+
178
+ // Run afterBuild script if defined
179
+ await runAfterBuild()
179
180
  } catch (error) {
180
181
  console.error(` ❌ Error building in ${process.cwd()}:\n\n`, error.stack + '\n')
181
182
  if (!shouldWatch) {
@@ -184,6 +185,28 @@ async function build({ skipTypes } = {}) {
184
185
  }
185
186
  }
186
187
 
188
+ async function runAfterBuild() {
189
+ const afterBuild = pkg.scripts?.afterBuild
190
+ if (!afterBuild) return
191
+
192
+ try {
193
+ console.info('Running afterBuild script...')
194
+ const start = Date.now()
195
+
196
+ childProcess.execSync(afterBuild, {
197
+ stdio: 'inherit',
198
+ cwd: process.cwd()
199
+ })
200
+
201
+ console.info('afterBuild completed in', Date.now() - start, 'ms')
202
+ } catch (error) {
203
+ console.error('afterBuild failed:', error.message)
204
+ if (!shouldWatch) {
205
+ throw error
206
+ }
207
+ }
208
+ }
209
+
187
210
  async function buildTsc(allFiles) {
188
211
  if (!pkgTypes || jsOnly || shouldSkipTypes) return
189
212
  if (shouldSkipInitialTypes) {
@@ -374,13 +397,31 @@ async function buildJs(allFiles) {
374
397
  const bundlePlugin = {
375
398
  name: `external-most-modules`,
376
399
  setup(build) {
400
+ // Alias esbuild to esbuild-wasm (but keep it external)
401
+ build.onResolve({ filter: /^esbuild$/ }, (args) => {
402
+ return { path: 'esbuild-wasm', external: true }
403
+ })
404
+
377
405
  build.onResolve({ filter: /.*/ }, (args) => {
406
+ // Externalize node built-ins
407
+ if (args.path.startsWith('node:')) {
408
+ return { external: true }
409
+ }
410
+
378
411
  if (
379
412
  !args.path.startsWith('.') &&
380
- !args.path.startsWith('/') &&
381
- !args.path.startsWith('node:')
413
+ !args.path.startsWith('/')
382
414
  ) {
383
- return { external: /^(esbuild|mdx-bundler)$/.test(args.path) }
415
+ // Keep esbuild-wasm external (it needs access to WASM files)
416
+ if (args.path === 'esbuild-wasm' || args.path.startsWith('esbuild-wasm/')) {
417
+ return { external: true }
418
+ }
419
+ // Bundle mdx-bundler and its dependencies
420
+ if (args.path === 'mdx-bundler' || args.path.startsWith('mdx-bundler/')) {
421
+ return { external: false }
422
+ }
423
+ // Externalize all other npm packages
424
+ return { external: true }
384
425
  }
385
426
  })
386
427
  },
@@ -388,58 +429,6 @@ async function buildJs(allFiles) {
388
429
 
389
430
  const external = shouldBundleFlag ? ['@swc/*', '*.node'] : undefined
390
431
 
391
- /** @type { import('esbuild').BuildOptions } */
392
- const esbuildBundleProps =
393
- bundleNative || bundleNativeTest
394
- ? {
395
- entryPoints: [bundleNative],
396
- bundle: true,
397
- plugins: [
398
- alias({
399
- '@tamagui/web': require.resolve('@tamagui/web/native'),
400
-
401
- 'react-native': require.resolve('@tamagui/fake-react-native'),
402
- 'react-native/Libraries/Renderer/shims/ReactFabric': require.resolve(
403
- '@tamagui/fake-react-native'
404
- ),
405
- 'react-native/Libraries/Renderer/shims/ReactNative': require.resolve(
406
- '@tamagui/fake-react-native'
407
- ),
408
-
409
- 'react-native/Libraries/Pressability/Pressability': require.resolve(
410
- '@tamagui/fake-react-native'
411
- ),
412
-
413
- 'react-native/Libraries/Pressability/usePressability': require.resolve(
414
- '@tamagui/fake-react-native/idFn'
415
- ),
416
-
417
- 'react-native-safe-area-context': require.resolve(
418
- '@tamagui/fake-react-native'
419
- ),
420
- 'react-native-gesture-handler': require.resolve('@tamagui/proxy-worm'),
421
- }),
422
- ],
423
- external: [
424
- 'react',
425
- 'react-dom',
426
- bundleNativeTest ? 'react-native' : undefined,
427
- ].filter(Boolean),
428
- resolveExtensions: [
429
- '.native.ts',
430
- '.native.tsx',
431
- '.native.js',
432
- '.ts',
433
- '.tsx',
434
- '.js',
435
- '.jsx',
436
- ],
437
- minify: !!process.env.MINIFY,
438
- define: {
439
- 'process.env.TAMAGUI_IS_CORE_NODE': '"1"',
440
- },
441
- }
442
- : {}
443
432
 
444
433
  const start = Date.now()
445
434
 
@@ -498,33 +487,6 @@ async function buildJs(allFiles) {
498
487
  })
499
488
  : null,
500
489
 
501
- // for tests to load native-mode from node
502
- bundleNative && !shouldSkipNative
503
- ? esbuildWriteIfChanged(
504
- {
505
- ...esbuildBundleProps,
506
- outfile: `dist/native.js`,
507
- },
508
- {
509
- platform: 'native',
510
- }
511
- )
512
- : null,
513
-
514
- // for tests to load native-mode from node
515
- bundleNativeTest && !shouldSkipNative
516
- ? esbuildWriteIfChanged(
517
- {
518
- ...esbuildBundleProps,
519
- outfile: `dist/test.js`,
520
- },
521
- {
522
- platform: 'native',
523
- env: 'test',
524
- }
525
- )
526
- : null,
527
-
528
490
  // web output to esm
529
491
  pkgModule
530
492
  ? esbuildWriteIfChanged(esmConfig, {
@@ -614,12 +576,12 @@ async function esbuildWriteIfChanged(
614
576
  // compat with jsx and hermes back a few versions generally:
615
577
  /** @type { import('esbuild').BuildOptions } */
616
578
  const nativeEsbuildSettings = {
617
- target: isESM ? 'esnext' : 'node16',
579
+ target: 'esnext',
618
580
  supported: {
619
581
  'logical-assignment': false,
620
582
  },
621
583
  jsx: 'automatic',
622
- platform: 'node',
584
+ platform: 'neutral',
623
585
  }
624
586
 
625
587
  /** @type { import('esbuild').BuildOptions } */
@@ -636,13 +598,17 @@ async function esbuildWriteIfChanged(
636
598
  },
637
599
  }
638
600
 
639
- return {
601
+ /** @type { import('esbuild').BuildOptions } */
602
+ const out = {
640
603
  ...opts,
641
604
 
605
+ conditions: platform === 'native' ? ['react-native'] : [],
606
+ mainFields: isESM ? ['import', 'module', 'main'] : ['require', 'main'],
607
+
642
608
  plugins: [
643
609
  ...(opts.plugins || []),
644
610
 
645
- ...(platform === 'native'
611
+ ...(platform === 'native' && !opts.bundle
646
612
  ? [
647
613
  // class isnt supported by hermes
648
614
  es5Plugin(),
@@ -650,6 +616,9 @@ async function esbuildWriteIfChanged(
650
616
  : []),
651
617
  ].filter(Boolean),
652
618
 
619
+
620
+ format: isESM ? 'esm' : 'cjs',
621
+
653
622
  treeShaking: true,
654
623
  minifySyntax: true,
655
624
  write: false,
@@ -669,9 +638,14 @@ async function esbuildWriteIfChanged(
669
638
  ...(env && {
670
639
  'process.env.NODE_ENV': `"${env}"`,
671
640
  }),
641
+ ...(shouldBundleNodeModules && {
642
+ 'process.env.ESBUILD_BINARY_PATH': `"true"`,
643
+ }),
672
644
  ...opts.define,
673
645
  },
674
646
  }
647
+
648
+ return out
675
649
  })()
676
650
 
677
651
  let built
@@ -832,7 +806,12 @@ async function esbuildWriteIfChanged(
832
806
  configFile: false,
833
807
  sourceMap: true,
834
808
  plugins: [
835
- require.resolve('@tamagui/babel-plugin-fully-specified/commonjs'),
809
+ [
810
+ require.resolve('@tamagui/babel-plugin-fully-specified/commonjs'),
811
+ {
812
+ esExtensionDefault: platform === 'native' ? '.native.cjs' : '.cjs',
813
+ },
814
+ ],
836
815
  ].filter(Boolean),
837
816
  })
838
817
 
@@ -844,7 +823,8 @@ async function esbuildWriteIfChanged(
844
823
  return
845
824
  }
846
825
 
847
- if (shouldSkipMJS || !isESM) {
826
+ // Skip mjs transformation if --skip-mjs flag is set
827
+ if (shouldSkipMJS) {
848
828
  return
849
829
  }
850
830
 
@@ -857,19 +837,21 @@ async function esbuildWriteIfChanged(
857
837
  if (!path.endsWith('.js')) return
858
838
 
859
839
  // for web do mjs, for native keep js since rollup gets confused when you have both
860
- const mjsOutPath = platform === 'native' ? path : path.replace('.js', '.mjs')
840
+ const newOutPath = platform === 'native' ? path : path.replace('.js', '.mjs')
861
841
 
862
842
  // if bundling no need to specify as its all internal
863
843
  // and babel is bad on huge bundled files
864
844
  const result = opts.bundle
865
845
  ? { code: contents }
866
846
  : transform(contents, {
867
- filename: mjsOutPath,
847
+ filename: newOutPath,
868
848
  configFile: false,
869
849
  sourceMap: true,
870
850
  plugins: [
871
851
  [
872
- require.resolve('@tamagui/babel-plugin-fully-specified'),
852
+ isESM
853
+ ? require.resolve('@tamagui/babel-plugin-fully-specified')
854
+ : require.resolve('@tamagui/babel-plugin-fully-specified/commonjs'),
873
855
  {
874
856
  esExtensionDefault: platform === 'native' ? '.native.js' : '.mjs',
875
857
  esExtensions: platform === 'native' ? ['.js'] : ['.mjs'],
@@ -886,13 +868,13 @@ async function esbuildWriteIfChanged(
886
868
  // output to mjs fully specified
887
869
  if (
888
870
  await flush(
889
- mjsOutPath,
871
+ newOutPath,
890
872
  result.code +
891
- (result.map ? `\n//# sourceMappingURL=${basename(mjsOutPath)}.map\n` : '')
873
+ (result.map ? `\n//# sourceMappingURL=${basename(newOutPath)}.map\n` : '')
892
874
  )
893
875
  ) {
894
876
  if (result.map) {
895
- await FSE.writeFile(mjsOutPath + '.map', JSON.stringify(result.map), 'utf8')
877
+ await FSE.writeFile(newOutPath + '.map', JSON.stringify(result.map), 'utf8')
896
878
  }
897
879
  }
898
880
  })