tamagui-loader 1.0.0-alpha.0 → 1.0.0-alpha.12
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/LICENSE +21 -0
- package/dist/cjs/index.js +14 -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 +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/loader.js +79 -0
- package/dist/esm/loader.js.map +7 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +2 -2
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/loader.js +78 -0
- package/dist/loader.js +6 -6
- package/dist/loader.js.map +2 -2
- package/package.json +11 -10
- package/src/loader.ts +10 -9
- 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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
__markAsModule(target);
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
__export(exports, {
|
|
9
|
+
default: () => src_default
|
|
10
|
+
});
|
|
11
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
12
|
+
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
13
|
+
var src_default = require("./loader").loader;
|
|
14
|
+
//# 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,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 __export = (target, all) => {
|
|
24
|
+
__markAsModule(target);
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, module2, desc) => {
|
|
29
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(module2))
|
|
31
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
32
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __toModule = (module2) => {
|
|
37
|
+
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);
|
|
38
|
+
};
|
|
39
|
+
__export(exports, {
|
|
40
|
+
loader: () => loader
|
|
41
|
+
});
|
|
42
|
+
var import_static = __toModule(require("@tamagui/static"));
|
|
43
|
+
var import_loader_utils = __toModule(require("loader-utils"));
|
|
44
|
+
Error.stackTraceLimit = Infinity;
|
|
45
|
+
const extractor = (0, import_static.createExtractor)();
|
|
46
|
+
const stylesByFile = new Map();
|
|
47
|
+
const stylePathToFilePath = 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
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 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 // @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;AAAA;AAAA;AAEA,oBAKO;AACP,0BAA2B;AAE3B,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,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,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
|
+
"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,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 = new Map();
|
|
12
|
+
const stylePathToFilePath = 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
|
+
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 = { ...getOptions(this) };
|
|
27
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
28
|
+
if (!hasLogged) {
|
|
29
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
30
|
+
hasLogged = true;
|
|
31
|
+
}
|
|
32
|
+
return callback(null, source);
|
|
33
|
+
}
|
|
34
|
+
const sourcePath = `${this.resourcePath}`;
|
|
35
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
36
|
+
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
|
+
if (options.cssPath || options.cssData) {
|
|
38
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath);
|
|
39
|
+
if (!out) {
|
|
40
|
+
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
41
|
+
}
|
|
42
|
+
return callback(null, out);
|
|
43
|
+
}
|
|
44
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
45
|
+
return callback(null, source);
|
|
46
|
+
}
|
|
47
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
48
|
+
const extracted = extractToClassNames({
|
|
49
|
+
loader: this,
|
|
50
|
+
extractor,
|
|
51
|
+
source,
|
|
52
|
+
threaded,
|
|
53
|
+
sourcePath,
|
|
54
|
+
cssPath,
|
|
55
|
+
options,
|
|
56
|
+
shouldPrintDebug
|
|
57
|
+
});
|
|
58
|
+
if (!extracted) {
|
|
59
|
+
return callback(null, source);
|
|
60
|
+
}
|
|
61
|
+
if (!threaded) {
|
|
62
|
+
if (extracted.stylesPath) {
|
|
63
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
64
|
+
}
|
|
65
|
+
if (extracted.styles) {
|
|
66
|
+
stylesByFile.set(sourcePath, extracted.styles);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
callback(null, extracted.js, extracted.map);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error("ERROR", err);
|
|
72
|
+
return callback(null, source);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
__name(loader, "loader");
|
|
76
|
+
export {
|
|
77
|
+
loader
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 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 // @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": ";;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,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,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,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
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -48,15 +48,16 @@ __export(loader_exports, {
|
|
|
48
48
|
function loader(source) {
|
|
49
49
|
this.cacheable();
|
|
50
50
|
const callback = this.async();
|
|
51
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {
|
|
51
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
52
52
|
(0, import_static.patchReactNativeWeb)();
|
|
53
|
+
hasPatched = true;
|
|
53
54
|
}
|
|
54
55
|
try {
|
|
55
56
|
const threaded = this.emitFile === void 0;
|
|
56
57
|
const options = __spreadValues({}, (0, import_loader_utils.getOptions)(this));
|
|
57
|
-
if (options.disableExtraction) {
|
|
58
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
58
59
|
if (!hasLogged) {
|
|
59
|
-
console.log("\u{1F95A} Tamagui disableExtraction set
|
|
60
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
60
61
|
hasLogged = true;
|
|
61
62
|
}
|
|
62
63
|
return callback(null, source);
|
|
@@ -71,8 +72,7 @@ function loader(source) {
|
|
|
71
72
|
}
|
|
72
73
|
return callback(null, out);
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
if (!isTamaguiInternalView && ((0, import_path.extname)(sourcePath) !== ".tsx" || startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore")))) {
|
|
75
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
76
76
|
return callback(null, source);
|
|
77
77
|
}
|
|
78
78
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
@@ -103,10 +103,9 @@ function loader(source) {
|
|
|
103
103
|
return callback(null, source);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
var
|
|
106
|
+
var import_static, import_loader_utils, extractor, stylesByFile, stylePathToFilePath, index, hasLogged, hasPatched;
|
|
107
107
|
var init_loader = __esm({
|
|
108
108
|
"src/loader.ts"() {
|
|
109
|
-
import_path = __toModule(require("path"));
|
|
110
109
|
import_static = __toModule(require("@tamagui/static"));
|
|
111
110
|
import_loader_utils = __toModule(require("loader-utils"));
|
|
112
111
|
Error.stackTraceLimit = Infinity;
|
|
@@ -115,6 +114,7 @@ var init_loader = __esm({
|
|
|
115
114
|
stylePathToFilePath = new Map();
|
|
116
115
|
index = 0;
|
|
117
116
|
hasLogged = false;
|
|
117
|
+
hasPatched = false;
|
|
118
118
|
process.env.TAMAGUI_TARGET = "web";
|
|
119
119
|
__name(loader, "loader");
|
|
120
120
|
}
|
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\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) {\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
|
|
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\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 // @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,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,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;AAtG1B,IAEA,eAMA,qBAGM,WAEA,cACA,qBAEF,OACA,WACA;AAlBJ;AAAA;AAEA,oBAKO;AACP,0BAA2B;AAE3B,UAAM,kBAAkB;AACxB,IAAM,YAAY;AAElB,IAAM,eAAe,IAAI;AACzB,IAAM,sBAAsB,IAAI;AAEhC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,YAAQ,IAAI,iBAAiB;AAEb;AAAA;AAAA;;;ACtBhB;AAAA;AAAA;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,gCAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 = new Map();
|
|
12
|
+
const stylePathToFilePath = 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
|
+
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 = { ...getOptions(this) };
|
|
27
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
28
|
+
if (!hasLogged) {
|
|
29
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
30
|
+
hasLogged = true;
|
|
31
|
+
}
|
|
32
|
+
return callback(null, source);
|
|
33
|
+
}
|
|
34
|
+
const sourcePath = `${this.resourcePath}`;
|
|
35
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
36
|
+
const shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
|
+
if (options.cssPath || options.cssData) {
|
|
38
|
+
const out = options.cssData ? Buffer.from(options.cssData, "base64").toString("utf-8") : stylesByFile.get(stylePathToFilePath.get(sourcePath) ?? sourcePath);
|
|
39
|
+
if (!out) {
|
|
40
|
+
console.warn(`no styles... ${stylesByFile.keys} ${sourcePath}`);
|
|
41
|
+
}
|
|
42
|
+
return callback(null, out);
|
|
43
|
+
}
|
|
44
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
45
|
+
return callback(null, source);
|
|
46
|
+
}
|
|
47
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
48
|
+
const extracted = extractToClassNames({
|
|
49
|
+
loader: this,
|
|
50
|
+
extractor,
|
|
51
|
+
source,
|
|
52
|
+
threaded,
|
|
53
|
+
sourcePath,
|
|
54
|
+
cssPath,
|
|
55
|
+
options,
|
|
56
|
+
shouldPrintDebug
|
|
57
|
+
});
|
|
58
|
+
if (!extracted) {
|
|
59
|
+
return callback(null, source);
|
|
60
|
+
}
|
|
61
|
+
if (!threaded) {
|
|
62
|
+
if (extracted.stylesPath) {
|
|
63
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
64
|
+
}
|
|
65
|
+
if (extracted.styles) {
|
|
66
|
+
stylesByFile.set(sourcePath, extracted.styles);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
callback(null, extracted.js, extracted.map);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error("ERROR", err);
|
|
72
|
+
return callback(null, source);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
__name(loader, "loader");
|
|
76
|
+
export {
|
|
77
|
+
loader
|
|
78
|
+
};
|
package/dist/loader.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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,
|
|
@@ -13,19 +12,21 @@ const stylesByFile = new Map();
|
|
|
13
12
|
const stylePathToFilePath = new Map();
|
|
14
13
|
let index = 0;
|
|
15
14
|
let hasLogged = false;
|
|
15
|
+
let hasPatched = false;
|
|
16
16
|
process.env.TAMAGUI_TARGET = "web";
|
|
17
17
|
function loader(source) {
|
|
18
18
|
this.cacheable();
|
|
19
19
|
const callback = this.async();
|
|
20
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {
|
|
20
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
21
21
|
patchReactNativeWeb();
|
|
22
|
+
hasPatched = true;
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
25
|
const threaded = this.emitFile === void 0;
|
|
25
26
|
const options = { ...getOptions(this) };
|
|
26
|
-
if (options.disableExtraction) {
|
|
27
|
+
if (options.disableExtraction && (options.disableDebugAttr || process.env.NODE_ENV !== "development")) {
|
|
27
28
|
if (!hasLogged) {
|
|
28
|
-
console.log("\u{1F95A} Tamagui disableExtraction set
|
|
29
|
+
console.log("\u{1F95A} Tamagui disableDebug & disableExtraction set, no parsing running");
|
|
29
30
|
hasLogged = true;
|
|
30
31
|
}
|
|
31
32
|
return callback(null, source);
|
|
@@ -40,8 +41,7 @@ function loader(source) {
|
|
|
40
41
|
}
|
|
41
42
|
return callback(null, out);
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
if (!isTamaguiInternalView && (extname(sourcePath) !== ".tsx" || startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore")))) {
|
|
44
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
45
45
|
return callback(null, source);
|
|
46
46
|
}
|
|
47
47
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
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\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) {\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
|
|
5
|
-
"mappings": ";;
|
|
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 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 // @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": ";;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,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,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,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,30 @@
|
|
|
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.12",
|
|
4
|
+
"typings": "types",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"module:jsx": "dist/_jsx",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"src"
|
|
9
|
+
"types",
|
|
10
|
+
"src",
|
|
11
|
+
"dist"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "tamagui-build",
|
|
14
15
|
"watch": "tamagui-build --watch"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@tamagui/static": "^1.0.0-alpha.
|
|
18
|
+
"@tamagui/static": "^1.0.0-alpha.12",
|
|
18
19
|
"fs-extra": "^9.1.0",
|
|
19
20
|
"loader-utils": "^2.0.0",
|
|
20
21
|
"lodash": "^4.17.21"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
24
|
+
"@tamagui/build": "^1.0.0-alpha.12"
|
|
24
25
|
},
|
|
25
26
|
"publishConfig": {
|
|
26
27
|
"access": "public"
|
|
27
28
|
},
|
|
28
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d50261a4e08d2212395af4f2d8f49555fc780c3e"
|
|
29
30
|
}
|
package/src/loader.ts
CHANGED
|
@@ -16,6 +16,7 @@ const stylePathToFilePath = new Map<string, string>()
|
|
|
16
16
|
|
|
17
17
|
let index = 0
|
|
18
18
|
let hasLogged = false
|
|
19
|
+
let hasPatched = false
|
|
19
20
|
|
|
20
21
|
process.env.TAMAGUI_TARGET = 'web'
|
|
21
22
|
|
|
@@ -23,17 +24,21 @@ export function loader(this: any, source: string) {
|
|
|
23
24
|
this.cacheable()
|
|
24
25
|
const callback = this.async()
|
|
25
26
|
|
|
26
|
-
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH) {
|
|
27
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
27
28
|
patchReactNativeWeb()
|
|
29
|
+
hasPatched = true
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
try {
|
|
31
33
|
const threaded = this.emitFile === undefined
|
|
32
34
|
const options: TamaguiOptions = { ...getOptions(this) }
|
|
33
35
|
|
|
34
|
-
if (
|
|
36
|
+
if (
|
|
37
|
+
options.disableExtraction &&
|
|
38
|
+
(options.disableDebugAttr || process.env.NODE_ENV !== 'development')
|
|
39
|
+
) {
|
|
35
40
|
if (!hasLogged) {
|
|
36
|
-
console.log('🥚 Tamagui disableExtraction set
|
|
41
|
+
console.log('🥚 Tamagui disableDebug & disableExtraction set, no parsing running')
|
|
37
42
|
hasLogged = true
|
|
38
43
|
}
|
|
39
44
|
return callback(null, source)
|
|
@@ -59,13 +64,9 @@ export function loader(this: any, source: string) {
|
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
// check if should ignore
|
|
62
|
-
const isTamaguiInternalView = sourcePath.includes('/tamagui/')
|
|
63
|
-
|
|
64
67
|
if (
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
(startsWithComment &&
|
|
68
|
-
(source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))))
|
|
68
|
+
startsWithComment &&
|
|
69
|
+
(source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))
|
|
69
70
|
) {
|
|
70
71
|
return callback(null, source)
|
|
71
72
|
}
|
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":"AAsBA,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,OAkF/C"}
|