@tamagui/build 1.111.8 → 1.111.9

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/README.md CHANGED
@@ -32,7 +32,7 @@ It assumes your package.json looks something like this:
32
32
  "exports": {
33
33
  "./package.json": "./package.json",
34
34
  ".": {
35
- "react-native-import": "./dist/esm/index.native.mjs",
35
+ "react-native-import": "./dist/esm/index.native.js",
36
36
  "react-native": "./dist/cjs/index.native.js",
37
37
  "types": "./types/index.d.ts",
38
38
  "import": "./dist/esm/index.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamagui-build-test-simple-tpackage",
3
- "version": "1.111.8",
3
+ "version": "1.111.9",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "types": "dist/types/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "build:target-native": "TAMAGUI_TARGET=native node ../../../tamagui-build.js"
17
17
  },
18
18
  "devDependencies": {
19
- "@tamagui/build": "1.111.8",
19
+ "@tamagui/build": "1.111.9",
20
20
  "typescript": "^5.5.2"
21
21
  }
22
22
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamagui-build-test-watch-package",
3
- "version": "1.111.8",
3
+ "version": "1.111.9",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "types": "dist/types/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "build:target-native": "TAMAGUI_TARGET=native node ../../../tamagui-build.js"
17
17
  },
18
18
  "devDependencies": {
19
- "@tamagui/build": "1.111.8",
19
+ "@tamagui/build": "1.111.9",
20
20
  "typescript": "^5.5.2"
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.111.8",
3
+ "version": "1.111.9",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@babel/core": "^7.25.2",
16
16
  "@swc/core": "^1.7.21",
17
- "@tamagui/babel-plugin-fully-specified": "1.111.8",
17
+ "@tamagui/babel-plugin-fully-specified": "1.111.9",
18
18
  "@types/fs-extra": "^9.0.13",
19
19
  "babel-plugin-fully-specified": "*",
20
20
  "chokidar": "^3.5.2",
package/tamagui-build.js CHANGED
@@ -353,6 +353,7 @@ async function buildJs() {
353
353
  }
354
354
 
355
355
  const esmConfig = {
356
+ target: 'esnext',
356
357
  format: 'esm',
357
358
  entryPoints: files,
358
359
  outdir: flatOut ? 'dist' : 'dist/esm',
@@ -421,7 +422,6 @@ async function buildJs() {
421
422
  pkgModule
422
423
  ? esbuildWriteIfChanged(esmConfig, {
423
424
  platform: 'web',
424
- mjs: true,
425
425
  })
426
426
  : null,
427
427
 
@@ -429,7 +429,6 @@ async function buildJs() {
429
429
  pkgModule
430
430
  ? esbuildWriteIfChanged(esmConfig, {
431
431
  platform: 'native',
432
- mjs: true,
433
432
  })
434
433
  : null,
435
434
 
@@ -450,7 +449,6 @@ async function buildJs() {
450
449
  },
451
450
  {
452
451
  platform: 'web',
453
- mjs: true,
454
452
  }
455
453
  )
456
454
  : null,
@@ -488,8 +486,7 @@ async function buildJs() {
488
486
  async function esbuildWriteIfChanged(
489
487
  /** @type { import('esbuild').BuildOptions } */
490
488
  opts,
491
- { platform, env, mjs } = {
492
- mjs: false,
489
+ { platform, env } = {
493
490
  platform: '',
494
491
  env: '',
495
492
  }
@@ -498,85 +495,73 @@ async function esbuildWriteIfChanged(
498
495
  return await esbuild.build(opts)
499
496
  }
500
497
 
501
- // compat with jsx and hermes back a few versions generally:
502
- /** @type { import('esbuild').BuildOptions } */
503
- const nativeEsbuildSettings = {
504
- target: mjs ? 'esnext' : 'node16',
505
- supported: {
506
- 'logical-assignment': false,
507
- },
508
- jsx: 'automatic',
509
- platform: 'node',
510
- }
498
+ const isESM = opts.target === 'esm' || opts.target === 'esnext'
511
499
 
512
- /** @type { import('esbuild').BuildOptions } */
513
- const webEsbuildSettings = {
514
- target: 'esnext',
515
- jsx: 'automatic',
516
- platform: shouldBundle ? 'node' : 'neutral',
517
- tsconfigRaw: {
518
- compilerOptions: {
519
- paths: {
520
- 'react-native': ['react-native-web'],
500
+ const buildSettings = (() => {
501
+ // compat with jsx and hermes back a few versions generally:
502
+ /** @type { import('esbuild').BuildOptions } */
503
+ const nativeEsbuildSettings = {
504
+ target: isESM ? 'esnext' : 'node16',
505
+ supported: {
506
+ 'logical-assignment': false,
507
+ },
508
+ jsx: 'automatic',
509
+ platform: 'node',
510
+ }
511
+
512
+ /** @type { import('esbuild').BuildOptions } */
513
+ const webEsbuildSettings = {
514
+ target: 'esnext',
515
+ jsx: 'automatic',
516
+ platform: shouldBundle ? 'node' : 'neutral',
517
+ tsconfigRaw: {
518
+ compilerOptions: {
519
+ paths: {
520
+ 'react-native': ['react-native-web'],
521
+ },
521
522
  },
522
523
  },
523
- },
524
- }
524
+ }
525
525
 
526
- const buildSettings = {
527
- ...opts,
528
-
529
- plugins: [
530
- ...(opts.plugins || []),
531
-
532
- ...(platform === 'native'
533
- ? [
534
- // class isnt supported by hermes
535
- es5Plugin(),
536
- ]
537
- : []),
538
-
539
- // not workin
540
- // {
541
- // name: 'no-side-effects',
542
- // setup(build) {
543
- // build.onResolve({ filter: /@tamagui.*/ }, async ({ path, ...options }) => {
544
- // const result = await build.resolve(path, {
545
- // ...options,
546
- // namespace: 'noRecurse',
547
- // })
548
- // console.log('no side effects', path)
549
- // return { ...result, sideEffects: false }
550
- // })
551
- // },
552
- // },
553
- ].filter(Boolean),
554
-
555
- treeShaking: true,
556
- minifySyntax: true,
557
- write: false,
558
-
559
- color: true,
560
- allowOverwrite: true,
561
- keepNames: false,
562
- sourcemap: true,
563
- sourcesContent: false,
564
- logLevel: 'error',
565
- ...(platform === 'native' && nativeEsbuildSettings),
566
- ...(platform === 'web' && webEsbuildSettings),
567
- define: {
568
- ...(platform && {
569
- 'process.env.TAMAGUI_TARGET': `"${platform}"`,
570
- }),
571
- ...(env && {
572
- 'process.env.NODE_ENV': `"${env}"`,
573
- }),
574
- ...opts.define,
575
- },
576
- }
526
+ return {
527
+ ...opts,
528
+
529
+ plugins: [
530
+ ...(opts.plugins || []),
531
+
532
+ ...(platform === 'native'
533
+ ? [
534
+ // class isnt supported by hermes
535
+ es5Plugin(),
536
+ ]
537
+ : []),
538
+ ].filter(Boolean),
539
+
540
+ treeShaking: true,
541
+ minifySyntax: true,
542
+ write: false,
543
+
544
+ color: true,
545
+ allowOverwrite: true,
546
+ keepNames: false,
547
+ sourcemap: true,
548
+ sourcesContent: false,
549
+ logLevel: 'error',
550
+ ...(platform === 'native' && nativeEsbuildSettings),
551
+ ...(platform === 'web' && webEsbuildSettings),
552
+ define: {
553
+ ...(platform && {
554
+ 'process.env.TAMAGUI_TARGET': `"${platform}"`,
555
+ }),
556
+ ...(env && {
557
+ 'process.env.NODE_ENV': `"${env}"`,
558
+ }),
559
+ ...opts.define,
560
+ },
561
+ }
562
+ })()
577
563
 
578
564
  const built = await esbuild.build(buildSettings)
579
- const isESM = buildSettings.target === 'esm' || buildSettings.target === 'esnext'
580
565
 
581
566
  if (!built.outputFiles) {
582
567
  return
@@ -613,7 +598,9 @@ async function esbuildWriteIfChanged(
613
598
  built.outputFiles.map(async (file) => {
614
599
  let path = file.path
615
600
 
616
- if (path.endsWith('.js') || path.endsWith('.js.map')) {
601
+ const isMap = path.endsWith('.js.map')
602
+
603
+ if (path.endsWith('.js') || isMap) {
617
604
  const [_, extPlatform] =
618
605
  path.match(/(web|native|ios|android)\.js(\.map)?$/) ?? []
619
606
 
@@ -673,6 +660,10 @@ async function esbuildWriteIfChanged(
673
660
 
674
661
  await flush(path, contents)
675
662
 
663
+ if (isMap) {
664
+ return
665
+ }
666
+
676
667
  return {
677
668
  path,
678
669
  contents,
@@ -683,16 +674,18 @@ async function esbuildWriteIfChanged(
683
674
 
684
675
  // path specifics:
685
676
 
677
+ if (shouldSkipMJS || !isESM) {
678
+ return
679
+ }
680
+
686
681
  await Promise.all(
687
682
  outputs.map(async (file) => {
688
683
  if (!file) return
689
684
  const { path, contents } = file
690
685
 
691
- const shouldDoMJS = !shouldSkipMJS && isESM && mjs && path.endsWith('.js')
692
-
693
- if (!shouldDoMJS) return
686
+ // for web do mjs, for native keep js since rollup gets confused when you have both
687
+ const mjsOutPath = platform === 'native' ? path : path.replace('.js', '.mjs')
694
688
 
695
- const mjsOutPath = path.replace('.js', '.mjs')
696
689
  // if bundling no need to specify as its all internal
697
690
  // and babel is bad on huge bundled files
698
691
  const result = shouldBundle
@@ -705,12 +698,10 @@ async function esbuildWriteIfChanged(
705
698
  [
706
699
  require.resolve('@tamagui/babel-plugin-fully-specified'),
707
700
  {
708
- esExtensionDefault: platform === 'native' ? '.native.mjs' : '.mjs',
701
+ esExtensionDefault: platform === 'native' ? '.native.js' : '.mjs',
702
+ esExtensions: platform === 'native' ? ['.js'] : ['.mjs'],
709
703
  },
710
704
  ],
711
- // pkg.tamagui?.build?.skipEnvToMeta
712
- // ? null
713
- // : require.resolve('./babel-plugin-process-env-to-meta'),
714
705
  ].filter(Boolean),
715
706
  })
716
707