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

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,179 +1,244 @@
1
- "use strict";
2
-
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
1
+ var __create = Object.create
2
+ var __defProp = Object.defineProperty
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor
4
+ var __getOwnPropNames = Object.getOwnPropertyNames
7
5
  var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ __hasOwnProp = Object.prototype.hasOwnProperty
9
7
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: !0,
12
+ })
14
13
  },
15
14
  __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
- get: () => from[key],
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
34
- var plugin_exports = {};
15
+ if ((from && typeof from == 'object') || typeof from == 'function')
16
+ for (let key of __getOwnPropNames(from))
17
+ !__hasOwnProp.call(to, key) &&
18
+ key !== except &&
19
+ __defProp(to, key, {
20
+ get: () => from[key],
21
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
22
+ })
23
+ return to
24
+ }
25
+ var __toESM = (mod, isNodeMode, target) => (
26
+ (target = mod != null ? __create(__getProtoOf(mod)) : {}),
27
+ __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule
33
+ ? __defProp(target, 'default', {
34
+ value: mod,
35
+ enumerable: !0,
36
+ })
37
+ : target,
38
+ mod
39
+ )
40
+ ),
41
+ __toCommonJS = (mod) =>
42
+ __copyProps(
43
+ __defProp({}, '__esModule', {
44
+ value: !0,
45
+ }),
46
+ mod
47
+ )
48
+ var plugin_exports = {}
35
49
  __export(plugin_exports, {
36
- tamaguiPlugin: () => tamaguiPlugin
37
- });
38
- module.exports = __toCommonJS(plugin_exports);
39
- var Static = __toESM(require("@tamagui/static-worker"), 1),
40
- import_url = require("url"),
41
- import_vite = require("vite"),
42
- import_extract = require("./extract.native.js"),
43
- import_loadTamagui = require("./loadTamagui.native.js");
44
- const import_meta = {};
45
- var resolve = function (name) {
46
- return (0, import_url.fileURLToPath)(import_meta.resolve(name));
47
- };
50
+ tamaguiPlugin: () => tamaguiPlugin,
51
+ })
52
+ module.exports = __toCommonJS(plugin_exports)
53
+ var Static = __toESM(require('@tamagui/static-worker'), 1),
54
+ import_url = require('url'),
55
+ import_vite = require('vite'),
56
+ import_extract = require('./extract.native.js'),
57
+ import_loadTamagui = require('./loadTamagui.native.js')
58
+ const import_meta = {}
59
+ var resolve = (name) => (0, import_url.fileURLToPath)(import_meta.resolve(name))
48
60
  function tamaguiPlugin() {
49
- var {
50
- optimize,
51
- disableResolveConfig,
52
- ...tamaguiOptionsIn
53
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {},
61
+ var { optimize, disableResolveConfig, ...tamaguiOptionsIn } =
62
+ arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {},
54
63
  shouldAddCompiler = !!optimize,
55
64
  watcher,
56
65
  loaded = !1,
57
66
  enableNativeEnv = !!globalThis.__vxrnEnableNativeEnv,
58
- extensions = [".web.mjs", ".web.js", ".web.jsx", ".web.ts", ".web.tsx", ".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
67
+ extensions = [
68
+ '.web.mjs',
69
+ '.web.js',
70
+ '.web.jsx',
71
+ '.web.ts',
72
+ '.web.tsx',
73
+ '.mjs',
74
+ '.js',
75
+ '.mts',
76
+ '.ts',
77
+ '.jsx',
78
+ '.tsx',
79
+ '.json',
80
+ ]
59
81
  async function load() {
60
- if (!loaded && (loaded = !0, await (0, import_loadTamagui.loadTamaguiBuildConfig)(tamaguiOptionsIn), !import_loadTamagui.tamaguiOptions.disableWatchTamaguiConfig)) {
61
- if (!Static) throw new Error("Not loaded");
82
+ if (
83
+ !loaded &&
84
+ ((loaded = !0),
85
+ await (0, import_loadTamagui.loadTamaguiBuildConfig)(tamaguiOptionsIn),
86
+ !import_loadTamagui.tamaguiOptions.disableWatchTamaguiConfig)
87
+ ) {
88
+ if (!Static) throw new Error('Not loaded')
62
89
  watcher = Static.watchTamaguiConfig({
63
- components: ["tamagui"],
64
- config: "./src/tamagui.config.ts",
65
- ...import_loadTamagui.tamaguiOptions
66
- }).catch(function (err) {
67
- console.error(` [Tamagui] Error watching config: ${err}`);
68
- });
90
+ components: ['tamagui'],
91
+ config: './src/tamagui.config.ts',
92
+ ...import_loadTamagui.tamaguiOptions,
93
+ }).catch((err) => {
94
+ console.error(` [Tamagui] Error watching config: ${err}`)
95
+ })
69
96
  }
70
97
  }
71
- var compatPlugins = [{
72
- name: "tamagui-base-web-only",
73
- enforce: "pre",
74
- async buildEnd() {
75
- await watcher?.then(function (res) {
76
- res?.dispose();
77
- });
78
- },
79
- async transform(code, id) {
80
- if (id.includes("expo-linear-gradient")) return (0, import_vite.transformWithEsbuild)(code, id, {
81
- loader: "jsx",
82
- jsx: "automatic"
83
- });
84
- },
85
- // 👈
86
- async config(_, env) {
87
- if (await load(), !import_loadTamagui.tamaguiOptions) throw new Error("No options loaded");
88
- return {
89
- environments: {
90
- client: {
91
- define: {
92
- "process.env.TAMAGUI_IS_CLIENT": JSON.stringify(!0),
93
- "process.env.TAMAGUI_ENVIRONMENT": '"client"'
94
- }
95
- }
96
- },
97
- define: {
98
- // reanimated support
99
- _frameTimestamp: void 0,
100
- _WORKLET: !1,
101
- __DEV__: `${env.mode === "development"}`,
102
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || env.mode),
103
- "process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
104
- "process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
105
- "process.env.IS_STATIC": JSON.stringify(!1),
106
- ...(env.mode === "production" && {
107
- "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(!0)
98
+ var compatPlugins = [
99
+ {
100
+ name: 'tamagui-base-web-only',
101
+ enforce: 'pre',
102
+ async buildEnd() {
103
+ await watcher?.then((res) => {
104
+ res?.dispose()
105
+ })
106
+ },
107
+ async transform(code, id) {
108
+ if (id.includes('expo-linear-gradient'))
109
+ return (0, import_vite.transformWithEsbuild)(code, id, {
110
+ loader: 'jsx',
111
+ jsx: 'automatic',
108
112
  })
109
- },
110
- resolve: disableResolveConfig || enableNativeEnv ? {} : {
111
- extensions,
112
- alias: {
113
- ...(import_loadTamagui.tamaguiOptions.platform !== "native" && {
114
- "react-native/Libraries/Renderer/shims/ReactFabric": resolve("@tamagui/proxy-worm"),
115
- "react-native/Libraries/Utilities/codegenNativeComponent": resolve("@tamagui/proxy-worm"),
116
- "react-native-svg": resolve("@tamagui/react-native-svg"),
117
- ...(!(!(import_loadTamagui.tamaguiOptions === null || import_loadTamagui.tamaguiOptions === void 0) && import_loadTamagui.tamaguiOptions.useReactNativeWebLite) && {
118
- "react-native": resolve("react-native-web")
119
- })
120
- })
121
- }
122
- }
123
- };
124
- }
125
- }, {
126
- name: "tamagui-rnw-lite-web-only",
127
- // enforce: 'pre',
128
- // resolveId(source) {
129
- // const envName = this['environment']?.name as any // vite 5 + 6 compat
130
- // if (isVite6 && envName !== 'client' && envName !== 'ssr') {
131
- // return
132
- // }
133
- // if (source === 'react-native-svg') {
134
- // return '@tamagui/react-native-svg'
135
- // }
136
- // console.log('cmon', source)
137
- // if (tamaguiOptions?.useReactNativeWebLite) {
138
- // if (/^react-native$/.test(source)) {
139
- // return 'react-native-web'
140
- // }
141
- // } else {
142
- // if (/^react-native$/.test(source)) {
143
- // return '@tamagui/react-native-web-lite'
144
- // }
145
- // }
146
- // },
147
- config() {
148
- if (enableNativeEnv) return {};
149
- if (!(import_loadTamagui.tamaguiOptions === null || import_loadTamagui.tamaguiOptions === void 0) && import_loadTamagui.tamaguiOptions.useReactNativeWebLite) {
150
- var rnwl = resolve((import_loadTamagui.tamaguiOptions === null || import_loadTamagui.tamaguiOptions === void 0 ? void 0 : import_loadTamagui.tamaguiOptions.useReactNativeWebLite) === "without-animated" ? "@tamagui/react-native-web-lite/without-animated" : "@tamagui/react-native-web-lite"),
151
- rnwlSS = resolve("@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle");
113
+ },
114
+ // 👈
115
+ async config(_, env) {
116
+ if ((await load(), !import_loadTamagui.tamaguiOptions))
117
+ throw new Error('No options loaded')
152
118
  return {
153
- resolve: {
154
- alias: [
155
- // fix reanimated issue not finding this
156
- {
157
- find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
158
- replacement: rnwlSS
159
- }, {
160
- find: /^react-native$/,
161
- replacement: rnwl
162
- }, {
163
- find: /^react-native\/(.+)$/,
164
- replacement: `${rnwl}/$1`
165
- }, {
166
- find: /^react-native-web$/,
167
- replacement: rnwl
168
- }, {
169
- find: /^react-native-web\/(.+)$/,
170
- replacement: `${rnwl}/$1`
171
- }]
119
+ environments: {
120
+ client: {
121
+ define: {
122
+ 'process.env.TAMAGUI_IS_CLIENT': JSON.stringify(!0),
123
+ 'process.env.TAMAGUI_ENVIRONMENT': '"client"',
124
+ },
125
+ },
126
+ },
127
+ define: {
128
+ // reanimated support
129
+ _frameTimestamp: void 0,
130
+ _WORKLET: !1,
131
+ __DEV__: `${env.mode === 'development'}`,
132
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || env.mode),
133
+ 'process.env.ENABLE_RSC': JSON.stringify(process.env.ENABLE_RSC || ''),
134
+ 'process.env.ENABLE_STEPS': JSON.stringify(process.env.ENABLE_STEPS || ''),
135
+ 'process.env.IS_STATIC': JSON.stringify(!1),
136
+ ...(env.mode === 'production' && {
137
+ 'process.env.TAMAGUI_OPTIMIZE_THEMES': JSON.stringify(!0),
138
+ }),
139
+ },
140
+ resolve:
141
+ disableResolveConfig || enableNativeEnv
142
+ ? {}
143
+ : {
144
+ extensions,
145
+ alias: {
146
+ ...(import_loadTamagui.tamaguiOptions.platform !== 'native' && {
147
+ 'react-native/Libraries/Renderer/shims/ReactFabric':
148
+ resolve('@tamagui/proxy-worm'),
149
+ 'react-native/Libraries/Utilities/codegenNativeComponent':
150
+ resolve('@tamagui/proxy-worm'),
151
+ 'react-native-svg': resolve('@tamagui/react-native-svg'),
152
+ ...(!(
153
+ !(
154
+ import_loadTamagui.tamaguiOptions === null ||
155
+ import_loadTamagui.tamaguiOptions === void 0
156
+ ) && import_loadTamagui.tamaguiOptions.useReactNativeWebLite
157
+ ) && {
158
+ 'react-native': resolve('react-native-web'),
159
+ }),
160
+ }),
161
+ },
162
+ },
163
+ }
164
+ },
165
+ },
166
+ {
167
+ name: 'tamagui-rnw-lite-web-only',
168
+ // enforce: 'pre',
169
+ // resolveId(source) {
170
+ // const envName = this['environment']?.name as any // vite 5 + 6 compat
171
+ // if (isVite6 && envName !== 'client' && envName !== 'ssr') {
172
+ // return
173
+ // }
174
+ // if (source === 'react-native-svg') {
175
+ // return '@tamagui/react-native-svg'
176
+ // }
177
+ // console.log('cmon', source)
178
+ // if (tamaguiOptions?.useReactNativeWebLite) {
179
+ // if (/^react-native$/.test(source)) {
180
+ // return 'react-native-web'
181
+ // }
182
+ // } else {
183
+ // if (/^react-native$/.test(source)) {
184
+ // return '@tamagui/react-native-web-lite'
185
+ // }
186
+ // }
187
+ // },
188
+ config() {
189
+ if (enableNativeEnv) return {}
190
+ if (
191
+ !(
192
+ import_loadTamagui.tamaguiOptions === null ||
193
+ import_loadTamagui.tamaguiOptions === void 0
194
+ ) &&
195
+ import_loadTamagui.tamaguiOptions.useReactNativeWebLite
196
+ ) {
197
+ var rnwl = resolve(
198
+ (import_loadTamagui.tamaguiOptions === null ||
199
+ import_loadTamagui.tamaguiOptions === void 0
200
+ ? void 0
201
+ : import_loadTamagui.tamaguiOptions.useReactNativeWebLite) ===
202
+ 'without-animated'
203
+ ? '@tamagui/react-native-web-lite/without-animated'
204
+ : '@tamagui/react-native-web-lite'
205
+ ),
206
+ rnwlSS = resolve(
207
+ '@tamagui/react-native-web-lite/dist/exports/StyleSheet/compiler/createReactDOMStyle'
208
+ )
209
+ return {
210
+ resolve: {
211
+ alias: [
212
+ // fix reanimated issue not finding this
213
+ {
214
+ find: /react-native.*\/dist\/exports\/StyleSheet\/compiler\/createReactDOMStyle/,
215
+ replacement: rnwlSS,
216
+ },
217
+ {
218
+ find: /^react-native$/,
219
+ replacement: rnwl,
220
+ },
221
+ {
222
+ find: /^react-native\/(.+)$/,
223
+ replacement: `${rnwl}/$1`,
224
+ },
225
+ {
226
+ find: /^react-native-web$/,
227
+ replacement: rnwl,
228
+ },
229
+ {
230
+ find: /^react-native-web\/(.+)$/,
231
+ replacement: `${rnwl}/$1`,
232
+ },
233
+ ],
234
+ },
172
235
  }
173
- };
174
- }
175
- }
176
- }];
177
- return shouldAddCompiler ? [...compatPlugins, (0, import_extract.tamaguiExtractPlugin)(tamaguiOptionsIn)] : [...compatPlugins];
236
+ }
237
+ },
238
+ },
239
+ ]
240
+ return shouldAddCompiler
241
+ ? [...compatPlugins, (0, import_extract.tamaguiExtractPlugin)(tamaguiOptionsIn)]
242
+ : [...compatPlugins]
178
243
  }
179
244
  //# sourceMappingURL=plugin.native.js.map
@@ -1,3 +1,14 @@
1
- var extensions = [".ios.js", ".native.js", ".native.ts", ".native.tsx", ".js", ".jsx", ".json", ".ts", ".tsx", ".mjs"];
2
- export { extensions };
1
+ var extensions = [
2
+ '.ios.js',
3
+ '.native.js',
4
+ '.native.ts',
5
+ '.native.tsx',
6
+ '.js',
7
+ '.jsx',
8
+ '.json',
9
+ '.ts',
10
+ '.tsx',
11
+ '.mjs',
12
+ ]
13
+ export { extensions }
3
14
  //# sourceMappingURL=extensions.native.js.map