@tamagui/vite-plugin-cjs 2.0.0-1768586279389 → 2.0.0-1768636514428

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,141 +1,184 @@
1
- import * as Static from "@tamagui/static-worker";
2
- import { fileURLToPath } from "url";
3
- import { transformWithEsbuild } from "vite";
4
- import { tamaguiExtractPlugin } from "./extract.native.js";
5
- import { loadTamaguiBuildConfig, tamaguiOptions } from "./loadTamagui.native.js";
6
- var resolve = function (name) {
7
- return fileURLToPath(import.meta.resolve(name));
8
- };
1
+ import * as Static from '@tamagui/static-worker'
2
+ import { fileURLToPath } from 'url'
3
+ import { transformWithEsbuild } from 'vite'
4
+ import { tamaguiExtractPlugin } from './extract.native.js'
5
+ import { loadTamaguiBuildConfig, tamaguiOptions } from './loadTamagui.native.js'
6
+ var resolve = (name) => fileURLToPath(import.meta.resolve(name))
9
7
  function tamaguiPlugin() {
10
- var {
11
- optimize,
12
- disableResolveConfig,
13
- ...tamaguiOptionsIn
14
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {},
8
+ var { optimize, disableResolveConfig, ...tamaguiOptionsIn } =
9
+ arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {},
15
10
  shouldAddCompiler = !!optimize,
16
11
  watcher,
17
12
  loaded = !1,
18
13
  enableNativeEnv = !!globalThis.__vxrnEnableNativeEnv,
19
- extensions = [".web.mjs", ".web.js", ".web.jsx", ".web.ts", ".web.tsx", ".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
14
+ extensions = [
15
+ '.web.mjs',
16
+ '.web.js',
17
+ '.web.jsx',
18
+ '.web.ts',
19
+ '.web.tsx',
20
+ '.mjs',
21
+ '.js',
22
+ '.mts',
23
+ '.ts',
24
+ '.jsx',
25
+ '.tsx',
26
+ '.json',
27
+ ]
20
28
  async function load() {
21
- if (!loaded && (loaded = !0, await loadTamaguiBuildConfig(tamaguiOptionsIn), !tamaguiOptions.disableWatchTamaguiConfig)) {
22
- if (!Static) throw new Error("Not loaded");
29
+ if (
30
+ !loaded &&
31
+ ((loaded = !0),
32
+ await loadTamaguiBuildConfig(tamaguiOptionsIn),
33
+ !tamaguiOptions.disableWatchTamaguiConfig)
34
+ ) {
35
+ if (!Static) throw new Error('Not loaded')
23
36
  watcher = Static.watchTamaguiConfig({
24
- components: ["tamagui"],
25
- config: "./src/tamagui.config.ts",
26
- ...tamaguiOptions
27
- }).catch(function (err) {
28
- console.error(` [Tamagui] Error watching config: ${err}`);
29
- });
37
+ components: ['tamagui'],
38
+ config: './src/tamagui.config.ts',
39
+ ...tamaguiOptions,
40
+ }).catch((err) => {
41
+ console.error(` [Tamagui] Error watching config: ${err}`)
42
+ })
30
43
  }
31
44
  }
32
- var compatPlugins = [{
33
- name: "tamagui-base-web-only",
34
- enforce: "pre",
35
- async buildEnd() {
36
- await watcher?.then(function (res) {
37
- res?.dispose();
38
- });
39
- },
40
- async transform(code, id) {
41
- if (id.includes("expo-linear-gradient")) return transformWithEsbuild(code, id, {
42
- loader: "jsx",
43
- jsx: "automatic"
44
- });
45
- },
46
- // 👈
47
- async config(_, env) {
48
- if (await load(), !tamaguiOptions) throw new Error("No options loaded");
49
- return {
50
- environments: {
51
- client: {
52
- define: {
53
- "process.env.TAMAGUI_IS_CLIENT": JSON.stringify(!0),
54
- "process.env.TAMAGUI_ENVIRONMENT": '"client"'
55
- }
56
- }
57
- },
58
- define: {
59
- // reanimated support
60
- _frameTimestamp: void 0,
61
- _WORKLET: !1,
62
- __DEV__: `${env.mode === "development"}`,
63
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || env.mode),
64
- "process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
65
- "process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
66
- "process.env.IS_STATIC": JSON.stringify(!1),
67
- ...(env.mode === "production" && {
68
- "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(!0)
45
+ var compatPlugins = [
46
+ {
47
+ name: 'tamagui-base-web-only',
48
+ enforce: 'pre',
49
+ async buildEnd() {
50
+ await watcher?.then((res) => {
51
+ res?.dispose()
52
+ })
53
+ },
54
+ async transform(code, id) {
55
+ if (id.includes('expo-linear-gradient'))
56
+ return transformWithEsbuild(code, id, {
57
+ loader: 'jsx',
58
+ jsx: 'automatic',
69
59
  })
70
- },
71
- resolve: disableResolveConfig || enableNativeEnv ? {} : {
72
- extensions,
73
- alias: {
74
- ...(tamaguiOptions.platform !== "native" && {
75
- "react-native/Libraries/Renderer/shims/ReactFabric": resolve("@tamagui/proxy-worm"),
76
- "react-native/Libraries/Utilities/codegenNativeComponent": resolve("@tamagui/proxy-worm"),
77
- "react-native-svg": resolve("@tamagui/react-native-svg"),
78
- ...(!(!(tamaguiOptions === null || tamaguiOptions === void 0) && tamaguiOptions.useReactNativeWebLite) && {
79
- "react-native": resolve("react-native-web")
80
- })
81
- })
82
- }
83
- }
84
- };
85
- }
86
- }, {
87
- name: "tamagui-rnw-lite-web-only",
88
- // enforce: 'pre',
89
- // resolveId(source) {
90
- // const envName = this['environment']?.name as any // vite 5 + 6 compat
91
- // if (isVite6 && envName !== 'client' && envName !== 'ssr') {
92
- // return
93
- // }
94
- // if (source === 'react-native-svg') {
95
- // return '@tamagui/react-native-svg'
96
- // }
97
- // console.log('cmon', source)
98
- // if (tamaguiOptions?.useReactNativeWebLite) {
99
- // if (/^react-native$/.test(source)) {
100
- // return 'react-native-web'
101
- // }
102
- // } else {
103
- // if (/^react-native$/.test(source)) {
104
- // return '@tamagui/react-native-web-lite'
105
- // }
106
- // }
107
- // },
108
- config() {
109
- if (enableNativeEnv) return {};
110
- if (!(tamaguiOptions === null || tamaguiOptions === void 0) && tamaguiOptions.useReactNativeWebLite) {
111
- var rnwl = resolve((tamaguiOptions === null || tamaguiOptions === void 0 ? void 0 : tamaguiOptions.useReactNativeWebLite) === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite"),
112
- rnwlSS = resolve("@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle");
60
+ },
61
+ // 👈
62
+ async config(_, env) {
63
+ if ((await load(), !tamaguiOptions)) throw new Error('No options loaded')
113
64
  return {
114
- resolve: {
115
- alias: [
116
- // fix reanimated issue not finding this
117
- {
118
- find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
119
- replacement: rnwlSS
120
- }, {
121
- find: /^react-native$/,
122
- replacement: rnwl
123
- }, {
124
- find: /^react-native\/(.+)$/,
125
- replacement: `${rnwl}/$1`
126
- }, {
127
- find: /^react-native-web$/,
128
- replacement: rnwl
129
- }, {
130
- find: /^react-native-web\/(.+)$/,
131
- replacement: `${rnwl}/$1`
132
- }]
65
+ environments: {
66
+ client: {
67
+ define: {
68
+ 'process.env.TAMAGUI_IS_CLIENT': JSON.stringify(!0),
69
+ 'process.env.TAMAGUI_ENVIRONMENT': '"client"',
70
+ },
71
+ },
72
+ },
73
+ define: {
74
+ // reanimated support
75
+ _frameTimestamp: void 0,
76
+ _WORKLET: !1,
77
+ __DEV__: `${env.mode === 'development'}`,
78
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || env.mode),
79
+ 'process.env.ENABLE_RSC': JSON.stringify(process.env.ENABLE_RSC || ''),
80
+ 'process.env.ENABLE_STEPS': JSON.stringify(process.env.ENABLE_STEPS || ''),
81
+ 'process.env.IS_STATIC': JSON.stringify(!1),
82
+ ...(env.mode === 'production' && {
83
+ 'process.env.TAMAGUI_OPTIMIZE_THEMES': JSON.stringify(!0),
84
+ }),
85
+ },
86
+ resolve:
87
+ disableResolveConfig || enableNativeEnv
88
+ ? {}
89
+ : {
90
+ extensions,
91
+ alias: {
92
+ ...(tamaguiOptions.platform !== 'native' && {
93
+ 'react-native/Libraries/Renderer/shims/ReactFabric':
94
+ resolve('@tamagui/proxy-worm'),
95
+ 'react-native/Libraries/Utilities/codegenNativeComponent':
96
+ resolve('@tamagui/proxy-worm'),
97
+ 'react-native-svg': resolve('@tamagui/react-native-svg'),
98
+ ...(!(
99
+ !(tamaguiOptions === null || tamaguiOptions === void 0) &&
100
+ tamaguiOptions.useReactNativeWebLite
101
+ ) && {
102
+ 'react-native': resolve('react-native-web'),
103
+ }),
104
+ }),
105
+ },
106
+ },
107
+ }
108
+ },
109
+ },
110
+ {
111
+ name: 'tamagui-rnw-lite-web-only',
112
+ // enforce: 'pre',
113
+ // resolveId(source) {
114
+ // const envName = this['environment']?.name as any // vite 5 + 6 compat
115
+ // if (isVite6 && envName !== 'client' && envName !== 'ssr') {
116
+ // return
117
+ // }
118
+ // if (source === 'react-native-svg') {
119
+ // return '@tamagui/react-native-svg'
120
+ // }
121
+ // console.log('cmon', source)
122
+ // if (tamaguiOptions?.useReactNativeWebLite) {
123
+ // if (/^react-native$/.test(source)) {
124
+ // return 'react-native-web'
125
+ // }
126
+ // } else {
127
+ // if (/^react-native$/.test(source)) {
128
+ // return '@tamagui/react-native-web-lite'
129
+ // }
130
+ // }
131
+ // },
132
+ config() {
133
+ if (enableNativeEnv) return {}
134
+ if (
135
+ !(tamaguiOptions === null || tamaguiOptions === void 0) &&
136
+ tamaguiOptions.useReactNativeWebLite
137
+ ) {
138
+ var rnwl = resolve(
139
+ (tamaguiOptions === null || tamaguiOptions === void 0
140
+ ? void 0
141
+ : tamaguiOptions.useReactNativeWebLite) === 'without-animated'
142
+ ? '@tamagui/react-native-web-lite/without-animated'
143
+ : '@tamagui/react-native-web-lite'
144
+ ),
145
+ rnwlSS = resolve(
146
+ '@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle'
147
+ )
148
+ return {
149
+ resolve: {
150
+ alias: [
151
+ // fix reanimated issue not finding this
152
+ {
153
+ find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
154
+ replacement: rnwlSS,
155
+ },
156
+ {
157
+ find: /^react-native$/,
158
+ replacement: rnwl,
159
+ },
160
+ {
161
+ find: /^react-native\/(.+)$/,
162
+ replacement: `${rnwl}/$1`,
163
+ },
164
+ {
165
+ find: /^react-native-web$/,
166
+ replacement: rnwl,
167
+ },
168
+ {
169
+ find: /^react-native-web\/(.+)$/,
170
+ replacement: `${rnwl}/$1`,
171
+ },
172
+ ],
173
+ },
133
174
  }
134
- };
135
- }
136
- }
137
- }];
138
- return shouldAddCompiler ? [...compatPlugins, tamaguiExtractPlugin(tamaguiOptionsIn)] : [...compatPlugins];
175
+ }
176
+ },
177
+ },
178
+ ]
179
+ return shouldAddCompiler
180
+ ? [...compatPlugins, tamaguiExtractPlugin(tamaguiOptionsIn)]
181
+ : [...compatPlugins]
139
182
  }
140
- export { tamaguiPlugin };
183
+ export { tamaguiPlugin }
141
184
  //# sourceMappingURL=plugin.native.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/vite-plugin-cjs",
3
- "version": "2.0.0-1768586279389",
3
+ "version": "2.0.0-1768636514428",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "./index.js",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "build": "cp -r ../vite-plugin/dist . || true"
9
9
  },
10
10
  "dependencies": {
11
- "@tamagui/vite-plugin": "2.0.0-1768586279389"
11
+ "@tamagui/vite-plugin": "2.0.0-1768636514428"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"