@tamagui/vite-plugin-cjs 2.0.0-rc.8 → 2.0.0

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 (56) hide show
  1. package/dist/cjs/extensions.cjs +12 -10
  2. package/dist/cjs/index.cjs +7 -5
  3. package/dist/cjs/index.js +11 -8
  4. package/dist/cjs/loadTamagui.cjs +58 -39
  5. package/dist/cjs/plugin.cjs +280 -123
  6. package/dist/esm/index.js +1 -1
  7. package/dist/esm/index.js.map +1 -6
  8. package/dist/esm/loadTamagui.mjs +34 -17
  9. package/dist/esm/loadTamagui.mjs.map +1 -1
  10. package/dist/esm/plugin.mjs +249 -94
  11. package/dist/esm/plugin.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/dist/cjs/cache.cjs +0 -70
  14. package/dist/cjs/cache.js +0 -63
  15. package/dist/cjs/cache.js.map +0 -6
  16. package/dist/cjs/extensions.mjs +0 -47
  17. package/dist/cjs/extensions.mjs.map +0 -1
  18. package/dist/cjs/extensions.native.js +0 -47
  19. package/dist/cjs/extensions.native.js.map +0 -1
  20. package/dist/cjs/extract.cjs +0 -160
  21. package/dist/cjs/extract.js +0 -148
  22. package/dist/cjs/extract.js.map +0 -6
  23. package/dist/cjs/extract.mjs +0 -226
  24. package/dist/cjs/extract.mjs.map +0 -1
  25. package/dist/cjs/extract.native.js +0 -274
  26. package/dist/cjs/extract.native.js.map +0 -1
  27. package/dist/cjs/index.mjs +0 -31
  28. package/dist/cjs/index.mjs.map +0 -1
  29. package/dist/cjs/index.native.js +0 -31
  30. package/dist/cjs/index.native.js.map +0 -1
  31. package/dist/cjs/loadTamagui.mjs +0 -89
  32. package/dist/cjs/loadTamagui.mjs.map +0 -1
  33. package/dist/cjs/loadTamagui.native.js +0 -90
  34. package/dist/cjs/loadTamagui.native.js.map +0 -1
  35. package/dist/cjs/plugin.mjs +0 -228
  36. package/dist/cjs/plugin.mjs.map +0 -1
  37. package/dist/cjs/plugin.native.js +0 -244
  38. package/dist/cjs/plugin.native.js.map +0 -1
  39. package/dist/esm/cache.js +0 -47
  40. package/dist/esm/cache.js.map +0 -6
  41. package/dist/esm/cache.mjs +0 -40
  42. package/dist/esm/cache.mjs.map +0 -1
  43. package/dist/esm/extensions.native.js +0 -14
  44. package/dist/esm/extensions.native.js.map +0 -1
  45. package/dist/esm/extract.js +0 -129
  46. package/dist/esm/extract.js.map +0 -6
  47. package/dist/esm/extract.mjs +0 -126
  48. package/dist/esm/extract.mjs.map +0 -1
  49. package/dist/esm/extract.native.js +0 -216
  50. package/dist/esm/extract.native.js.map +0 -1
  51. package/dist/esm/index.native.js +0 -3
  52. package/dist/esm/index.native.js.map +0 -1
  53. package/dist/esm/loadTamagui.native.js +0 -36
  54. package/dist/esm/loadTamagui.native.js.map +0 -1
  55. package/dist/esm/plugin.native.js +0 -184
  56. package/dist/esm/plugin.native.js.map +0 -1
