tamagui-loader 1.0.0-alpha.4 → 1.0.0-alpha.40
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.
- package/dist/.buildinfo +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/loader.js +112 -0
- package/dist/cjs/loader.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/loader.js +80 -0
- package/dist/esm/loader.js.map +7 -0
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/loader.js +79 -0
- package/dist/loader.js +0 -1
- package/dist/loader.js.map +2 -2
- package/package.json +10 -10
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/loader.d.ts +2 -0
- package/types/loader.d.ts.map +1 -0
- package/src/index.ts +0 -4
- package/src/loader.ts +0 -104
package/dist/.buildinfo
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"at":1636517190003}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
default: () => src_default
|
|
26
|
+
});
|
|
27
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
28
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
29
|
+
var src_default = require("./loader").loader;
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
20
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
26
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(module2))
|
|
28
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
29
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
34
|
+
return (module2, temp) => {
|
|
35
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
36
|
+
};
|
|
37
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
38
|
+
var loader_exports = {};
|
|
39
|
+
__export(loader_exports, {
|
|
40
|
+
loader: () => loader
|
|
41
|
+
});
|
|
42
|
+
var import_static = require("@tamagui/static");
|
|
43
|
+
var import_loader_utils = require("loader-utils");
|
|
44
|
+
Error.stackTraceLimit = Infinity;
|
|
45
|
+
const extractor = (0, import_static.createExtractor)();
|
|
46
|
+
const stylesByFile = /* @__PURE__ */ new Map();
|
|
47
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
48
|
+
let index = 0;
|
|
49
|
+
let hasLogged = false;
|
|
50
|
+
let hasPatched = false;
|
|
51
|
+
process.env.TAMAGUI_TARGET = "web";
|
|
52
|
+
function loader(source) {
|
|
53
|
+
this.cacheable();
|
|
54
|
+
const callback = this.async();
|
|
55
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
56
|
+
(0, import_static.patchReactNativeWeb)();
|
|
57
|
+
hasPatched = true;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const threaded = this.emitFile === void 0;
|
|
61
|
+
const options = __spreadValues({}, (0, import_loader_utils.getOptions)(this));
|
|
62
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
63
|
+
if (!hasLogged) {
|
|
64
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
65
|
+
hasLogged = true;
|
|
66
|
+
}
|
|
67
|
+
return callback(null, source);
|
|
68
|
+
}
|
|
69
|
+
const sourcePath = `${this.resourcePath}`;
|
|
70
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
71
|
+
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
72
|
+
if (options.cssPath || options.cssData) {
|
|
73
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath);
|
|
74
|
+
if (!out) {
|
|
75
|
+
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
76
|
+
}
|
|
77
|
+
return callback(null, out);
|
|
78
|
+
}
|
|
79
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
80
|
+
return callback(null, source);
|
|
81
|
+
}
|
|
82
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
83
|
+
const extracted = (0, import_static.extractToClassNames)({
|
|
84
|
+
loader: this,
|
|
85
|
+
extractor,
|
|
86
|
+
source,
|
|
87
|
+
threaded,
|
|
88
|
+
sourcePath,
|
|
89
|
+
cssPath,
|
|
90
|
+
options,
|
|
91
|
+
shouldPrintDebug
|
|
92
|
+
});
|
|
93
|
+
if (!extracted) {
|
|
94
|
+
return callback(null, source);
|
|
95
|
+
}
|
|
96
|
+
if (!threaded) {
|
|
97
|
+
if (extracted.stylesPath) {
|
|
98
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
99
|
+
}
|
|
100
|
+
if (extracted.styles) {
|
|
101
|
+
stylesByFile.set(sourcePath, extracted.styles);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
callback(null, extracted.js, extracted.map);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.error("ERROR", err);
|
|
107
|
+
return callback(null, source);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
__name(loader, "loader");
|
|
111
|
+
module.exports = __toCommonJS(loader_exports);
|
|
112
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport function loader(this: any, source: string) {\n this.cacheable()\n const callback = this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...getOptions(this) }\n\n if (\n options.disableExtraction &&\n (options.disableDebugAttr || process.env.NODE_ENV !== 'development')\n ) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableDebug & disableExtraction set, no parsing running')\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n const shouldPrintDebug =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)\n if (!out) {\n console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)\n }\n return callback(null, out)\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n if (extracted.styles) {\n stylesByFile.set(sourcePath, extracted.styles)\n }\n }\n\n callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,0BAA2B;AAE3B,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAElB,MAAM,eAAe,oBAAI;AACzB,MAAM,sBAAsB,oBAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA2B,QAAgB;AAChD,OAAK;AACL,QAAM,WAAW,KAAK;AAEtB,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD;AACA,iBAAa;AAAA;AAGf,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,mBAAK,oCAAW;AAEhD,QACE,QAAQ,qBACP,SAAQ,oBAAoB,QAAQ,IAAI,aAAa,gBACtD;AACA,UAAI,CAAC,WAAW;AACd,gBAAQ,IAAI;AACZ,oBAAY;AAAA;AAEd,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAC7D,UAAM,mBACH,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,cAAc,SAEzE,qBAAsB,QAAO,WAAW,eAAe,OAAO,WAAW;AAG5E,QAAI,QAAQ,WAAW,QAAQ,SAAS;AACtC,YAAM,MAAM,QAAQ,UAChB,OAAO,KAAK,QAAQ,SAAS,UAAU,SAAS,WAChD,aAAa,IAAI,oBAAoB,IAAI,eAAe;AAC5D,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,gBAAgB,aAAa,QAAQ;AAAA;AAEpD,aAAO,SAAS,MAAM;AAAA;AAIxB,QACE,qBACC,QAAO,WAAW,wBAAwB,OAAO,WAAW,wBAC7D;AACA,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AACzE,UAAM,YAAY,uCAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM;AAAA;AAGxB,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY;AAAA;AAEhD,UAAI,UAAU,QAAQ;AACpB,qBAAa,IAAI,YAAY,UAAU;AAAA;AAAA;AAI3C,aAAS,MAAM,UAAU,IAAI,UAAU;AAAA,WAChC,KAAP;AACA,YAAQ,MAAM,SAAS;AACvB,WAAO,SAAS,MAAM;AAAA;AAAA;AA/EV;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n"],
|
|
5
|
+
"mappings": "AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import {
|
|
4
|
+
createExtractor,
|
|
5
|
+
extractToClassNames,
|
|
6
|
+
patchReactNativeWeb
|
|
7
|
+
} from "@tamagui/static";
|
|
8
|
+
import { getOptions } from "loader-utils";
|
|
9
|
+
Error.stackTraceLimit = Infinity;
|
|
10
|
+
const extractor = createExtractor();
|
|
11
|
+
const stylesByFile = /* @__PURE__ */ new Map();
|
|
12
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
13
|
+
let index = 0;
|
|
14
|
+
let hasLogged = false;
|
|
15
|
+
let hasPatched = false;
|
|
16
|
+
process.env.TAMAGUI_TARGET = "web";
|
|
17
|
+
function loader(source) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.cacheable();
|
|
20
|
+
const callback = this.async();
|
|
21
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
22
|
+
patchReactNativeWeb();
|
|
23
|
+
hasPatched = true;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const threaded = this.emitFile === void 0;
|
|
27
|
+
const options = { ...getOptions(this) };
|
|
28
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
29
|
+
if (!hasLogged) {
|
|
30
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
31
|
+
hasLogged = true;
|
|
32
|
+
}
|
|
33
|
+
return callback(null, source);
|
|
34
|
+
}
|
|
35
|
+
const sourcePath = `${this.resourcePath}`;
|
|
36
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
37
|
+
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
38
|
+
if (options.cssPath || options.cssData) {
|
|
39
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get((_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath);
|
|
40
|
+
if (!out) {
|
|
41
|
+
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
42
|
+
}
|
|
43
|
+
return callback(null, out);
|
|
44
|
+
}
|
|
45
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
46
|
+
return callback(null, source);
|
|
47
|
+
}
|
|
48
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
49
|
+
const extracted = extractToClassNames({
|
|
50
|
+
loader: this,
|
|
51
|
+
extractor,
|
|
52
|
+
source,
|
|
53
|
+
threaded,
|
|
54
|
+
sourcePath,
|
|
55
|
+
cssPath,
|
|
56
|
+
options,
|
|
57
|
+
shouldPrintDebug
|
|
58
|
+
});
|
|
59
|
+
if (!extracted) {
|
|
60
|
+
return callback(null, source);
|
|
61
|
+
}
|
|
62
|
+
if (!threaded) {
|
|
63
|
+
if (extracted.stylesPath) {
|
|
64
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
65
|
+
}
|
|
66
|
+
if (extracted.styles) {
|
|
67
|
+
stylesByFile.set(sourcePath, extracted.styles);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
callback(null, extracted.js, extracted.map);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error("ERROR", err);
|
|
73
|
+
return callback(null, source);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__name(loader, "loader");
|
|
77
|
+
export {
|
|
78
|
+
loader
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport function loader(this: any, source: string) {\n this.cacheable()\n const callback = this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...getOptions(this) }\n\n if (\n options.disableExtraction &&\n (options.disableDebugAttr || process.env.NODE_ENV !== 'development')\n ) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableDebug & disableExtraction set, no parsing running')\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n const shouldPrintDebug =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)\n if (!out) {\n console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)\n }\n return callback(null, out)\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n if (extracted.styles) {\n stylesByFile.set(sourcePath, extracted.styles)\n }\n }\n\n callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAElB,MAAM,eAAe,oBAAI;AACzB,MAAM,sBAAsB,oBAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA2B,QAAgB;AApBlD;AAqBE,OAAK;AACL,QAAM,WAAW,KAAK;AAEtB,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD;AACA,iBAAa;AAAA;AAGf,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,KAAK,WAAW;AAEhD,QACE,QAAQ,qBACP,SAAQ,oBAAoB,QAAQ,IAAI,aAAa,gBACtD;AACA,UAAI,CAAC,WAAW;AACd,gBAAQ,IAAI;AACZ,oBAAY;AAAA;AAEd,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAC7D,UAAM,mBACH,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,cAAc,SAEzE,qBAAsB,QAAO,WAAW,eAAe,OAAO,WAAW;AAG5E,QAAI,QAAQ,WAAW,QAAQ,SAAS;AACtC,YAAM,MAAM,QAAQ,UAChB,OAAO,KAAK,QAAQ,SAAS,UAAU,SAAS,WAChD,aAAa,IAAI,0BAAoB,IAAI,gBAAxB,YAAuC;AAC5D,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,gBAAgB,aAAa,QAAQ;AAAA;AAEpD,aAAO,SAAS,MAAM;AAAA;AAIxB,QACE,qBACC,QAAO,WAAW,wBAAwB,OAAO,WAAW,wBAC7D;AACA,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AACzE,UAAM,YAAY,oBAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM;AAAA;AAGxB,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY;AAAA;AAEhD,UAAI,UAAU,QAAQ;AACpB,qBAAa,IAAI,YAAY,UAAU;AAAA;AAAA;AAI3C,aAAS,MAAM,UAAU,IAAI,UAAU;AAAA,WAChC,KAAP;AACA,YAAQ,MAAM,SAAS;AACvB,WAAO,SAAS,MAAM;AAAA;AAAA;AA/EV;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -115,7 +115,6 @@ var init_loader = __esm({
|
|
|
115
115
|
stylePathToFilePath = new Map();
|
|
116
116
|
index = 0;
|
|
117
117
|
hasLogged = false;
|
|
118
|
-
process.env.TAMAGUI_TARGET = "web";
|
|
119
118
|
__name(loader, "loader");
|
|
120
119
|
}
|
|
121
120
|
});
|
|
@@ -124,7 +123,7 @@ var init_loader = __esm({
|
|
|
124
123
|
__export(exports, {
|
|
125
124
|
default: () => src_default
|
|
126
125
|
});
|
|
127
|
-
process.env.
|
|
128
|
-
process.env.
|
|
126
|
+
process.env.TARGET = process.env.TARGET || "web";
|
|
127
|
+
process.env.SNACKUI_COMPILE_PROCESS = "1";
|
|
129
128
|
var src_default = (init_loader(), loader_exports).loader;
|
|
130
129
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/loader.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { extname } from 'path'\n\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { extname } from 'path'\n\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\n\nexport function loader(this: any, source: string) {\n this.cacheable()\n const callback = this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {\n patchReactNativeWeb()\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...getOptions(this) }\n\n if (options.disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n const shouldPrintDebug =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)\n if (!out) {\n console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)\n }\n return callback(null, out)\n }\n\n // check if should ignore\n const isTamaguiInternalView = sourcePath.includes('/tamagui/')\n\n if (\n !isTamaguiInternalView &&\n (extname(sourcePath) !== '.tsx' ||\n (startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))))\n ) {\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n const extracted = extractToClassNames({\n // @ts-ignore\n loader: this,\n extractor,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n if (extracted.styles) {\n stylesByFile.set(sourcePath, extracted.styles)\n }\n }\n\n callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return callback(null, source)\n }\n}\n", "process.env.TARGET = process.env.TARGET || 'web'\nprocess.env.SNACKUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAmBO,gBAA2B,QAAgB;AAChD,OAAK;AACL,QAAM,WAAW,KAAK;AAEtB,MAAI,CAAC,QAAQ,IAAI,2BAA2B;AAC1C;AAAA;AAGF,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,mBAAK,oCAAW;AAEhD,QAAI,QAAQ,mBAAmB;AAC7B,UAAI,CAAC,WAAW;AACd,gBAAQ,IAAI;AACZ,oBAAY;AAAA;AAEd,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAC7D,UAAM,mBACH,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,cAAc,SAEzE,qBAAsB,QAAO,WAAW,eAAe,OAAO,WAAW;AAG5E,QAAI,QAAQ,WAAW,QAAQ,SAAS;AACtC,YAAM,MAAM,QAAQ,UAChB,OAAO,KAAK,QAAQ,SAAS,UAAU,SAAS,WAChD,aAAa,IAAI,oBAAoB,IAAI,eAAe;AAC5D,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,gBAAgB,aAAa,QAAQ;AAAA;AAEpD,aAAO,SAAS,MAAM;AAAA;AAIxB,UAAM,wBAAwB,WAAW,SAAS;AAElD,QACE,CAAC,yBACA,0BAAQ,gBAAgB,UACtB,qBACE,QAAO,WAAW,wBAAwB,OAAO,WAAW,yBACjE;AACA,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AACzE,UAAM,YAAY,uCAAoB;AAAA,MAEpC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM;AAAA;AAGxB,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY;AAAA;AAEhD,UAAI,UAAU,QAAQ;AACpB,qBAAa,IAAI,YAAY,UAAU;AAAA;AAAA;AAI3C,aAAS,MAAM,UAAU,IAAI,UAAU;AAAA,WAChC,KAAP;AACA,YAAQ,MAAM,SAAS;AACvB,WAAO,SAAS,MAAM;AAAA;AAAA;AAnG1B,iBAEA,eAMA,qBAGM,WAEA,cACA,qBAEF,OACA;AAjBJ;AAAA;AAAA,kBAAwB;AAExB,oBAKO;AACP,0BAA2B;AAE3B,UAAM,kBAAkB;AACxB,IAAM,YAAY;AAElB,IAAM,eAAe,IAAI;AACzB,IAAM,sBAAsB,IAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAEA;AAAA;AAAA;;;ACnBhB;AAAA;AAAA;AAAA,QAAQ,IAAI,SAAS,QAAQ,IAAI,UAAU;AAC3C,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,gCAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
process.env.
|
|
2
|
-
process.env.
|
|
1
|
+
process.env.TARGET = process.env.TARGET || "web";
|
|
2
|
+
process.env.SNACKUI_COMPILE_PROCESS = "1";
|
|
3
3
|
var src_default = require("./loader").loader;
|
|
4
4
|
export {
|
|
5
5
|
src_default as default
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["process.env.
|
|
5
|
-
"mappings": "AAAA,QAAQ,IAAI,
|
|
4
|
+
"sourcesContent": ["process.env.TARGET = process.env.TARGET || 'web'\nprocess.env.SNACKUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n"],
|
|
5
|
+
"mappings": "AAAA,QAAQ,IAAI,SAAS,QAAQ,IAAI,UAAU;AAC3C,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import {
|
|
4
|
+
createExtractor,
|
|
5
|
+
extractToClassNames,
|
|
6
|
+
patchReactNativeWeb
|
|
7
|
+
} from "@tamagui/static";
|
|
8
|
+
import { getOptions } from "loader-utils";
|
|
9
|
+
Error.stackTraceLimit = Infinity;
|
|
10
|
+
const extractor = createExtractor();
|
|
11
|
+
const stylesByFile = /* @__PURE__ */ new Map();
|
|
12
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
13
|
+
let index = 0;
|
|
14
|
+
let hasLogged = false;
|
|
15
|
+
let hasPatched = false;
|
|
16
|
+
process.env.TAMAGUI_TARGET = "web";
|
|
17
|
+
function loader(source) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.cacheable();
|
|
20
|
+
const callback = this.async();
|
|
21
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
22
|
+
patchReactNativeWeb();
|
|
23
|
+
hasPatched = true;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const threaded = this.emitFile === void 0;
|
|
27
|
+
const options = { ...getOptions(this) };
|
|
28
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
29
|
+
if (!hasLogged) {
|
|
30
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
31
|
+
hasLogged = true;
|
|
32
|
+
}
|
|
33
|
+
return callback(null, source);
|
|
34
|
+
}
|
|
35
|
+
const sourcePath = `${this.resourcePath}`;
|
|
36
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
37
|
+
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
38
|
+
if (options.cssPath || options.cssData) {
|
|
39
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get((_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath);
|
|
40
|
+
if (!out) {
|
|
41
|
+
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
42
|
+
}
|
|
43
|
+
return callback(null, out);
|
|
44
|
+
}
|
|
45
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
46
|
+
return callback(null, source);
|
|
47
|
+
}
|
|
48
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
49
|
+
const extracted = extractToClassNames({
|
|
50
|
+
loader: this,
|
|
51
|
+
extractor,
|
|
52
|
+
source,
|
|
53
|
+
threaded,
|
|
54
|
+
sourcePath,
|
|
55
|
+
cssPath,
|
|
56
|
+
options,
|
|
57
|
+
shouldPrintDebug
|
|
58
|
+
});
|
|
59
|
+
if (!extracted) {
|
|
60
|
+
return callback(null, source);
|
|
61
|
+
}
|
|
62
|
+
if (!threaded) {
|
|
63
|
+
if (extracted.stylesPath) {
|
|
64
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
65
|
+
}
|
|
66
|
+
if (extracted.styles) {
|
|
67
|
+
stylesByFile.set(sourcePath, extracted.styles);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
callback(null, extracted.js, extracted.map);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error("ERROR", err);
|
|
73
|
+
return callback(null, source);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__name(loader, "loader");
|
|
77
|
+
export {
|
|
78
|
+
loader
|
|
79
|
+
};
|
package/dist/loader.js
CHANGED
package/dist/loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/loader.ts"],
|
|
4
|
-
"sourcesContent": ["import { extname } from 'path'\n\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\n\
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAElB,MAAM,eAAe,IAAI;AACzB,MAAM,sBAAsB,IAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;
|
|
4
|
+
"sourcesContent": ["import { extname } from 'path'\n\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { getOptions } from 'loader-utils'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst stylesByFile = new Map<string, string>()\nconst stylePathToFilePath = new Map<string, string>()\n\nlet index = 0\nlet hasLogged = false\n\nexport function loader(this: any, source: string) {\n this.cacheable()\n const callback = this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {\n patchReactNativeWeb()\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...getOptions(this) }\n\n if (options.disableExtraction) {\n if (!hasLogged) {\n console.log('\uD83E\uDD5A Tamagui disableExtraction set: no CSS or optimizations will be run')\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n const shouldPrintDebug =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)\n if (!out) {\n console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)\n }\n return callback(null, out)\n }\n\n // check if should ignore\n const isTamaguiInternalView = sourcePath.includes('/tamagui/')\n\n if (\n !isTamaguiInternalView &&\n (extname(sourcePath) !== '.tsx' ||\n (startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))))\n ) {\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n const extracted = extractToClassNames({\n // @ts-ignore\n loader: this,\n extractor,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n if (extracted.styles) {\n stylesByFile.set(sourcePath, extracted.styles)\n }\n }\n\n callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAElB,MAAM,eAAe,IAAI;AACzB,MAAM,sBAAsB,IAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAET,gBAA2B,QAAgB;AAChD,OAAK;AACL,QAAM,WAAW,KAAK;AAEtB,MAAI,CAAC,QAAQ,IAAI,2BAA2B;AAC1C;AAAA;AAGF,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,KAAK,WAAW;AAEhD,QAAI,QAAQ,mBAAmB;AAC7B,UAAI,CAAC,WAAW;AACd,gBAAQ,IAAI;AACZ,oBAAY;AAAA;AAEd,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAC7D,UAAM,mBACH,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,cAAc,SAEzE,qBAAsB,QAAO,WAAW,eAAe,OAAO,WAAW;AAG5E,QAAI,QAAQ,WAAW,QAAQ,SAAS;AACtC,YAAM,MAAM,QAAQ,UAChB,OAAO,KAAK,QAAQ,SAAS,UAAU,SAAS,WAChD,aAAa,IAAI,oBAAoB,IAAI,eAAe;AAC5D,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,gBAAgB,aAAa,QAAQ;AAAA;AAEpD,aAAO,SAAS,MAAM;AAAA;AAIxB,UAAM,wBAAwB,WAAW,SAAS;AAElD,QACE,CAAC,yBACA,SAAQ,gBAAgB,UACtB,qBACE,QAAO,WAAW,wBAAwB,OAAO,WAAW,yBACjE;AACA,aAAO,SAAS,MAAM;AAAA;AAGxB,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AACzE,UAAM,YAAY,oBAAoB;AAAA,MAEpC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM;AAAA;AAGxB,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY;AAAA;AAEhD,UAAI,UAAU,QAAQ;AACpB,qBAAa,IAAI,YAAY,UAAU;AAAA;AAAA;AAI3C,aAAS,MAAM,UAAU,IAAI,UAAU;AAAA,WAChC,KAAP;AACA,YAAQ,MAAM,SAAS;AACvB,WAAO,SAAS,MAAM;AAAA;AAAA;AAhFV;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamagui-loader",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"module": "dist/
|
|
7
|
-
"
|
|
3
|
+
"version": "1.0.0-alpha.40",
|
|
4
|
+
"typings": "types",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"module:jsx": "dist/jsx",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"types",
|
|
10
|
+
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tamagui-build",
|
|
14
14
|
"watch": "tamagui-build --watch"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@tamagui/static": "^1.0.0-alpha.
|
|
17
|
+
"@tamagui/static": "^1.0.0-alpha.40",
|
|
18
18
|
"fs-extra": "^9.1.0",
|
|
19
19
|
"loader-utils": "^2.0.0",
|
|
20
20
|
"lodash": "^4.17.21"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
23
|
+
"@tamagui/build": "^1.0.0-alpha.40"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "425b002aea52f714266c1ae6ddbef6ba62deafeb"
|
|
29
29
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAoBA,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAiF/C"}
|
package/src/index.ts
DELETED
package/src/loader.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { extname } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
TamaguiOptions,
|
|
5
|
-
createExtractor,
|
|
6
|
-
extractToClassNames,
|
|
7
|
-
patchReactNativeWeb,
|
|
8
|
-
} from '@tamagui/static'
|
|
9
|
-
import { getOptions } from 'loader-utils'
|
|
10
|
-
|
|
11
|
-
Error.stackTraceLimit = Infinity
|
|
12
|
-
const extractor = createExtractor()
|
|
13
|
-
|
|
14
|
-
const stylesByFile = new Map<string, string>()
|
|
15
|
-
const stylePathToFilePath = new Map<string, string>()
|
|
16
|
-
|
|
17
|
-
let index = 0
|
|
18
|
-
let hasLogged = false
|
|
19
|
-
|
|
20
|
-
process.env.TAMAGUI_TARGET = 'web'
|
|
21
|
-
|
|
22
|
-
export function loader(this: any, source: string) {
|
|
23
|
-
this.cacheable()
|
|
24
|
-
const callback = this.async()
|
|
25
|
-
|
|
26
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {
|
|
27
|
-
patchReactNativeWeb()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const threaded = this.emitFile === undefined
|
|
32
|
-
const options: TamaguiOptions = { ...getOptions(this) }
|
|
33
|
-
|
|
34
|
-
if (options.disableExtraction) {
|
|
35
|
-
if (!hasLogged) {
|
|
36
|
-
console.log('🥚 Tamagui disableExtraction set: no CSS or optimizations will be run')
|
|
37
|
-
hasLogged = true
|
|
38
|
-
}
|
|
39
|
-
return callback(null, source)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const sourcePath = `${this.resourcePath}`
|
|
43
|
-
const startsWithComment = source[0] === '/' && source[1] === '/'
|
|
44
|
-
const shouldPrintDebug =
|
|
45
|
-
(!!process.env.DEBUG &&
|
|
46
|
-
(process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||
|
|
47
|
-
// supports esbuild style //! comments
|
|
48
|
-
(startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))
|
|
49
|
-
|
|
50
|
-
// if outputted css
|
|
51
|
-
if (options.cssPath || options.cssData) {
|
|
52
|
-
const out = options.cssData
|
|
53
|
-
? Buffer.from(options.cssData, 'base64').toString('utf-8')
|
|
54
|
-
: stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)
|
|
55
|
-
if (!out) {
|
|
56
|
-
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)
|
|
57
|
-
}
|
|
58
|
-
return callback(null, out)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// check if should ignore
|
|
62
|
-
const isTamaguiInternalView = sourcePath.includes('/tamagui/')
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
!isTamaguiInternalView &&
|
|
66
|
-
(extname(sourcePath) !== '.tsx' ||
|
|
67
|
-
(startsWithComment &&
|
|
68
|
-
(source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))))
|
|
69
|
-
) {
|
|
70
|
-
return callback(null, source)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`
|
|
74
|
-
const extracted = extractToClassNames({
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
loader: this,
|
|
77
|
-
extractor,
|
|
78
|
-
source,
|
|
79
|
-
threaded,
|
|
80
|
-
sourcePath,
|
|
81
|
-
cssPath,
|
|
82
|
-
options,
|
|
83
|
-
shouldPrintDebug,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (!extracted) {
|
|
87
|
-
return callback(null, source)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (!threaded) {
|
|
91
|
-
if (extracted.stylesPath) {
|
|
92
|
-
stylePathToFilePath.set(extracted.stylesPath, sourcePath)
|
|
93
|
-
}
|
|
94
|
-
if (extracted.styles) {
|
|
95
|
-
stylesByFile.set(sourcePath, extracted.styles)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
callback(null, extracted.js, extracted.map)
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.error('ERROR', err)
|
|
102
|
-
return callback(null, source)
|
|
103
|
-
}
|
|
104
|
-
}
|