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