package/dist/cjs/cache.js DELETED
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var cache_exports = {};
16
- __export(cache_exports, {
17
- clearCache: () => clearCache,
18
- clearPendingExtraction: () => clearPendingExtraction,
19
- getCache: () => getCache,
20
- getCached: () => getCached,
21
- getPending: () => getPending,
22
- getPendingExtraction: () => getPendingExtraction,
23
- setCache: () => setCache,
24
- setPendingExtraction: () => setPendingExtraction
25
- });
26
- module.exports = __toCommonJS(cache_exports);
27
- const KEYS = {
28
- cache: "__tamagui_vite_cache__",
29
- size: "__tamagui_vite_cache_size__",
30
- pending: "__tamagui_vite_pending__"
31
- }, MAX_CACHE_SIZE = 67108864;
32
- function getGlobal(key, defaultValue) {
33
- return globalThis[key] === void 0 && (globalThis[key] = defaultValue), globalThis[key];
34
- }
35
- function setGlobal(key, value) {
36
- globalThis[key] = value;
37
- }
38
- function getCache() {
39
- return getGlobal(KEYS.cache, {});
40
- }
41
- function getCached(key) {
42
- return getCache()[key];
43
- }
44
- function setCache(key, entry) {
45
- const cache = getCache(), newSize = getGlobal(KEYS.size, 0) + entry.js.length;
46
- newSize > MAX_CACHE_SIZE ? clearCache() : setGlobal(KEYS.size, newSize), cache[key] = entry;
47
- }
48
- function clearCache() {
49
- setGlobal(KEYS.cache, {}), setGlobal(KEYS.size, 0);
50
- }
51
- function getPending() {
52
- return getGlobal(KEYS.pending, /* @__PURE__ */ new Map());
53
- }
54
- function getPendingExtraction(key) {
55
- return getPending().get(key);
56
- }
57
- function setPendingExtraction(key, promise) {
58
- getPending().set(key, promise);
59
- }
60
- function clearPendingExtraction(key) {
61
- getPending().delete(key);
62
- }
63
- //# sourceMappingURL=cache.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/cache.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,MAAM,OAAO;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AACX,GAGM,iBAAiB;AAEvB,SAAS,UAAa,KAAa,cAAoB;AACrD,SAAK,WAAmB,GAAG,MAAM,WAC7B,WAAmB,GAAG,IAAI,eAEtB,WAAmB,GAAG;AAChC;AAEA,SAAS,UAAa,KAAa,OAAgB;AAChD,EAAC,WAAmB,GAAG,IAAI;AAC9B;AAKO,SAAS,WAAuC;AACrD,SAAO,UAAU,KAAK,OAAO,CAAC,CAAC;AACjC;AAKO,SAAS,UAAU,KAAqC;AAC7D,SAAO,SAAS,EAAE,GAAG;AACvB;AAMO,SAAS,SAAS,KAAa,OAAyB;AAC7D,QAAM,QAAQ,SAAS,GAEjB,UADc,UAAkB,KAAK,MAAM,CAAC,IACpB,MAAM,GAAG;AAEvC,EAAI,UAAU,iBACZ,WAAW,IAEX,UAAU,KAAK,MAAM,OAAO,GAG9B,MAAM,GAAG,IAAI;AACf;AAKO,SAAS,aAAmB;AACjC,YAAU,KAAK,OAAO,CAAC,CAAC,GACxB,UAAU,KAAK,MAAM,CAAC;AACxB;AAMO,SAAS,aAAsD;AACpE,SAAO,UAAU,KAAK,SAAS,oBAAI,IAAI,CAAC;AAC1C;AAKO,SAAS,qBACd,KACwC;AACxC,SAAO,WAAW,EAAE,IAAI,GAAG;AAC7B;AAKO,SAAS,qBACd,KACA,SACM;AACN,aAAW,EAAE,IAAI,KAAK,OAAO;AAC/B;AAKO,SAAS,uBAAuB,KAAmB;AACxD,aAAW,EAAE,OAAO,GAAG;AACzB;",
5
- "names": []
6
- }
@@ -1,47 +0,0 @@
1
- var __defProp = Object.defineProperty
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor
3
- var __getOwnPropNames = Object.getOwnPropertyNames
4
- var __hasOwnProp = Object.prototype.hasOwnProperty
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, {
8
- get: all[name],
9
- enumerable: !0,
10
- })
11
- },
12
- __copyProps = (to, from, except, desc) => {
13
- if ((from && typeof from == 'object') || typeof from == 'function')
14
- for (let key of __getOwnPropNames(from))
15
- !__hasOwnProp.call(to, key) &&
16
- key !== except &&
17
- __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
20
- })
21
- return to
22
- }
23
- var __toCommonJS = (mod) =>
24
- __copyProps(
25
- __defProp({}, '__esModule', {
26
- value: !0,
27
- }),
28
- mod
29
- )
30
- var extensions_exports = {}
31
- __export(extensions_exports, {
32
- extensions: () => extensions,
33
- })
34
- module.exports = __toCommonJS(extensions_exports)
35
- const extensions = [
36
- '.ios.js',
37
- '.native.js',
38
- '.native.ts',
39
- '.native.tsx',
40
- '.js',
41
- '.jsx',
42
- '.json',
43
- '.ts',
44
- '.tsx',
45
- '.mjs',
46
- ]
47
- //# sourceMappingURL=extensions.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["extensions_exports","__export","extensions","module","exports","__toCommonJS"],"sources":["../../src/extensions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,kBAAA;AAAO,MAAME,UAAA,GAAa,CACxB,WACA,cACA,cACA,eACA,OACA,QACA,SACA,OACA,QACA,OACF","ignoreList":[]}
@@ -1,47 +0,0 @@
1
- var __defProp = Object.defineProperty
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor
3
- var __getOwnPropNames = Object.getOwnPropertyNames
4
- var __hasOwnProp = Object.prototype.hasOwnProperty
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, {
8
- get: all[name],
9
- enumerable: !0,
10
- })
11
- },
12
- __copyProps = (to, from, except, desc) => {
13
- if ((from && typeof from == 'object') || typeof from == 'function')
14
- for (let key of __getOwnPropNames(from))
15
- !__hasOwnProp.call(to, key) &&
16
- key !== except &&
17
- __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
20
- })
21
- return to
22
- }
23
- var __toCommonJS = (mod) =>
24
- __copyProps(
25
- __defProp({}, '__esModule', {
26
- value: !0,
27
- }),
28
- mod
29
- )
30
- var extensions_exports = {}
31
- __export(extensions_exports, {
32
- extensions: () => extensions,
33
- })
34
- module.exports = __toCommonJS(extensions_exports)
35
- var extensions = [
36
- '.ios.js',
37
- '.native.js',
38
- '.native.ts',
39
- '.native.tsx',
40
- '.js',
41
- '.jsx',
42
- '.json',
43
- '.ts',
44
- '.tsx',
45
- '.mjs',
46
- ]
47
- //# sourceMappingURL=extensions.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","extensions_exports","__export","extensions","module","exports"],"sources":["../../src/extensions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAAT,YAAa,CAAAK,kBAAA;AAAA,IACxBE,UAAA,IACA,WACA,cACA,cACA,eACA,OACA,QACA,SACA,OACA,QACF,O","ignoreList":[]}
@@ -1,160 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __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 extract_exports = {};
33
- __export(extract_exports, {
34
- tamaguiExtractPlugin: () => tamaguiExtractPlugin
35
- });
36
- module.exports = __toCommonJS(extract_exports);
37
- var Static = __toESM(require("@tamagui/static-worker"), 1),
38
- import_static_worker = require("@tamagui/static-worker"),
39
- import_node_path = __toESM(require("node:path"), 1),
40
- import_vite = require("vite"),
41
- import_loadTamagui = require("./loadTamagui.cjs"),
42
- import_node_crypto = require("node:crypto");
43
- function tamaguiExtractPlugin(optionsIn) {
44
- if (optionsIn?.disable) return {
45
- name: "tamagui-extract"
46
- };
47
- const getHash = input => (0, import_node_crypto.createHash)("sha1").update(input).digest("base64"),
48
- clearCompilerCache = () => {
49
- memoryCache = {}, cacheSize = 0;
50
- };
51
- let memoryCache = {},
52
- cacheSize = 0;
53
- const cssMap = /* @__PURE__ */new Map();
54
- let config, server;
55
- const virtualExt = ".tamagui.css",
56
- getAbsoluteVirtualFileId = filePath => filePath.startsWith(config.root) ? filePath : (0, import_vite.normalizePath)(import_node_path.default.join(config.root, filePath));
57
- function isNotClient(environment) {
58
- return environment?.name && environment.name !== "client";
59
- }
60
- function isNative(environment) {
61
- return environment?.name && (environment.name === "ios" || environment.name === "android");
62
- }
63
- function invalidateModule(absoluteId) {
64
- if (!server) return;
65
- const {
66
- moduleGraph
67
- } = server,
68
- modules = moduleGraph.getModulesByFile(absoluteId);
69
- if (modules) for (const module2 of modules) moduleGraph.invalidateModule(module2), module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now();
70
- }
71
- return {
72
- name: "tamagui-extract",
73
- enforce: "pre",
74
- configureServer(_server) {
75
- server = _server;
76
- },
77
- async buildStart() {
78
- await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn);
79
- },
80
- async closeBundle() {},
81
- config(userConf) {
82
- userConf.optimizeDeps ||= {}, userConf.optimizeDeps.include ||= [], userConf.optimizeDeps.include.push("@tamagui/core/inject-styles");
83
- },
84
- async configResolved(resolvedConfig) {
85
- config = resolvedConfig;
86
- },
87
- async resolveId(source) {
88
- if (isNative(this.environment) || isNotClient(this.environment)) return;
89
- const [validId, query] = source.split("?");
90
- if (!validId.endsWith(virtualExt)) return;
91
- const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
92
- if (cssMap.has(absoluteId)) return absoluteId + (query ? `?${query}` : "");
93
- },
94
- /**
95
- * TODO
96
- *
97
- * mainFields module:jsx breaks, so lets just have a mapping here
98
- * where we load() and map it to the jsx path before transform
99
- *
100
- */
101
- async load(id) {
102
- if (import_loadTamagui.disableStatic || isNative(this.environment) || isNotClient(this.environment)) return;
103
- const [validId] = id.split("?");
104
- return cssMap.get(validId);
105
- },
106
- transform: {
107
- order: "pre",
108
- async handler(code, id) {
109
- if (import_loadTamagui.disableStatic || isNative(this.environment)) return;
110
- const [validId] = id.split("?");
111
- if (!validId.endsWith(".tsx")) return;
112
- const firstCommentIndex = code.indexOf("// "),
113
- {
114
- shouldDisable,
115
- shouldPrintDebug
116
- } = await (0, import_static_worker.getPragmaOptions)({
117
- source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
118
- path: validId
119
- });
120
- if (shouldPrintDebug && (console.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`), console.info(`
121
-
122
- Original source:
123
- ${code}
124
-
125
- `)), shouldDisable) return;
126
- const isSSR = isNotClient(this.environment),
127
- cacheKey = getHash(`${this.environment.name}${code}${id}`),
128
- cached = memoryCache[cacheKey];
129
- if (cached) return cached;
130
- let extracted;
131
- try {
132
- extracted = await Static.extractToClassNames({
133
- source: code,
134
- sourcePath: validId,
135
- options: {
136
- ...import_loadTamagui.tamaguiOptions
137
- // run full extraction on both SSR and client for hydration parity
138
- },
139
- shouldPrintDebug
140
- });
141
- } catch (err) {
142
- console.error(err instanceof Error ? err.message : String(err));
143
- return;
144
- }
145
- if (!extracted) return;
146
- const rootRelativeId = `${validId}${virtualExt}`,
147
- absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
148
- let source = extracted.js;
149
- extracted.styles && !isSSR && (this.addWatchFile(rootRelativeId), server && cssMap.has(absoluteId) && invalidateModule(rootRelativeId), source = `${source}
150
- import "${rootRelativeId}";`, cssMap.set(absoluteId, extracted.styles));
151
- const codeOut = source.toString(),
152
- out = {
153
- code: codeOut,
154
- map: extracted.map
155
- };
156
- return cacheSize += codeOut.length, cacheSize > 26214400 && clearCompilerCache(), memoryCache[cacheKey] = out, out;
157
- }
158
- }
159
- };
160
- }
@@ -1,148 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var extract_exports = {};
24
- __export(extract_exports, {
25
- tamaguiExtractPlugin: () => tamaguiExtractPlugin
26
- });
27
- module.exports = __toCommonJS(extract_exports);
28
- var Static = __toESM(require("@tamagui/static-worker"), 1), import_static_worker = require("@tamagui/static-worker"), import_node_path = __toESM(require("node:path"), 1), import_vite = require("vite"), import_loadTamagui = require("./loadTamagui"), import_node_crypto = require("node:crypto");
29
- function tamaguiExtractPlugin(optionsIn) {
30
- if (optionsIn?.disable)
31
- return {
32
- name: "tamagui-extract"
33
- };
34
- const getHash = (input) => (0, import_node_crypto.createHash)("sha1").update(input).digest("base64"), clearCompilerCache = () => {
35
- memoryCache = {}, cacheSize = 0;
36
- };
37
- let memoryCache = {}, cacheSize = 0;
38
- const cssMap = /* @__PURE__ */ new Map();
39
- let config, server;
40
- const virtualExt = ".tamagui.css", getAbsoluteVirtualFileId = (filePath) => filePath.startsWith(config.root) ? filePath : (0, import_vite.normalizePath)(import_node_path.default.join(config.root, filePath));
41
- function isNotClient(environment) {
42
- return environment?.name && environment.name !== "client";
43
- }
44
- function isNative(environment) {
45
- return environment?.name && (environment.name === "ios" || environment.name === "android");
46
- }
47
- function invalidateModule(absoluteId) {
48
- if (!server) return;
49
- const { moduleGraph } = server, modules = moduleGraph.getModulesByFile(absoluteId);
50
- if (modules)
51
- for (const module2 of modules)
52
- moduleGraph.invalidateModule(module2), module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now();
53
- }
54
- return {
55
- name: "tamagui-extract",
56
- enforce: "pre",
57
- configureServer(_server) {
58
- server = _server;
59
- },
60
- async buildStart() {
61
- await (0, import_loadTamagui.loadTamaguiBuildConfig)(optionsIn);
62
- },
63
- async closeBundle() {
64
- },
65
- config(userConf) {
66
- userConf.optimizeDeps ||= {}, userConf.optimizeDeps.include ||= [], userConf.optimizeDeps.include.push("@tamagui/core/inject-styles");
67
- },
68
- async configResolved(resolvedConfig) {
69
- config = resolvedConfig;
70
- },
71
- async resolveId(source) {
72
- if (isNative(this.environment) || isNotClient(this.environment))
73
- return;
74
- const [validId, query] = source.split("?");
75
- if (!validId.endsWith(virtualExt))
76
- return;
77
- const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
78
- if (cssMap.has(absoluteId))
79
- return absoluteId + (query ? `?${query}` : "");
80
- },
81
- /**
82
- * TODO
83
- *
84
- * mainFields module:jsx breaks, so lets just have a mapping here
85
- * where we load() and map it to the jsx path before transform
86
- *
87
- */
88
- async load(id) {
89
- if (import_loadTamagui.disableStatic || isNative(this.environment) || isNotClient(this.environment))
90
- return;
91
- const [validId] = id.split("?");
92
- return cssMap.get(validId);
93
- },
94
- transform: {
95
- order: "pre",
96
- async handler(code, id) {
97
- if (import_loadTamagui.disableStatic || isNative(this.environment))
98
- return;
99
- const [validId] = id.split("?");
100
- if (!validId.endsWith(".tsx"))
101
- return;
102
- const firstCommentIndex = code.indexOf("// "), { shouldDisable, shouldPrintDebug } = await (0, import_static_worker.getPragmaOptions)({
103
- source: firstCommentIndex >= 0 ? code.slice(firstCommentIndex) : "",
104
- path: validId
105
- });
106
- if (shouldPrintDebug && (console.trace(
107
- `Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`
108
- ), console.info(`
109
-
110
- Original source:
111
- ${code}
112
-
113
- `)), shouldDisable)
114
- return;
115
- const isSSR = isNotClient(this.environment), cacheKey = getHash(`${this.environment.name}${code}${id}`), cached = memoryCache[cacheKey];
116
- if (cached)
117
- return cached;
118
- let extracted;
119
- try {
120
- extracted = await Static.extractToClassNames({
121
- source: code,
122
- sourcePath: validId,
123
- options: {
124
- ...import_loadTamagui.tamaguiOptions
125
- // run full extraction on both SSR and client for hydration parity
126
- },
127
- shouldPrintDebug
128
- });
129
- } catch (err) {
130
- console.error(err instanceof Error ? err.message : String(err));
131
- return;
132
- }
133
- if (!extracted)
134
- return;
135
- const rootRelativeId = `${validId}${virtualExt}`, absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
136
- let source = extracted.js;
137
- extracted.styles && !isSSR && (this.addWatchFile(rootRelativeId), server && cssMap.has(absoluteId) && invalidateModule(rootRelativeId), source = `${source}
138
- import "${rootRelativeId}";`, cssMap.set(absoluteId, extracted.styles));
139
- const codeOut = source.toString(), out = {
140
- code: codeOut,
141
- map: extracted.map
142
- };
143
- return cacheSize += codeOut.length, cacheSize > 26214400 && clearCompilerCache(), memoryCache[cacheKey] = out, out;
144
- }
145
- }
146
- };
147
- }
148
- //# sourceMappingURL=extract.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extract.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,aAAwB,+CACxB,uBAAiC,mCACjC,mBAAiB,kCAEjB,cAAgD,iBAChD,qBAAsE,0BAEtE,qBAA2B;AAEpB,SAAS,qBAAqB,WAA6C;AAChF,MAAI,WAAW;AACb,WAAO;AAAA,MACL,MAAM;AAAA,IACR;AAGF,QAAM,UAAU,CAAC,cAAkB,+BAAW,MAAM,EAAE,OAAO,KAAK,EAAE,OAAO,QAAQ,GAE7E,qBAAqB,MAAM;AAC/B,kBAAc,CAAC,GACf,YAAY;AAAA,EACd;AAEA,MAAI,cAAc,CAAC,GACf,YAAY;AAEhB,QAAM,SAAS,oBAAI,IAAoB;AAEvC,MAAI,QACA;AACJ,QAAM,aAAa,gBAEb,2BAA2B,CAAC,aAC5B,SAAS,WAAW,OAAO,IAAI,IAC1B,eAEF,2BAAc,iBAAAA,QAAK,KAAK,OAAO,MAAM,QAAQ,CAAC;AAGvD,WAAS,YAAY,aAA2B;AAC9C,WAAO,aAAa,QAAQ,YAAY,SAAS;AAAA,EACnD;AAEA,WAAS,SAAS,aAA2B;AAC3C,WACE,aAAa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