@tamagui/build 1.143.1 → 2.0.0-1767740890268

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/README.md +14 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
  A small, opinionated build script for libraries that target both React Native and React web.
4
4
 
5
- Path-specific extensions are the only way to support ESM. Bundlers used to be flexible and configure this for you, but to conform to spec your import must specify the full file path now, and not leave out the extension. This is trouble for React Native which has platform file extensions.
5
+ Path-specific extensions are the only way to support both ESM and CJS properly in modern Node and across all bundlers. Some bundlers used to be flexible and configure this for you, but we found this was the only way to achieve "no config" packages that target native and web. This is even more true as React Native is now supporting package.json exports with an experimental flag.
6
6
 
7
- We wanted to build packages so we didn't have to deal with all this fuss. What it does, is builds out `.native` and `.web` versions of every file. It then does some transforms to each to support a wide variety of setups - Metro, Vite, modern Node, etc.
7
+ We wanted to build packages so we didn't have to deal with all this fuss. `@tamagui/build` will build every input file out to both `.native` and `.web` output files to make this work. It then adds path-specific imports to the files that are reachable via package.json exports, but leaves plain `.js` files for older bundlers that don't support it (Metro without the experimental exports flag). It also does a few small re-writes to ensure everyting works without needing bundler configuration. This means it supports basically every possible setup - Metro in either mode, Vite, and older and newer Node versions.
8
8
 
9
- The one limitation for now is it doesn't support .ios and .android platform-specifics at least for platform-specific imports. It does output non-specific versions for Metro/older node, so it'll work there.
10
-
11
- It has a few features that make it useful for "universal" libraries:
9
+ Some details on how it works:
12
10
 
13
11
  - uses tsc to output declaration files to `./types`
14
12
  - esbuild to output `dist/esm` and `dist/cjs` for ESModules and CommonJS
15
13
  - outputs `.js` and `.mjs` files in `dist/esm`
16
14
  - in `.mjs`, adds path-specific imports to non-specific imports
15
+ - outputs both `.js` and `.cjs` files in `dist/cjs`:
16
+ - in `.cjs`, adds path-specific imports to non-specific imports
17
17
  - removes hanging imports that esbuild leaves (see `pkgRemoveSideEffects`)
18
18
  - outputs `.native.js` and regular `.js` files for all output files, so React Native always loads separate files from web. In the `native` specific files,
19
19
  - swc is sued to transform to es5
20
20
  - `process.env.TAMAGUI_TARGET` is defined `native` (otherwise `web`)
21
21
  - on non-native files:
22
- - imports of `react-native` are transformed to `react-native-web`
22
+ - on web, imports of `react-native` are transformed to `react-native-web`
23
23
 
24
24
  It assumes your package.json looks something like this:
25
25
 
@@ -29,6 +29,7 @@ It assumes your package.json looks something like this:
29
29
  "types": "./types/index.d.ts",
30
30
  "main": "dist/cjs",
31
31
  "module": "dist/esm",
32
+ "type": "module",
32
33
  "removeSideEffects": "true",
33
34
  "scripts": {
34
35
  "build": "tamagui-build",
@@ -38,11 +39,14 @@ It assumes your package.json looks something like this:
38
39
  "exports": {
39
40
  "./package.json": "./package.json",
40
41
  ".": {
41
- "react-native-import": "./dist/esm/index.native.js",
42
- "react-native": "./dist/cjs/index.native.js",
42
+ "react-native": {
43
+ "import": "./dist/esm/index.native.js",
44
+ "require": "./dist/cjs/index.native.js"
45
+ },
43
46
  "types": "./types/index.d.ts",
44
47
  "import": "./dist/esm/index.mjs",
45
- "require": "./dist/cjs/index.js"
48
+ "require": "./dist/cjs/index.cjs",
49
+ "default": "./dist/cjs/index.native.js"
46
50
  }
47
51
  },
48
52
  "devDependencies": {
@@ -70,6 +74,7 @@ It assumes your package.json looks something like this:
70
74
  - `--declaration-root` - sets tsc flag `--declarationDir ./`
71
75
  - `--ignore-base-url` - if not set, tsc is passed `--baseUrl .`
72
76
  - `--skip-mjs` - don't output mjs files
77
+ - `--skip-native` - don't output native files
73
78
  - `tamagui-build --watch` - watches for changes and does the above
74
79
  - `tamagui-build clean` - cleans dist, types, node_modules folders
75
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.143.1",
3
+ "version": "2.0.0-1767740890268",
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.14.0",
17
- "@tamagui/babel-plugin-fully-specified": "1.143.1",
17
+ "@tamagui/babel-plugin-fully-specified": "2.0.0-1767740890268",
18
18
  "@types/fs-extra": "^9.0.13",
19
19
  "chokidar": "^3.5.2",
20
20
  "esbuild": "^0.25.11",