tamagui-loader 1.0.0-alpha.7 → 1.0.0-beta.147
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/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/loader.js +111 -0
- package/dist/cjs/loader.js.map +7 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/{loader.js → esm/loader.js} +18 -15
- package/dist/esm/loader.js.map +7 -0
- package/dist/jsx/index.js +19 -0
- package/dist/jsx/loader.js +83 -0
- package/package.json +13 -13
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -0
- package/types/loader.d.ts +3 -0
- package/types/loader.d.ts.map +1 -0
- package/dist/index.cjs +0 -132
- package/dist/index.cjs.map +0 -7
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -7
- package/dist/loader.js.map +0 -7
- package/src/index.ts +0 -4
- package/src/loader.ts +0 -107
- package/types.d.ts +0 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
default: () => src_default,
|
|
22
|
+
shouldExclude: () => shouldExclude
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(src_exports);
|
|
25
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
26
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
27
|
+
var src_default = require("./loader").loader;
|
|
28
|
+
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
29
|
+
if (path.includes("react-native-reanimated")) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const shouldInclude = path.includes(projectRoot) || tamaguiOptions.components.some((c) => path.includes(`/node_modules/${c}`) || path.includes(`${c}/dist/jsx/`) || path.includes("tamagui") && path.includes("/dist/jsx/"));
|
|
33
|
+
if (!shouldInclude) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}, "shouldExclude");
|
|
38
|
+
//# 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\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (path: string, projectRoot: string, tamaguiOptions: any) => {\n if (path.includes('react-native-reanimated')) {\n return false\n }\n // analyze everything in our jsx dir\n // analyze everything in the components dirs\n const shouldInclude =\n path.includes(projectRoot) ||\n tamaguiOptions.components.some(\n (c) =>\n path.includes(`/node_modules/${c}`) ||\n path.includes(`${c}/dist/jsx/`) ||\n // more generic catch-all for independent tamagui packages like drawer\n (path.includes('tamagui') && path.includes('/dist/jsx/'))\n )\n if (!shouldInclude) {\n return true\n }\n return false\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,wBAAC,MAAc,aAAqB,mBAAwB;AACvF,MAAI,KAAK,SAAS,yBAAyB,GAAG;AAC5C,WAAO;AAAA,EACT;AAGA,QAAM,gBACJ,KAAK,SAAS,WAAW,KACzB,eAAe,WAAW,KACxB,CAAC,MACC,KAAK,SAAS,iBAAiB,GAAG,KAClC,KAAK,SAAS,GAAG,aAAa,KAE7B,KAAK,SAAS,SAAS,KAAK,KAAK,SAAS,YAAY,CAC3D;AACF,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAnB6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var loader_exports = {};
|
|
34
|
+
__export(loader_exports, {
|
|
35
|
+
loader: () => loader
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(loader_exports);
|
|
38
|
+
var import_static = require("@tamagui/static");
|
|
39
|
+
Error.stackTraceLimit = Infinity;
|
|
40
|
+
const extractor = (0, import_static.createExtractor)();
|
|
41
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
42
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
43
|
+
let index = 0;
|
|
44
|
+
let hasLogged = false;
|
|
45
|
+
let hasPatched = false;
|
|
46
|
+
process.env.TAMAGUI_TARGET = "web";
|
|
47
|
+
function loader(source) {
|
|
48
|
+
this.cacheable();
|
|
49
|
+
const callback = this.async();
|
|
50
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
51
|
+
(0, import_static.patchReactNativeWeb)();
|
|
52
|
+
hasPatched = true;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const threaded = this.emitFile === void 0;
|
|
56
|
+
const options = __spreadValues({}, this.getOptions());
|
|
57
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
58
|
+
if (!hasLogged) {
|
|
59
|
+
console.log(" \xBB disableExtraction:", options.disableExtraction);
|
|
60
|
+
hasLogged = true;
|
|
61
|
+
}
|
|
62
|
+
return callback(null, source);
|
|
63
|
+
}
|
|
64
|
+
const sourcePath = `${this.resourcePath}`;
|
|
65
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
66
|
+
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
67
|
+
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
68
|
+
shouldPrintDebug = "verbose";
|
|
69
|
+
}
|
|
70
|
+
if (options.cssPath || options.cssData) {
|
|
71
|
+
const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath;
|
|
72
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
73
|
+
stylePathToFilePath.delete(sourcePath);
|
|
74
|
+
extractedInfoByFile.delete(pathKey);
|
|
75
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : info == null ? void 0 : info.styles;
|
|
76
|
+
if (!out) {
|
|
77
|
+
console.warn(`no styles... ${extractedInfoByFile.keys} ${sourcePath}`);
|
|
78
|
+
}
|
|
79
|
+
return callback(null, out || "");
|
|
80
|
+
}
|
|
81
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
82
|
+
return callback(null, source);
|
|
83
|
+
}
|
|
84
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
85
|
+
const extracted = (0, import_static.extractToClassNames)({
|
|
86
|
+
loader: this,
|
|
87
|
+
extractor,
|
|
88
|
+
source,
|
|
89
|
+
threaded,
|
|
90
|
+
sourcePath,
|
|
91
|
+
cssPath,
|
|
92
|
+
options,
|
|
93
|
+
shouldPrintDebug
|
|
94
|
+
});
|
|
95
|
+
if (!extracted) {
|
|
96
|
+
return callback(null, source);
|
|
97
|
+
}
|
|
98
|
+
extractedInfoByFile.set(sourcePath, extracted);
|
|
99
|
+
if (!threaded) {
|
|
100
|
+
if (extracted.stylesPath) {
|
|
101
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
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
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n ExtractedResponse,\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst extractedInfoByFile = new Map<string, ExtractedResponse>()\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: LoaderContext<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 = { ...this.getOptions() }\n\n if (\n options.disableExtraction &&\n (options.disableDebugAttr || process.env.NODE_ENV !== 'development')\n ) {\n if (!hasLogged) {\n console.log(' \u00BB disableExtraction:', options.disableExtraction)\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\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 (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n // get output CSS\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : info?.styles\n if (!out) {\n console.warn(`no styles... ${extractedInfoByFile.keys} ${sourcePath}`)\n }\n // use original JS sourcemap\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 extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;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AAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO,IACvD,6BAAM;AACV,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,gBAAgB,oBAAoB,QAAQ,YAAY;AAAA,MACvE;AAEA,aAAO,SAAS,MAAM,OAAO,EAAE;AAAA,IACjC;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,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,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,wBAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,aAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EAC5C,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,SAAS,MAAM,MAAM;AAAA,EAC9B;AACF;AA7FgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
4
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
5
|
+
var src_default = require("./loader").loader;
|
|
6
|
+
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
7
|
+
if (path.includes("react-native-reanimated")) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const shouldInclude = path.includes(projectRoot) || tamaguiOptions.components.some((c) => path.includes(`/node_modules/${c}`) || path.includes(`${c}/dist/jsx/`) || path.includes("tamagui") && path.includes("/dist/jsx/"));
|
|
11
|
+
if (!shouldInclude) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}, "shouldExclude");
|
|
16
|
+
export {
|
|
17
|
+
src_default as default,
|
|
18
|
+
shouldExclude
|
|
19
|
+
};
|
|
20
|
+
//# 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\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (path: string, projectRoot: string, tamaguiOptions: any) => {\n if (path.includes('react-native-reanimated')) {\n return false\n }\n // analyze everything in our jsx dir\n // analyze everything in the components dirs\n const shouldInclude =\n path.includes(projectRoot) ||\n tamaguiOptions.components.some(\n (c) =>\n path.includes(`/node_modules/${c}`) ||\n path.includes(`${c}/dist/jsx/`) ||\n // more generic catch-all for independent tamagui packages like drawer\n (path.includes('tamagui') && path.includes('/dist/jsx/'))\n )\n if (!shouldInclude) {\n return true\n }\n return false\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,wBAAC,MAAc,aAAqB,mBAAwB;AACvF,MAAI,KAAK,SAAS,yBAAyB,GAAG;AAC5C,WAAO;AAAA,EACT;AAGA,QAAM,gBACJ,KAAK,SAAS,WAAW,KACzB,eAAe,WAAW,KACxB,CAAC,MACC,KAAK,SAAS,iBAAiB,GAAG,KAClC,KAAK,SAAS,GAAG,aAAa,KAE7B,KAAK,SAAS,SAAS,KAAK,KAAK,SAAS,YAAY,CAC3D;AACF,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAnB6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { extname } from "path";
|
|
4
3
|
import {
|
|
5
4
|
createExtractor,
|
|
6
5
|
extractToClassNames,
|
|
7
6
|
patchReactNativeWeb
|
|
8
7
|
} from "@tamagui/static";
|
|
9
|
-
import { getOptions } from "loader-utils";
|
|
10
8
|
Error.stackTraceLimit = Infinity;
|
|
11
9
|
const extractor = createExtractor();
|
|
12
|
-
const
|
|
13
|
-
const stylePathToFilePath = new Map();
|
|
10
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
11
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
14
12
|
let index = 0;
|
|
15
13
|
let hasLogged = false;
|
|
16
14
|
let hasPatched = false;
|
|
17
15
|
process.env.TAMAGUI_TARGET = "web";
|
|
18
16
|
function loader(source) {
|
|
17
|
+
var _a;
|
|
19
18
|
this.cacheable();
|
|
20
19
|
const callback = this.async();
|
|
21
20
|
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
@@ -24,26 +23,32 @@ function loader(source) {
|
|
|
24
23
|
}
|
|
25
24
|
try {
|
|
26
25
|
const threaded = this.emitFile === void 0;
|
|
27
|
-
const options = { ...getOptions(
|
|
26
|
+
const options = { ...this.getOptions() };
|
|
28
27
|
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
29
28
|
if (!hasLogged) {
|
|
30
|
-
console.log("\
|
|
29
|
+
console.log(" \xBB disableExtraction:", options.disableExtraction);
|
|
31
30
|
hasLogged = true;
|
|
32
31
|
}
|
|
33
32
|
return callback(null, source);
|
|
34
33
|
}
|
|
35
34
|
const sourcePath = `${this.resourcePath}`;
|
|
36
35
|
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
37
|
-
|
|
36
|
+
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
|
+
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
38
|
+
shouldPrintDebug = "verbose";
|
|
39
|
+
}
|
|
38
40
|
if (options.cssPath || options.cssData) {
|
|
39
|
-
const
|
|
41
|
+
const pathKey = (_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath;
|
|
42
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
43
|
+
stylePathToFilePath.delete(sourcePath);
|
|
44
|
+
extractedInfoByFile.delete(pathKey);
|
|
45
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : info == null ? void 0 : info.styles;
|
|
40
46
|
if (!out) {
|
|
41
|
-
console.warn(`no styles... ${
|
|
47
|
+
console.warn(`no styles... ${extractedInfoByFile.keys} ${sourcePath}`);
|
|
42
48
|
}
|
|
43
|
-
return callback(null, out);
|
|
49
|
+
return callback(null, out || "");
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
if (ext !== ".tsx" && ext !== ".jsx" || startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
51
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
47
52
|
return callback(null, source);
|
|
48
53
|
}
|
|
49
54
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
@@ -60,13 +65,11 @@ function loader(source) {
|
|
|
60
65
|
if (!extracted) {
|
|
61
66
|
return callback(null, source);
|
|
62
67
|
}
|
|
68
|
+
extractedInfoByFile.set(sourcePath, extracted);
|
|
63
69
|
if (!threaded) {
|
|
64
70
|
if (extracted.stylesPath) {
|
|
65
71
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
66
72
|
}
|
|
67
|
-
if (extracted.styles) {
|
|
68
|
-
stylesByFile.set(sourcePath, extracted.styles);
|
|
69
|
-
}
|
|
70
73
|
}
|
|
71
74
|
callback(null, extracted.js, extracted.map);
|
|
72
75
|
} catch (err) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n ExtractedResponse,\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nconst extractedInfoByFile = new Map<string, ExtractedResponse>()\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: LoaderContext<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 = { ...this.getOptions() }\n\n if (\n options.disableExtraction &&\n (options.disableDebugAttr || process.env.NODE_ENV !== 'development')\n ) {\n if (!hasLogged) {\n console.log(' \u00BB disableExtraction:', options.disableExtraction)\n hasLogged = true\n }\n return callback(null, source)\n }\n\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\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 (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // if outputted css\n if (options.cssPath || options.cssData) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n // get output CSS\n const out = options.cssData\n ? Buffer.from(options.cssData, 'base64').toString('utf-8')\n : info?.styles\n if (!out) {\n console.warn(`no styles... ${extractedInfoByFile.keys} ${sourcePath}`)\n }\n // use original JS sourcemap\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 extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\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;AASA,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAEpD,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA0C,QAAgB;AArBjE;AAsBE,OAAK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S,MAAM,MAAM;AAAA,IAC9B;AAEA,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,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,wBAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,aAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EAC5C,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,SAAS,MAAM,MAAM;AAAA,EAC9B;AACF;AA7FgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
4
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
5
|
+
var src_default = require("./loader").loader;
|
|
6
|
+
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
7
|
+
if (path.includes("react-native-reanimated")) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const shouldInclude = path.includes(projectRoot) || tamaguiOptions.components.some((c) => path.includes(`/node_modules/${c}`) || path.includes(`${c}/dist/jsx/`) || path.includes("tamagui") && path.includes("/dist/jsx/"));
|
|
11
|
+
if (!shouldInclude) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}, "shouldExclude");
|
|
16
|
+
export {
|
|
17
|
+
src_default as default,
|
|
18
|
+
shouldExclude
|
|
19
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
Error.stackTraceLimit = Infinity;
|
|
9
|
+
const extractor = createExtractor();
|
|
10
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
11
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
12
|
+
let index = 0;
|
|
13
|
+
let hasLogged = false;
|
|
14
|
+
let hasPatched = false;
|
|
15
|
+
process.env.TAMAGUI_TARGET = "web";
|
|
16
|
+
function loader(source) {
|
|
17
|
+
var _a;
|
|
18
|
+
this.cacheable();
|
|
19
|
+
const callback = this.async();
|
|
20
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
21
|
+
patchReactNativeWeb();
|
|
22
|
+
hasPatched = true;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const threaded = this.emitFile === void 0;
|
|
26
|
+
const options = { ...this.getOptions() };
|
|
27
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
28
|
+
if (!hasLogged) {
|
|
29
|
+
console.log(" \xBB disableExtraction:", options.disableExtraction);
|
|
30
|
+
hasLogged = true;
|
|
31
|
+
}
|
|
32
|
+
return callback(null, source);
|
|
33
|
+
}
|
|
34
|
+
const sourcePath = `${this.resourcePath}`;
|
|
35
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
36
|
+
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
|
+
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
38
|
+
shouldPrintDebug = "verbose";
|
|
39
|
+
}
|
|
40
|
+
if (options.cssPath || options.cssData) {
|
|
41
|
+
const pathKey = (_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath;
|
|
42
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
43
|
+
stylePathToFilePath.delete(sourcePath);
|
|
44
|
+
extractedInfoByFile.delete(pathKey);
|
|
45
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : info == null ? void 0 : info.styles;
|
|
46
|
+
if (!out) {
|
|
47
|
+
console.warn(`no styles... ${extractedInfoByFile.keys} ${sourcePath}`);
|
|
48
|
+
}
|
|
49
|
+
return callback(null, out || "");
|
|
50
|
+
}
|
|
51
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
52
|
+
return callback(null, source);
|
|
53
|
+
}
|
|
54
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
55
|
+
const extracted = extractToClassNames({
|
|
56
|
+
loader: this,
|
|
57
|
+
extractor,
|
|
58
|
+
source,
|
|
59
|
+
threaded,
|
|
60
|
+
sourcePath,
|
|
61
|
+
cssPath,
|
|
62
|
+
options,
|
|
63
|
+
shouldPrintDebug
|
|
64
|
+
});
|
|
65
|
+
if (!extracted) {
|
|
66
|
+
return callback(null, source);
|
|
67
|
+
}
|
|
68
|
+
extractedInfoByFile.set(sourcePath, extracted);
|
|
69
|
+
if (!threaded) {
|
|
70
|
+
if (extracted.stylesPath) {
|
|
71
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
callback(null, extracted.js, extracted.map);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error("ERROR", err);
|
|
77
|
+
return callback(null, source);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__name(loader, "loader");
|
|
81
|
+
export {
|
|
82
|
+
loader
|
|
83
|
+
};
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamagui-loader",
|
|
3
|
-
"version": "1.0.0-
|
|
4
|
-
"
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"module": "dist/
|
|
7
|
-
"
|
|
3
|
+
"version": "1.0.0-beta.147+6d63af55",
|
|
4
|
+
"typings": "types",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"module:jsx": "dist/jsx",
|
|
8
8
|
"files": [
|
|
9
|
-
"types
|
|
10
|
-
"dist"
|
|
11
|
-
"src"
|
|
9
|
+
"types",
|
|
10
|
+
"dist"
|
|
12
11
|
],
|
|
13
12
|
"scripts": {
|
|
14
13
|
"build": "tamagui-build",
|
|
15
|
-
"watch": "tamagui-build --watch"
|
|
14
|
+
"watch": "tamagui-build --watch",
|
|
15
|
+
"clean": "tamagui-build clean",
|
|
16
|
+
"clean:build": "tamagui-build clean:build"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@tamagui/static": "^1.0.0-
|
|
19
|
+
"@tamagui/static": "^1.0.0-beta.147+6d63af55",
|
|
19
20
|
"fs-extra": "^9.1.0",
|
|
20
|
-
"loader-utils": "^2.0.0",
|
|
21
21
|
"lodash": "^4.17.21"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "^1.0.0-
|
|
24
|
+
"@tamagui/build": "^1.0.0-beta.147+6d63af55"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "6d63af55317e3c878ea0b61995728fa480776ffc"
|
|
30
30
|
}
|
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;AAIzC,eAAO,MAAM,aAAa,SAAU,MAAM,eAAe,MAAM,kBAAkB,GAAG,YAmBnF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAcvC,wBAAgB,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,QA6F9D"}
|
package/dist/index.cjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
23
|
-
var __esm = (fn, res) => function __init() {
|
|
24
|
-
return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
|
|
25
|
-
};
|
|
26
|
-
var __export = (target, all) => {
|
|
27
|
-
__markAsModule(target);
|
|
28
|
-
for (var name in all)
|
|
29
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
|
-
};
|
|
31
|
-
var __reExport = (target, module2, desc) => {
|
|
32
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
33
|
-
for (let key of __getOwnPropNames(module2))
|
|
34
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
35
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
36
|
-
}
|
|
37
|
-
return target;
|
|
38
|
-
};
|
|
39
|
-
var __toModule = (module2) => {
|
|
40
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/loader.ts
|
|
44
|
-
var loader_exports = {};
|
|
45
|
-
__export(loader_exports, {
|
|
46
|
-
loader: () => loader
|
|
47
|
-
});
|
|
48
|
-
function loader(source) {
|
|
49
|
-
this.cacheable();
|
|
50
|
-
const callback = this.async();
|
|
51
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
52
|
-
(0, import_static.patchReactNativeWeb)();
|
|
53
|
-
hasPatched = true;
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const threaded = this.emitFile === void 0;
|
|
57
|
-
const options = __spreadValues({}, (0, import_loader_utils.getOptions)(this));
|
|
58
|
-
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
59
|
-
if (!hasLogged) {
|
|
60
|
-
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
61
|
-
hasLogged = true;
|
|
62
|
-
}
|
|
63
|
-
return callback(null, source);
|
|
64
|
-
}
|
|
65
|
-
const sourcePath = `${this.resourcePath}`;
|
|
66
|
-
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
67
|
-
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
68
|
-
if (options.cssPath || options.cssData) {
|
|
69
|
-
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath);
|
|
70
|
-
if (!out) {
|
|
71
|
-
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
72
|
-
}
|
|
73
|
-
return callback(null, out);
|
|
74
|
-
}
|
|
75
|
-
const ext = (0, import_path.extname)(sourcePath);
|
|
76
|
-
if (ext !== ".tsx" && ext !== ".jsx" || startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
77
|
-
return callback(null, source);
|
|
78
|
-
}
|
|
79
|
-
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
80
|
-
const extracted = (0, import_static.extractToClassNames)({
|
|
81
|
-
loader: this,
|
|
82
|
-
extractor,
|
|
83
|
-
source,
|
|
84
|
-
threaded,
|
|
85
|
-
sourcePath,
|
|
86
|
-
cssPath,
|
|
87
|
-
options,
|
|
88
|
-
shouldPrintDebug
|
|
89
|
-
});
|
|
90
|
-
if (!extracted) {
|
|
91
|
-
return callback(null, source);
|
|
92
|
-
}
|
|
93
|
-
if (!threaded) {
|
|
94
|
-
if (extracted.stylesPath) {
|
|
95
|
-
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
96
|
-
}
|
|
97
|
-
if (extracted.styles) {
|
|
98
|
-
stylesByFile.set(sourcePath, extracted.styles);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
callback(null, extracted.js, extracted.map);
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.error("ERROR", err);
|
|
104
|
-
return callback(null, source);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
var import_path, import_static, import_loader_utils, extractor, stylesByFile, stylePathToFilePath, index, hasLogged, hasPatched;
|
|
108
|
-
var init_loader = __esm({
|
|
109
|
-
"src/loader.ts"() {
|
|
110
|
-
import_path = __toModule(require("path"));
|
|
111
|
-
import_static = __toModule(require("@tamagui/static"));
|
|
112
|
-
import_loader_utils = __toModule(require("loader-utils"));
|
|
113
|
-
Error.stackTraceLimit = Infinity;
|
|
114
|
-
extractor = (0, import_static.createExtractor)();
|
|
115
|
-
stylesByFile = new Map();
|
|
116
|
-
stylePathToFilePath = new Map();
|
|
117
|
-
index = 0;
|
|
118
|
-
hasLogged = false;
|
|
119
|
-
hasPatched = false;
|
|
120
|
-
process.env.TAMAGUI_TARGET = "web";
|
|
121
|
-
__name(loader, "loader");
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// src/index.ts
|
|
126
|
-
__export(exports, {
|
|
127
|
-
default: () => src_default
|
|
128
|
-
});
|
|
129
|
-
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
130
|
-
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
131
|
-
var src_default = (init_loader(), loader_exports).loader;
|
|
132
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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\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 const ext = extname(sourcePath)\n if (\n (ext !== '.tsx' && ext !== '.jsx') ||\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.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;AAsBO,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,g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@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/loader.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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\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 const ext = extname(sourcePath)\n if (\n (ext !== '.tsx' && ext !== '.jsx') ||\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;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,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AA;AAI3C,aAAS,MAAM,UAAU,IAAI,UAAU;AAAA,WAChC,KAAP;AACA,YAAQ,MAAM,SAAS;AACvB,WAAO,SAAS,MAAM;AAAA;AAAA;AAlFV;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/src/index.ts
DELETED
package/src/loader.ts
DELETED
|
@@ -1,107 +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
|
-
let hasPatched = false
|
|
20
|
-
|
|
21
|
-
process.env.TAMAGUI_TARGET = 'web'
|
|
22
|
-
|
|
23
|
-
export function loader(this: any, source: string) {
|
|
24
|
-
this.cacheable()
|
|
25
|
-
const callback = this.async()
|
|
26
|
-
|
|
27
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
28
|
-
patchReactNativeWeb()
|
|
29
|
-
hasPatched = true
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const threaded = this.emitFile === undefined
|
|
34
|
-
const options: TamaguiOptions = { ...getOptions(this) }
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
options.disableExtraction &&
|
|
38
|
-
(options.disableDebugAttr || process.env.NODE_ENV !== 'development')
|
|
39
|
-
) {
|
|
40
|
-
if (!hasLogged) {
|
|
41
|
-
console.log('🥚 Tamagui disableDebug & disableExtraction set, no parsing running')
|
|
42
|
-
hasLogged = true
|
|
43
|
-
}
|
|
44
|
-
return callback(null, source)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const sourcePath = `${this.resourcePath}`
|
|
48
|
-
const startsWithComment = source[0] === '/' && source[1] === '/'
|
|
49
|
-
const shouldPrintDebug =
|
|
50
|
-
(!!process.env.DEBUG &&
|
|
51
|
-
(process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||
|
|
52
|
-
// supports esbuild style //! comments
|
|
53
|
-
(startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))
|
|
54
|
-
|
|
55
|
-
// if outputted css
|
|
56
|
-
if (options.cssPath || options.cssData) {
|
|
57
|
-
const out = options.cssData
|
|
58
|
-
? Buffer.from(options.cssData, 'base64').toString('utf-8')
|
|
59
|
-
: stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath)
|
|
60
|
-
if (!out) {
|
|
61
|
-
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`)
|
|
62
|
-
}
|
|
63
|
-
return callback(null, out)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// check if should ignore
|
|
67
|
-
const ext = extname(sourcePath)
|
|
68
|
-
if (
|
|
69
|
-
(ext !== '.tsx' && ext !== '.jsx') ||
|
|
70
|
-
(startsWithComment &&
|
|
71
|
-
(source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore')))
|
|
72
|
-
) {
|
|
73
|
-
return callback(null, source)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`
|
|
77
|
-
const extracted = extractToClassNames({
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
loader: this,
|
|
80
|
-
extractor,
|
|
81
|
-
source,
|
|
82
|
-
threaded,
|
|
83
|
-
sourcePath,
|
|
84
|
-
cssPath,
|
|
85
|
-
options,
|
|
86
|
-
shouldPrintDebug,
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
if (!extracted) {
|
|
90
|
-
return callback(null, source)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!threaded) {
|
|
94
|
-
if (extracted.stylesPath) {
|
|
95
|
-
stylePathToFilePath.set(extracted.stylesPath, sourcePath)
|
|
96
|
-
}
|
|
97
|
-
if (extracted.styles) {
|
|
98
|
-
stylesByFile.set(sourcePath, extracted.styles)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
callback(null, extracted.js, extracted.map)
|
|
103
|
-
} catch (err) {
|
|
104
|
-
console.error('ERROR', err)
|
|
105
|
-
return callback(null, source)
|
|
106
|
-
}
|
|
107
|
-
}
|