@tamagui/build 1.75.4 → 1.75.6

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 +21 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.75.4",
3
+ "version": "1.75.6",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js"
6
6
  },
package/tamagui-build.js CHANGED
@@ -45,6 +45,17 @@ const pkgTypes = Boolean(pkg['types'] || pkg['typings'])
45
45
 
46
46
  const flatOut = [pkgMain, pkgModule, pkgModuleJSX].filter(Boolean).length === 1
47
47
 
48
+ const replaceRNWeb = {
49
+ esm: {
50
+ from: 'from "react-native"',
51
+ to: 'from "react-native-web"'
52
+ },
53
+ cjs: {
54
+ from: 'require("react-native")',
55
+ to: 'require("react-native-web")'
56
+ }
57
+ }
58
+
48
59
  async function clean() {
49
60
  try {
50
61
  await Promise.allSettled([
@@ -385,7 +396,7 @@ async function esbuildWriteIfChanged(
385
396
  if (!shouldWatch && !platform) {
386
397
  return await esbuild.build(opts)
387
398
  }
388
-
399
+
389
400
  const built = await esbuild.build({
390
401
  ...opts,
391
402
 
@@ -406,7 +417,7 @@ async function esbuildWriteIfChanged(
406
417
  // })
407
418
  // },
408
419
  // },
409
- ],
420
+ ].filter(Boolean),
410
421
 
411
422
  treeShaking: true,
412
423
  minifySyntax: true,
@@ -489,7 +500,14 @@ async function esbuildWriteIfChanged(
489
500
  const outDir = dirname(outPath)
490
501
 
491
502
  await fs.ensureDir(outDir)
492
- const outString = new TextDecoder().decode(file.contents)
503
+ let outString = new TextDecoder().decode(file.contents)
504
+
505
+ if (platform === 'web') {
506
+ const rnWebReplacer = replaceRNWeb[opts.format]
507
+ if (rnWebReplacer) {
508
+ outString = outString.replaceAll(rnWebReplacer.from, rnWebReplacer.to)
509
+ }
510
+ }
493
511
 
494
512
  if (shouldWatch) {
495
513
  if (