tamagui-loader 1.0.0-beta.187 → 1.0.0-beta.2
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/css.js +68 -0
- package/dist/cjs/css.js.map +7 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/loader.js +16 -27
- package/dist/cjs/loader.js.map +2 -2
- package/dist/esm/css.js +32 -0
- package/dist/esm/css.js.map +7 -0
- package/dist/esm/index.js +2 -6
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/loader.js +7 -26
- package/dist/esm/loader.js.map +2 -2
- package/dist/jsx/css.js +31 -0
- package/dist/jsx/index.js +2 -6
- package/dist/jsx/loader.js +7 -26
- package/package.json +4 -4
- package/types/css.d.ts +6 -0
- package/types/css.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/loader.d.ts.map +1 -1
- package/LICENSE +0 -21
package/dist/cjs/css.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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 css_exports = {};
|
|
34
|
+
__export(css_exports, {
|
|
35
|
+
default: () => loader,
|
|
36
|
+
extractedInfoByFile: () => extractedInfoByFile,
|
|
37
|
+
stylePathToFilePath: () => stylePathToFilePath
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(css_exports);
|
|
40
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
41
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
42
|
+
function loader(source) {
|
|
43
|
+
this.async();
|
|
44
|
+
const options = __spreadValues({}, this.getOptions());
|
|
45
|
+
const sourcePath = `${this.resourcePath}`;
|
|
46
|
+
let out = "";
|
|
47
|
+
if (options.cssPath) {
|
|
48
|
+
const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath;
|
|
49
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
50
|
+
stylePathToFilePath.delete(sourcePath);
|
|
51
|
+
extractedInfoByFile.delete(pathKey);
|
|
52
|
+
const out2 = info == null ? void 0 : info.styles;
|
|
53
|
+
return this.callback(null, out2 || "");
|
|
54
|
+
} else if (options.cssData) {
|
|
55
|
+
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
56
|
+
}
|
|
57
|
+
if (options.cssData || options.cssPath) {
|
|
58
|
+
return this.callback(null, out || "");
|
|
59
|
+
}
|
|
60
|
+
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
61
|
+
}
|
|
62
|
+
__name(loader, "loader");
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
extractedInfoByFile,
|
|
66
|
+
stylePathToFilePath
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/css.ts"],
|
|
4
|
+
"sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>, source: string) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\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 const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (options.cssData || options.cssPath) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,gBAA0C,QAAgB;AACvE,OAAK,MAAM;AACX,QAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,oBAAoB,IAAI,UAAU,KAAK;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,QAAQ,WAAW,QAAQ,SAAS;AAEtC,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;AAvBwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -26,13 +26,13 @@ process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
|
26
26
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
27
27
|
var src_default = require("./loader").loader;
|
|
28
28
|
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
29
|
-
if (path.includes("react-native-reanimated")) {
|
|
29
|
+
if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
if (!shouldInclude) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
32
|
+
return true;
|
|
37
33
|
}, "shouldExclude");
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
shouldExclude
|
|
37
|
+
});
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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')
|
|
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,
|
|
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 (\n path.includes('react-native-reanimated') ||\n path.includes('react-native-gesture-handler') ||\n path.includes(projectRoot) ||\n path.includes('/dist/jsx/')\n ) {\n return false\n }\n return true\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,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAV6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/loader.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -29,6 +31,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
31
|
}
|
|
30
32
|
return to;
|
|
31
33
|
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
32
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
36
|
var loader_exports = {};
|
|
34
37
|
__export(loader_exports, {
|
|
@@ -36,17 +39,16 @@ __export(loader_exports, {
|
|
|
36
39
|
});
|
|
37
40
|
module.exports = __toCommonJS(loader_exports);
|
|
38
41
|
var import_static = require("@tamagui/static");
|
|
42
|
+
var import_css = require("./css");
|
|
39
43
|
Error.stackTraceLimit = Infinity;
|
|
40
44
|
const extractor = (0, import_static.createExtractor)();
|
|
41
|
-
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
42
|
-
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
43
45
|
let index = 0;
|
|
44
46
|
let hasLogged = false;
|
|
45
47
|
let hasPatched = false;
|
|
46
48
|
process.env.TAMAGUI_TARGET = "web";
|
|
47
49
|
function loader(source) {
|
|
48
50
|
this.cacheable();
|
|
49
|
-
|
|
51
|
+
this.async();
|
|
50
52
|
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
51
53
|
(0, import_static.patchReactNativeWeb)();
|
|
52
54
|
hasPatched = true;
|
|
@@ -54,37 +56,20 @@ function loader(source) {
|
|
|
54
56
|
try {
|
|
55
57
|
const threaded = this.emitFile === void 0;
|
|
56
58
|
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
59
|
const sourcePath = `${this.resourcePath}`;
|
|
65
60
|
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
66
61
|
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
67
62
|
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
68
63
|
shouldPrintDebug = "verbose";
|
|
69
64
|
}
|
|
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
65
|
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
82
|
-
return callback(null, source);
|
|
66
|
+
return this.callback(null, source);
|
|
83
67
|
}
|
|
84
68
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
85
69
|
const extracted = (0, import_static.extractToClassNames)({
|
|
86
70
|
loader: this,
|
|
87
71
|
extractor,
|
|
72
|
+
cssLoaderPath: require.resolve("./css"),
|
|
88
73
|
source,
|
|
89
74
|
threaded,
|
|
90
75
|
sourcePath,
|
|
@@ -93,19 +78,23 @@ function loader(source) {
|
|
|
93
78
|
shouldPrintDebug
|
|
94
79
|
});
|
|
95
80
|
if (!extracted) {
|
|
96
|
-
return callback(null, source);
|
|
81
|
+
return this.callback(null, source);
|
|
97
82
|
}
|
|
98
|
-
extractedInfoByFile.set(sourcePath, extracted);
|
|
83
|
+
import_css.extractedInfoByFile.set(sourcePath, extracted);
|
|
99
84
|
if (!threaded) {
|
|
100
85
|
if (extracted.stylesPath) {
|
|
101
|
-
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
86
|
+
import_css.stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
102
87
|
}
|
|
103
88
|
}
|
|
104
|
-
callback(null, extracted.js, extracted.map);
|
|
89
|
+
this.callback(null, extracted.js, extracted.map);
|
|
105
90
|
} catch (err) {
|
|
106
91
|
console.error("ERROR", err);
|
|
107
|
-
return callback(null, source);
|
|
92
|
+
return this.callback(null, source);
|
|
108
93
|
}
|
|
109
94
|
}
|
|
110
95
|
__name(loader, "loader");
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
loader
|
|
99
|
+
});
|
|
111
100
|
//# sourceMappingURL=loader.js.map
|
package/dist/cjs/loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n ExtractedResponse,\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\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 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 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 // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n cssLoaderPath: require.resolve('./css'),\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.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 this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAMO;AAGP,iBAAyD;AAEzD,MAAM,kBAAkB;AACxB,MAAM,YAAY,mCAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA0C,QAAgB;AAC/D,OAAK,UAAU;AACf,OAAK,MAAM;AAEX,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,2CAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,uCAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,eAA+B;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,mCAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,uCAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;AAhEgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/css.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
4
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
5
|
+
function loader(source) {
|
|
6
|
+
var _a;
|
|
7
|
+
this.async();
|
|
8
|
+
const options = { ...this.getOptions() };
|
|
9
|
+
const sourcePath = `${this.resourcePath}`;
|
|
10
|
+
let out = "";
|
|
11
|
+
if (options.cssPath) {
|
|
12
|
+
const pathKey = (_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath;
|
|
13
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
14
|
+
stylePathToFilePath.delete(sourcePath);
|
|
15
|
+
extractedInfoByFile.delete(pathKey);
|
|
16
|
+
const out2 = info == null ? void 0 : info.styles;
|
|
17
|
+
return this.callback(null, out2 || "");
|
|
18
|
+
} else if (options.cssData) {
|
|
19
|
+
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
20
|
+
}
|
|
21
|
+
if (options.cssData || options.cssPath) {
|
|
22
|
+
return this.callback(null, out || "");
|
|
23
|
+
}
|
|
24
|
+
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
25
|
+
}
|
|
26
|
+
__name(loader, "loader");
|
|
27
|
+
export {
|
|
28
|
+
loader as default,
|
|
29
|
+
extractedInfoByFile,
|
|
30
|
+
stylePathToFilePath
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/css.ts"],
|
|
4
|
+
"sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>, source: string) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\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 const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (options.cssData || options.cssPath) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
|
|
5
|
+
"mappings": ";;AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,gBAA0C,QAAgB;AANzE;AAOE,OAAK,MAAM;AACX,QAAM,UAA0B,KAAK,KAAK,WAAW,EAAE;AACvD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,0BAAoB,IAAI,UAAU,MAAlC,YAAuC;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,QAAQ,WAAW,QAAQ,SAAS;AAEtC,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;AAvBwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,14 +4,10 @@ process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
|
4
4
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
5
5
|
var src_default = require("./loader").loader;
|
|
6
6
|
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
7
|
-
if (path.includes("react-native-reanimated")) {
|
|
7
|
+
if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
if (!shouldInclude) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
10
|
+
return true;
|
|
15
11
|
}, "shouldExclude");
|
|
16
12
|
export {
|
|
17
13
|
src_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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')
|
|
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,
|
|
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 (\n path.includes('react-native-reanimated') ||\n path.includes('react-native-gesture-handler') ||\n path.includes(projectRoot) ||\n path.includes('/dist/jsx/')\n ) {\n return false\n }\n return true\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,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAV6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,18 +5,16 @@ import {
|
|
|
5
5
|
extractToClassNames,
|
|
6
6
|
patchReactNativeWeb
|
|
7
7
|
} from "@tamagui/static";
|
|
8
|
+
import { extractedInfoByFile, stylePathToFilePath } from "./css";
|
|
8
9
|
Error.stackTraceLimit = Infinity;
|
|
9
10
|
const extractor = createExtractor();
|
|
10
|
-
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
11
|
-
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
12
11
|
let index = 0;
|
|
13
12
|
let hasLogged = false;
|
|
14
13
|
let hasPatched = false;
|
|
15
14
|
process.env.TAMAGUI_TARGET = "web";
|
|
16
15
|
function loader(source) {
|
|
17
|
-
var _a;
|
|
18
16
|
this.cacheable();
|
|
19
|
-
|
|
17
|
+
this.async();
|
|
20
18
|
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
21
19
|
patchReactNativeWeb();
|
|
22
20
|
hasPatched = true;
|
|
@@ -24,37 +22,20 @@ function loader(source) {
|
|
|
24
22
|
try {
|
|
25
23
|
const threaded = this.emitFile === void 0;
|
|
26
24
|
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
25
|
const sourcePath = `${this.resourcePath}`;
|
|
35
26
|
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
36
27
|
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
28
|
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
38
29
|
shouldPrintDebug = "verbose";
|
|
39
30
|
}
|
|
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
31
|
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
52
|
-
return callback(null, source);
|
|
32
|
+
return this.callback(null, source);
|
|
53
33
|
}
|
|
54
34
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
55
35
|
const extracted = extractToClassNames({
|
|
56
36
|
loader: this,
|
|
57
37
|
extractor,
|
|
38
|
+
cssLoaderPath: require.resolve("./css"),
|
|
58
39
|
source,
|
|
59
40
|
threaded,
|
|
60
41
|
sourcePath,
|
|
@@ -63,7 +44,7 @@ function loader(source) {
|
|
|
63
44
|
shouldPrintDebug
|
|
64
45
|
});
|
|
65
46
|
if (!extracted) {
|
|
66
|
-
return callback(null, source);
|
|
47
|
+
return this.callback(null, source);
|
|
67
48
|
}
|
|
68
49
|
extractedInfoByFile.set(sourcePath, extracted);
|
|
69
50
|
if (!threaded) {
|
|
@@ -71,10 +52,10 @@ function loader(source) {
|
|
|
71
52
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
72
53
|
}
|
|
73
54
|
}
|
|
74
|
-
callback(null, extracted.js, extracted.map);
|
|
55
|
+
this.callback(null, extracted.js, extracted.map);
|
|
75
56
|
} catch (err) {
|
|
76
57
|
console.error("ERROR", err);
|
|
77
|
-
return callback(null, source);
|
|
58
|
+
return this.callback(null, source);
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
61
|
__name(loader, "loader");
|
package/dist/esm/loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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\
|
|
5
|
-
"mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,
|
|
4
|
+
"sourcesContent": ["import {\n ExtractedResponse,\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\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 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 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 // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n cssLoaderPath: require.resolve('./css'),\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.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 this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;AAEA,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,YAAY;AAChB,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA0C,QAAgB;AAC/D,OAAK,UAAU;AACf,OAAK,MAAM;AAEX,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,wBAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,KAAK,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,oBAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,eAA+B;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,wBAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;AAhEgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/css.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
4
|
+
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
5
|
+
function loader(source) {
|
|
6
|
+
var _a;
|
|
7
|
+
this.async();
|
|
8
|
+
const options = { ...this.getOptions() };
|
|
9
|
+
const sourcePath = `${this.resourcePath}`;
|
|
10
|
+
let out = "";
|
|
11
|
+
if (options.cssPath) {
|
|
12
|
+
const pathKey = (_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath;
|
|
13
|
+
const info = extractedInfoByFile.get(pathKey);
|
|
14
|
+
stylePathToFilePath.delete(sourcePath);
|
|
15
|
+
extractedInfoByFile.delete(pathKey);
|
|
16
|
+
const out2 = info == null ? void 0 : info.styles;
|
|
17
|
+
return this.callback(null, out2 || "");
|
|
18
|
+
} else if (options.cssData) {
|
|
19
|
+
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
20
|
+
}
|
|
21
|
+
if (options.cssData || options.cssPath) {
|
|
22
|
+
return this.callback(null, out || "");
|
|
23
|
+
}
|
|
24
|
+
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
25
|
+
}
|
|
26
|
+
__name(loader, "loader");
|
|
27
|
+
export {
|
|
28
|
+
loader as default,
|
|
29
|
+
extractedInfoByFile,
|
|
30
|
+
stylePathToFilePath
|
|
31
|
+
};
|
package/dist/jsx/index.js
CHANGED
|
@@ -4,14 +4,10 @@ process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
|
4
4
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
5
5
|
var src_default = require("./loader").loader;
|
|
6
6
|
const shouldExclude = /* @__PURE__ */ __name((path, projectRoot, tamaguiOptions) => {
|
|
7
|
-
if (path.includes("react-native-reanimated")) {
|
|
7
|
+
if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
if (!shouldInclude) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
10
|
+
return true;
|
|
15
11
|
}, "shouldExclude");
|
|
16
12
|
export {
|
|
17
13
|
src_default as default,
|
package/dist/jsx/loader.js
CHANGED
|
@@ -5,18 +5,16 @@ import {
|
|
|
5
5
|
extractToClassNames,
|
|
6
6
|
patchReactNativeWeb
|
|
7
7
|
} from "@tamagui/static";
|
|
8
|
+
import { extractedInfoByFile, stylePathToFilePath } from "./css";
|
|
8
9
|
Error.stackTraceLimit = Infinity;
|
|
9
10
|
const extractor = createExtractor();
|
|
10
|
-
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
11
|
-
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
12
11
|
let index = 0;
|
|
13
12
|
let hasLogged = false;
|
|
14
13
|
let hasPatched = false;
|
|
15
14
|
process.env.TAMAGUI_TARGET = "web";
|
|
16
15
|
function loader(source) {
|
|
17
|
-
var _a;
|
|
18
16
|
this.cacheable();
|
|
19
|
-
|
|
17
|
+
this.async();
|
|
20
18
|
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
21
19
|
patchReactNativeWeb();
|
|
22
20
|
hasPatched = true;
|
|
@@ -24,37 +22,20 @@ function loader(source) {
|
|
|
24
22
|
try {
|
|
25
23
|
const threaded = this.emitFile === void 0;
|
|
26
24
|
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
25
|
const sourcePath = `${this.resourcePath}`;
|
|
35
26
|
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
36
27
|
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
37
28
|
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
38
29
|
shouldPrintDebug = "verbose";
|
|
39
30
|
}
|
|
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
31
|
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
52
|
-
return callback(null, source);
|
|
32
|
+
return this.callback(null, source);
|
|
53
33
|
}
|
|
54
34
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
55
35
|
const extracted = extractToClassNames({
|
|
56
36
|
loader: this,
|
|
57
37
|
extractor,
|
|
38
|
+
cssLoaderPath: require.resolve("./css"),
|
|
58
39
|
source,
|
|
59
40
|
threaded,
|
|
60
41
|
sourcePath,
|
|
@@ -63,7 +44,7 @@ function loader(source) {
|
|
|
63
44
|
shouldPrintDebug
|
|
64
45
|
});
|
|
65
46
|
if (!extracted) {
|
|
66
|
-
return callback(null, source);
|
|
47
|
+
return this.callback(null, source);
|
|
67
48
|
}
|
|
68
49
|
extractedInfoByFile.set(sourcePath, extracted);
|
|
69
50
|
if (!threaded) {
|
|
@@ -71,10 +52,10 @@ function loader(source) {
|
|
|
71
52
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
72
53
|
}
|
|
73
54
|
}
|
|
74
|
-
callback(null, extracted.js, extracted.map);
|
|
55
|
+
this.callback(null, extracted.js, extracted.map);
|
|
75
56
|
} catch (err) {
|
|
76
57
|
console.error("ERROR", err);
|
|
77
|
-
return callback(null, source);
|
|
58
|
+
return this.callback(null, source);
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
61
|
__name(loader, "loader");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamagui-loader",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"typings": "types",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"clean:build": "tamagui-build clean:build"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tamagui/static": "^1.0.0-beta.
|
|
19
|
+
"@tamagui/static": "^1.0.0-beta.2",
|
|
20
20
|
"fs-extra": "^9.1.0",
|
|
21
21
|
"lodash": "^4.17.21"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "^1.0.0-beta.
|
|
24
|
+
"@tamagui/build": "^1.0.0-beta.2"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
|
|
30
30
|
}
|
package/types/css.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExtractedResponse } from '@tamagui/static';
|
|
2
|
+
import { LoaderContext } from 'webpack';
|
|
3
|
+
export declare const extractedInfoByFile: Map<string, ExtractedResponse>;
|
|
4
|
+
export declare const stylePathToFilePath: Map<string, string>;
|
|
5
|
+
export default function loader(this: LoaderContext<any>, source: string): void;
|
|
6
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,mBAAmB,gCAAuC,CAAA;AACvE,eAAO,MAAM,mBAAmB,qBAA4B,CAAA;AAE5D,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,QAuBtE"}
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,YAUnF,CAAA"}
|
package/types/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAavC,wBAAgB,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,QAgE9D"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|