tamagui-loader 1.0.1-beta.21 → 1.0.1-beta.210
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 +4 -19
- package/dist/cjs/css.js.map +3 -3
- package/dist/cjs/index.js +15 -4
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/loader.js +41 -43
- package/dist/cjs/loader.js.map +3 -3
- package/dist/esm/css.js +3 -7
- package/dist/esm/css.js.map +3 -3
- package/dist/esm/index.js +8 -5
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/loader.js +36 -29
- package/dist/esm/loader.js.map +3 -3
- package/dist/jsx/css.js +5 -8
- package/dist/jsx/css.js.map +7 -0
- package/dist/jsx/index.js +9 -5
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/loader.js +37 -29
- package/dist/jsx/loader.js.map +7 -0
- package/package.json +9 -5
- package/src/css.ts +30 -0
- package/src/index.ts +26 -0
- package/src/loader.ts +91 -0
- package/types/css.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/loader.d.ts +2 -2
- package/types/css.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/loader.d.ts.map +0 -1
package/dist/cjs/css.js
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
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
6
|
var __export = (target, all) => {
|
|
21
7
|
for (var name in all)
|
|
22
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -39,9 +25,9 @@ __export(css_exports, {
|
|
|
39
25
|
module.exports = __toCommonJS(css_exports);
|
|
40
26
|
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
41
27
|
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
42
|
-
function loader(
|
|
28
|
+
function loader() {
|
|
43
29
|
this.async();
|
|
44
|
-
const options =
|
|
30
|
+
const options = { ...this.getOptions() };
|
|
45
31
|
const sourcePath = `${this.resourcePath}`;
|
|
46
32
|
let out = "";
|
|
47
33
|
if (options.cssPath) {
|
|
@@ -54,12 +40,11 @@ function loader(source) {
|
|
|
54
40
|
} else if (options.cssData) {
|
|
55
41
|
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
56
42
|
}
|
|
57
|
-
if (
|
|
43
|
+
if (out) {
|
|
58
44
|
return this.callback(null, out || "");
|
|
59
45
|
}
|
|
60
46
|
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
61
47
|
}
|
|
62
|
-
__name(loader, "loader");
|
|
63
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
49
|
0 && (module.exports = {
|
|
65
50
|
extractedInfoByFile,
|
package/dist/cjs/css.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
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>) {\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 (out) {\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,SAAR,SAAkD;AACvD,OAAK,MAAM;AACX,QAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,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,UAAMA,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAMA,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
|
|
6
|
+
"names": ["out"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
8
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
18
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
25
|
var src_exports = {};
|
|
20
26
|
__export(src_exports, {
|
|
@@ -22,15 +28,20 @@ __export(src_exports, {
|
|
|
22
28
|
shouldExclude: () => shouldExclude
|
|
23
29
|
});
|
|
24
30
|
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_path = __toESM(require("path"));
|
|
25
32
|
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
26
33
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
34
|
+
process.env.IS_STATIC = "is_static";
|
|
27
35
|
var src_default = require("./loader").loader;
|
|
28
|
-
const shouldExclude =
|
|
29
|
-
if (
|
|
36
|
+
const shouldExclude = (filePath, projectRoot) => {
|
|
37
|
+
if (filePath.includes("react-native-web") || filePath.includes("react-native-gesture-handler") || filePath.includes("@gorhom") || filePath.includes(projectRoot) || isTamaguiDistJSX(filePath)) {
|
|
30
38
|
return false;
|
|
31
39
|
}
|
|
32
40
|
return true;
|
|
33
|
-
}
|
|
41
|
+
};
|
|
42
|
+
function isTamaguiDistJSX(filePath) {
|
|
43
|
+
return filePath.includes("/dist/jsx/".replace(/\//g, import_path.default.sep));
|
|
44
|
+
}
|
|
34
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
46
|
0 && (module.exports = {
|
|
36
47
|
shouldExclude
|
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": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nprocess.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\nprocess.env.IS_STATIC = 'is_static'\n\nexport default require('./loader').loader\n\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (filePath: string, projectRoot: string) => {\n if (\n filePath.includes('react-native-web') ||\n filePath.includes('react-native-gesture-handler') ||\n filePath.includes('@gorhom') ||\n filePath.includes(projectRoot) ||\n isTamaguiDistJSX(filePath)\n ) {\n return false\n }\n return true\n}\n\nfunction isTamaguiDistJSX(filePath: string) {\n return filePath.includes('/dist/jsx/'.replace(/\\//g, path.sep))\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AACtC,QAAQ,IAAI,YAAY;AAExB,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,UAAkB,gBAAwB;AACtE,MACE,SAAS,SAAS,kBAAkB,KACpC,SAAS,SAAS,8BAA8B,KAChD,SAAS,SAAS,SAAS,KAC3B,SAAS,SAAS,WAAW,KAC7B,iBAAiB,QAAQ,GACzB;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,UAAkB;AAC1C,SAAO,SAAS,SAAS,aAAa,QAAQ,OAAO,YAAAA,QAAK,GAAG,CAAC;AAChE;",
|
|
6
|
+
"names": ["path"]
|
|
7
7
|
}
|
package/dist/cjs/loader.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
22
8
|
var __export = (target, all) => {
|
|
23
9
|
for (var name in all)
|
|
24
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,54 +17,58 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
31
17
|
}
|
|
32
18
|
return to;
|
|
33
19
|
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
35
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
25
|
var loader_exports = {};
|
|
37
26
|
__export(loader_exports, {
|
|
38
27
|
loader: () => loader
|
|
39
28
|
});
|
|
40
29
|
module.exports = __toCommonJS(loader_exports);
|
|
30
|
+
var import_cli_color = require("@tamagui/cli-color");
|
|
41
31
|
var import_static = require("@tamagui/static");
|
|
42
32
|
var import_css = require("./css");
|
|
43
33
|
Error.stackTraceLimit = Infinity;
|
|
34
|
+
const CSS_LOADER_PATH = require.resolve("./css");
|
|
35
|
+
Error.stackTraceLimit = Infinity;
|
|
44
36
|
const extractor = (0, import_static.createExtractor)();
|
|
45
37
|
let index = 0;
|
|
46
|
-
let hasLogged = false;
|
|
47
|
-
let hasPatched = false;
|
|
48
38
|
process.env.TAMAGUI_TARGET = "web";
|
|
49
|
-
function
|
|
50
|
-
this.cacheable();
|
|
51
|
-
this.async();
|
|
52
|
-
|
|
53
|
-
(0, import_static.patchReactNativeWeb)();
|
|
54
|
-
hasPatched = true;
|
|
55
|
-
}
|
|
39
|
+
const loader = async function loader2(sourceIn) {
|
|
40
|
+
this.cacheable(true);
|
|
41
|
+
const callback = this.async();
|
|
42
|
+
const source = sourceIn.toString();
|
|
56
43
|
try {
|
|
57
44
|
const threaded = this.emitFile === void 0;
|
|
58
|
-
const options =
|
|
45
|
+
const options = { ...this.getOptions() };
|
|
59
46
|
const sourcePath = `${this.resourcePath}`;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return this.callback(null, source);
|
|
47
|
+
const { shouldDisable, shouldPrintDebug } = (0, import_static.getPragmaOptions)({ source, path: sourcePath });
|
|
48
|
+
if (shouldDisable) {
|
|
49
|
+
if (shouldPrintDebug) {
|
|
50
|
+
console.log(`Disabling on file via pragma`);
|
|
51
|
+
}
|
|
52
|
+
return callback(null, source);
|
|
67
53
|
}
|
|
68
54
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
69
|
-
const extracted = (0, import_static.extractToClassNames)({
|
|
70
|
-
loader: this,
|
|
55
|
+
const extracted = await (0, import_static.extractToClassNames)({
|
|
71
56
|
extractor,
|
|
72
|
-
cssLoaderPath: require.resolve("./css"),
|
|
73
57
|
source,
|
|
74
|
-
threaded,
|
|
75
58
|
sourcePath,
|
|
76
|
-
cssPath,
|
|
77
59
|
options,
|
|
78
60
|
shouldPrintDebug
|
|
79
61
|
});
|
|
80
62
|
if (!extracted) {
|
|
81
|
-
return
|
|
63
|
+
return callback(null, source);
|
|
64
|
+
}
|
|
65
|
+
if (extracted.styles) {
|
|
66
|
+
const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
67
|
+
const remReq = this.remainingRequest;
|
|
68
|
+
const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
|
|
69
|
+
extracted.js = `${extracted.js}
|
|
70
|
+
|
|
71
|
+
require(${JSON.stringify(importPath)})`;
|
|
82
72
|
}
|
|
83
73
|
import_css.extractedInfoByFile.set(sourcePath, extracted);
|
|
84
74
|
if (!threaded) {
|
|
@@ -86,13 +76,21 @@ function loader(source) {
|
|
|
86
76
|
import_css.stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
87
77
|
}
|
|
88
78
|
}
|
|
89
|
-
|
|
79
|
+
callback(null, extracted.js, extracted.map);
|
|
90
80
|
} catch (err) {
|
|
91
|
-
|
|
81
|
+
const message = err instanceof Error ? `${err.message}
|
|
82
|
+
${err.stack}` : String(err);
|
|
83
|
+
console.error("Tamagui Webpack Loader Error:\n", ` ${message}
|
|
84
|
+
`);
|
|
85
|
+
if (message.includes(`Cannot create proxy`)) {
|
|
86
|
+
console.log(
|
|
87
|
+
`This is usually due to components not loading at build-time. Check for logs just below the line above:`
|
|
88
|
+
);
|
|
89
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `"Tamagui built config and components"`);
|
|
90
|
+
}
|
|
92
91
|
return this.callback(null, source);
|
|
93
92
|
}
|
|
94
|
-
}
|
|
95
|
-
__name(loader, "loader");
|
|
93
|
+
};
|
|
96
94
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
95
|
0 && (module.exports = {
|
|
98
96
|
loader
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { Color, colorLog } from '@tamagui/cli-color'\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n getPragmaOptions,\n} from '@tamagui/static'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\nError.stackTraceLimit = Infinity\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader = async function loader(this, sourceIn: Buffer | string) {\n this.cacheable(true)\n const callback = this.async()\n const source = sourceIn.toString()\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath })\n\n if (shouldDisable) {\n if (shouldPrintDebug) {\n // eslint-disable-next-line no-console\n console.log(`Disabling on file via pragma`)\n }\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = await extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n // add import to css\n if (extracted.styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = this.remainingRequest\n const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`\n extracted.js = `${extracted.js}\\n\\nrequire(${JSON.stringify(importPath)})`\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 const message = err instanceof Error ? `${err.message}\\n${err.stack}` : String(err)\n\n // eslint-disable-next-line no-console\n console.error('Tamagui Webpack Loader Error:\\n', ` ${message}\\n`)\n\n if (message.includes(`Cannot create proxy`)) {\n // eslint-disable-next-line no-console\n console.log(\n `This is usually due to components not loading at build-time. Check for logs just below the line above:`\n )\n colorLog(Color.FgYellow, `\"Tamagui built config and components\"`)\n }\n\n return this.callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAChC,oBAKO;AAEP,iBAAyD;AAEzD,MAAM,kBAAkB;AAGxB,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,gBAAY,+BAAgB;AAElC,IAAI,QAAQ;AAEZ,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAS,eAAeA,QAAa,UAA2B;AAC3E,OAAK,UAAU,IAAI;AACnB,QAAM,WAAW,KAAK,MAAM;AAC5B,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,EAAE,eAAe,iBAAiB,QAAI,gCAAiB,EAAE,QAAQ,MAAM,WAAW,CAAC;AAEzF,QAAI,eAAe;AACjB,UAAI,kBAAkB;AAEpB,gBAAQ,IAAI,8BAA8B;AAAA,MAC5C;AACA,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,UAAM,mCAAoB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAGA,QAAI,UAAU,QAAQ;AACpB,YAAM,WAAW,WACb,WAAW,OAAO,KAAK,UAAU,MAAM,EAAE,SAAS,QAAQ,MAC1D,WAAW;AACf,YAAM,SAAS,KAAK;AACpB,YAAM,aAAa,GAAG,aAAa,mBAAmB,YAAY;AAClE,gBAAU,KAAK,GAAG,UAAU;AAAA;AAAA,UAAiB,KAAK,UAAU,UAAU;AAAA,IACxE;AAEA,mCAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,uCAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,aAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EAC5C,SAAS,KAAP;AACA,UAAM,UAAU,eAAe,QAAQ,GAAG,IAAI;AAAA,EAAY,IAAI,UAAU,OAAO,GAAG;AAGlF,YAAQ,MAAM,mCAAmC,KAAK;AAAA,CAAW;AAEjE,QAAI,QAAQ,SAAS,qBAAqB,GAAG;AAE3C,cAAQ;AAAA,QACN;AAAA,MACF;AACA,qCAAS,uBAAM,UAAU,uCAAuC;AAAA,IAClE;AAEA,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;",
|
|
6
|
+
"names": ["loader"]
|
|
7
7
|
}
|
package/dist/esm/css.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
4
2
|
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
5
|
-
function loader(
|
|
6
|
-
var _a;
|
|
3
|
+
function loader() {
|
|
7
4
|
this.async();
|
|
8
5
|
const options = { ...this.getOptions() };
|
|
9
6
|
const sourcePath = `${this.resourcePath}`;
|
|
10
7
|
let out = "";
|
|
11
8
|
if (options.cssPath) {
|
|
12
|
-
const pathKey =
|
|
9
|
+
const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath;
|
|
13
10
|
const info = extractedInfoByFile.get(pathKey);
|
|
14
11
|
stylePathToFilePath.delete(sourcePath);
|
|
15
12
|
extractedInfoByFile.delete(pathKey);
|
|
@@ -18,12 +15,11 @@ function loader(source) {
|
|
|
18
15
|
} else if (options.cssData) {
|
|
19
16
|
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
20
17
|
}
|
|
21
|
-
if (
|
|
18
|
+
if (out) {
|
|
22
19
|
return this.callback(null, out || "");
|
|
23
20
|
}
|
|
24
21
|
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
25
22
|
}
|
|
26
|
-
__name(loader, "loader");
|
|
27
23
|
export {
|
|
28
24
|
loader as default,
|
|
29
25
|
extractedInfoByFile,
|
package/dist/esm/css.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
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>) {\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 (out) {\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,SAAR,SAAkD;AACvD,OAAK,MAAM;AACX,QAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,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,UAAMA,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAMA,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
|
|
6
|
+
"names": ["out"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import path from "path";
|
|
3
2
|
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
4
3
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
4
|
+
process.env.IS_STATIC = "is_static";
|
|
5
5
|
var src_default = require("./loader").loader;
|
|
6
|
-
const shouldExclude =
|
|
7
|
-
if (
|
|
6
|
+
const shouldExclude = (filePath, projectRoot) => {
|
|
7
|
+
if (filePath.includes("react-native-web") || filePath.includes("react-native-gesture-handler") || filePath.includes("@gorhom") || filePath.includes(projectRoot) || isTamaguiDistJSX(filePath)) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
return true;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
|
+
function isTamaguiDistJSX(filePath) {
|
|
13
|
+
return filePath.includes("/dist/jsx/".replace(/\//g, path.sep));
|
|
14
|
+
}
|
|
12
15
|
export {
|
|
13
16
|
src_default as default,
|
|
14
17
|
shouldExclude
|
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": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nprocess.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\nprocess.env.IS_STATIC = 'is_static'\n\nexport default require('./loader').loader\n\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (filePath: string, projectRoot: string) => {\n if (\n filePath.includes('react-native-web') ||\n filePath.includes('react-native-gesture-handler') ||\n filePath.includes('@gorhom') ||\n filePath.includes(projectRoot) ||\n isTamaguiDistJSX(filePath)\n ) {\n return false\n }\n return true\n}\n\nfunction isTamaguiDistJSX(filePath: string) {\n return filePath.includes('/dist/jsx/'.replace(/\\//g, path.sep))\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AACtC,QAAQ,IAAI,YAAY;AAExB,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,UAAkB,gBAAwB;AACtE,MACE,SAAS,SAAS,kBAAkB,KACpC,SAAS,SAAS,8BAA8B,KAChD,SAAS,SAAS,SAAS,KAC3B,SAAS,SAAS,WAAW,KAC7B,iBAAiB,QAAQ,GACzB;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,UAAkB;AAC1C,SAAO,SAAS,SAAS,aAAa,QAAQ,OAAO,KAAK,GAAG,CAAC;AAChE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/loader.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import { Color, colorLog } from "@tamagui/cli-color";
|
|
3
2
|
import {
|
|
4
3
|
createExtractor,
|
|
5
4
|
extractToClassNames,
|
|
6
|
-
|
|
5
|
+
getPragmaOptions
|
|
7
6
|
} from "@tamagui/static";
|
|
8
7
|
import { extractedInfoByFile, stylePathToFilePath } from "./css";
|
|
9
8
|
Error.stackTraceLimit = Infinity;
|
|
9
|
+
const CSS_LOADER_PATH = require.resolve("./css");
|
|
10
|
+
Error.stackTraceLimit = Infinity;
|
|
10
11
|
const extractor = createExtractor();
|
|
11
12
|
let index = 0;
|
|
12
|
-
let hasLogged = false;
|
|
13
|
-
let hasPatched = false;
|
|
14
13
|
process.env.TAMAGUI_TARGET = "web";
|
|
15
|
-
function
|
|
16
|
-
this.cacheable();
|
|
17
|
-
this.async();
|
|
18
|
-
|
|
19
|
-
patchReactNativeWeb();
|
|
20
|
-
hasPatched = true;
|
|
21
|
-
}
|
|
14
|
+
const loader = async function loader2(sourceIn) {
|
|
15
|
+
this.cacheable(true);
|
|
16
|
+
const callback = this.async();
|
|
17
|
+
const source = sourceIn.toString();
|
|
22
18
|
try {
|
|
23
19
|
const threaded = this.emitFile === void 0;
|
|
24
20
|
const options = { ...this.getOptions() };
|
|
25
21
|
const sourcePath = `${this.resourcePath}`;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return this.callback(null, source);
|
|
22
|
+
const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath });
|
|
23
|
+
if (shouldDisable) {
|
|
24
|
+
if (shouldPrintDebug) {
|
|
25
|
+
console.log(`Disabling on file via pragma`);
|
|
26
|
+
}
|
|
27
|
+
return callback(null, source);
|
|
33
28
|
}
|
|
34
29
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
35
|
-
const extracted = extractToClassNames({
|
|
36
|
-
loader: this,
|
|
30
|
+
const extracted = await extractToClassNames({
|
|
37
31
|
extractor,
|
|
38
|
-
cssLoaderPath: require.resolve("./css"),
|
|
39
32
|
source,
|
|
40
|
-
threaded,
|
|
41
33
|
sourcePath,
|
|
42
|
-
cssPath,
|
|
43
34
|
options,
|
|
44
35
|
shouldPrintDebug
|
|
45
36
|
});
|
|
46
37
|
if (!extracted) {
|
|
47
|
-
return
|
|
38
|
+
return callback(null, source);
|
|
39
|
+
}
|
|
40
|
+
if (extracted.styles) {
|
|
41
|
+
const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
42
|
+
const remReq = this.remainingRequest;
|
|
43
|
+
const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
|
|
44
|
+
extracted.js = `${extracted.js}
|
|
45
|
+
|
|
46
|
+
require(${JSON.stringify(importPath)})`;
|
|
48
47
|
}
|
|
49
48
|
extractedInfoByFile.set(sourcePath, extracted);
|
|
50
49
|
if (!threaded) {
|
|
@@ -52,13 +51,21 @@ function loader(source) {
|
|
|
52
51
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
callback(null, extracted.js, extracted.map);
|
|
56
55
|
} catch (err) {
|
|
57
|
-
|
|
56
|
+
const message = err instanceof Error ? `${err.message}
|
|
57
|
+
${err.stack}` : String(err);
|
|
58
|
+
console.error("Tamagui Webpack Loader Error:\n", ` ${message}
|
|
59
|
+
`);
|
|
60
|
+
if (message.includes(`Cannot create proxy`)) {
|
|
61
|
+
console.log(
|
|
62
|
+
`This is usually due to components not loading at build-time. Check for logs just below the line above:`
|
|
63
|
+
);
|
|
64
|
+
colorLog(Color.FgYellow, `"Tamagui built config and components"`);
|
|
65
|
+
}
|
|
58
66
|
return this.callback(null, source);
|
|
59
67
|
}
|
|
60
|
-
}
|
|
61
|
-
__name(loader, "loader");
|
|
68
|
+
};
|
|
62
69
|
export {
|
|
63
70
|
loader
|
|
64
71
|
};
|
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
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { Color, colorLog } from '@tamagui/cli-color'\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n getPragmaOptions,\n} from '@tamagui/static'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\nError.stackTraceLimit = Infinity\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader = async function loader(this, sourceIn: Buffer | string) {\n this.cacheable(true)\n const callback = this.async()\n const source = sourceIn.toString()\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath })\n\n if (shouldDisable) {\n if (shouldPrintDebug) {\n // eslint-disable-next-line no-console\n console.log(`Disabling on file via pragma`)\n }\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = await extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n // add import to css\n if (extracted.styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = this.remainingRequest\n const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`\n extracted.js = `${extracted.js}\\n\\nrequire(${JSON.stringify(importPath)})`\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 const message = err instanceof Error ? `${err.message}\\n${err.stack}` : String(err)\n\n // eslint-disable-next-line no-console\n console.error('Tamagui Webpack Loader Error:\\n', ` ${message}\\n`)\n\n if (message.includes(`Cannot create proxy`)) {\n // eslint-disable-next-line no-console\n console.log(\n `This is usually due to components not loading at build-time. Check for logs just below the line above:`\n )\n colorLog(Color.FgYellow, `\"Tamagui built config and components\"`)\n }\n\n return this.callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,gBAAgB;AAChC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,qBAAqB,2BAA2B;AAEzD,MAAM,kBAAkB;AAGxB,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AAEZ,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAS,eAAeA,QAAa,UAA2B;AAC3E,OAAK,UAAU,IAAI;AACnB,QAAM,WAAW,KAAK,MAAM;AAC5B,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,EAAE,eAAe,iBAAiB,IAAI,iBAAiB,EAAE,QAAQ,MAAM,WAAW,CAAC;AAEzF,QAAI,eAAe;AACjB,UAAI,kBAAkB;AAEpB,gBAAQ,IAAI,8BAA8B;AAAA,MAC5C;AACA,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,MAAM,oBAAoB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAGA,QAAI,UAAU,QAAQ;AACpB,YAAM,WAAW,WACb,WAAW,OAAO,KAAK,UAAU,MAAM,EAAE,SAAS,QAAQ,MAC1D,WAAW;AACf,YAAM,SAAS,KAAK;AACpB,YAAM,aAAa,GAAG,aAAa,mBAAmB,YAAY;AAClE,gBAAU,KAAK,GAAG,UAAU;AAAA;AAAA,UAAiB,KAAK,UAAU,UAAU;AAAA,IACxE;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,UAAM,UAAU,eAAe,QAAQ,GAAG,IAAI;AAAA,EAAY,IAAI,UAAU,OAAO,GAAG;AAGlF,YAAQ,MAAM,mCAAmC,KAAK;AAAA,CAAW;AAEjE,QAAI,QAAQ,SAAS,qBAAqB,GAAG;AAE3C,cAAQ;AAAA,QACN;AAAA,MACF;AACA,eAAS,MAAM,UAAU,uCAAuC;AAAA,IAClE;AAEA,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;",
|
|
6
|
+
"names": ["loader"]
|
|
7
7
|
}
|
package/dist/jsx/css.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
4
2
|
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
5
|
-
function loader(
|
|
6
|
-
var _a;
|
|
3
|
+
function loader() {
|
|
7
4
|
this.async();
|
|
8
5
|
const options = { ...this.getOptions() };
|
|
9
6
|
const sourcePath = `${this.resourcePath}`;
|
|
10
7
|
let out = "";
|
|
11
8
|
if (options.cssPath) {
|
|
12
|
-
const pathKey =
|
|
9
|
+
const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath;
|
|
13
10
|
const info = extractedInfoByFile.get(pathKey);
|
|
14
11
|
stylePathToFilePath.delete(sourcePath);
|
|
15
12
|
extractedInfoByFile.delete(pathKey);
|
|
16
|
-
const out2 = info
|
|
13
|
+
const out2 = info?.styles;
|
|
17
14
|
return this.callback(null, out2 || "");
|
|
18
15
|
} else if (options.cssData) {
|
|
19
16
|
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
20
17
|
}
|
|
21
|
-
if (
|
|
18
|
+
if (out) {
|
|
22
19
|
return this.callback(null, out || "");
|
|
23
20
|
}
|
|
24
21
|
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
25
22
|
}
|
|
26
|
-
__name(loader, "loader");
|
|
27
23
|
export {
|
|
28
24
|
loader as default,
|
|
29
25
|
extractedInfoByFile,
|
|
30
26
|
stylePathToFilePath
|
|
31
27
|
};
|
|
28
|
+
//# 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>) {\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 (out) {\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,SAAR,SAAkD;AACvD,OAAK,MAAM;AACX,QAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,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,UAAMA,OAAM,MAAM;AAClB,WAAO,KAAK,SAAS,MAAMA,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
|
|
6
|
+
"names": ["out"]
|
|
7
|
+
}
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import path from "path";
|
|
3
2
|
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
4
3
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
4
|
+
process.env.IS_STATIC = "is_static";
|
|
5
5
|
var src_default = require("./loader").loader;
|
|
6
|
-
const shouldExclude =
|
|
7
|
-
if (
|
|
6
|
+
const shouldExclude = (filePath, projectRoot) => {
|
|
7
|
+
if (filePath.includes("react-native-web") || filePath.includes("react-native-gesture-handler") || filePath.includes("@gorhom") || filePath.includes(projectRoot) || isTamaguiDistJSX(filePath)) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
return true;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
|
+
function isTamaguiDistJSX(filePath) {
|
|
13
|
+
return filePath.includes("/dist/jsx/".replace(/\//g, path.sep));
|
|
14
|
+
}
|
|
12
15
|
export {
|
|
13
16
|
src_default as default,
|
|
14
17
|
shouldExclude
|
|
15
18
|
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nprocess.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\nprocess.env.IS_STATIC = 'is_static'\n\nexport default require('./loader').loader\n\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (filePath: string, projectRoot: string) => {\n if (\n filePath.includes('react-native-web') ||\n filePath.includes('react-native-gesture-handler') ||\n filePath.includes('@gorhom') ||\n filePath.includes(projectRoot) ||\n isTamaguiDistJSX(filePath)\n ) {\n return false\n }\n return true\n}\n\nfunction isTamaguiDistJSX(filePath: string) {\n return filePath.includes('/dist/jsx/'.replace(/\\//g, path.sep))\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AACtC,QAAQ,IAAI,YAAY;AAExB,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,UAAkB,gBAAwB;AACtE,MACE,SAAS,SAAS,kBAAkB,KACpC,SAAS,SAAS,8BAA8B,KAChD,SAAS,SAAS,SAAS,KAC3B,SAAS,SAAS,WAAW,KAC7B,iBAAiB,QAAQ,GACzB;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,UAAkB;AAC1C,SAAO,SAAS,SAAS,aAAa,QAAQ,OAAO,KAAK,GAAG,CAAC;AAChE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/jsx/loader.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import { Color, colorLog } from "@tamagui/cli-color";
|
|
3
2
|
import {
|
|
4
3
|
createExtractor,
|
|
5
4
|
extractToClassNames,
|
|
6
|
-
|
|
5
|
+
getPragmaOptions
|
|
7
6
|
} from "@tamagui/static";
|
|
8
7
|
import { extractedInfoByFile, stylePathToFilePath } from "./css";
|
|
9
8
|
Error.stackTraceLimit = Infinity;
|
|
9
|
+
const CSS_LOADER_PATH = require.resolve("./css");
|
|
10
|
+
Error.stackTraceLimit = Infinity;
|
|
10
11
|
const extractor = createExtractor();
|
|
11
12
|
let index = 0;
|
|
12
|
-
let hasLogged = false;
|
|
13
|
-
let hasPatched = false;
|
|
14
13
|
process.env.TAMAGUI_TARGET = "web";
|
|
15
|
-
function
|
|
16
|
-
this.cacheable();
|
|
17
|
-
this.async();
|
|
18
|
-
|
|
19
|
-
patchReactNativeWeb();
|
|
20
|
-
hasPatched = true;
|
|
21
|
-
}
|
|
14
|
+
const loader = async function loader2(sourceIn) {
|
|
15
|
+
this.cacheable(true);
|
|
16
|
+
const callback = this.async();
|
|
17
|
+
const source = sourceIn.toString();
|
|
22
18
|
try {
|
|
23
19
|
const threaded = this.emitFile === void 0;
|
|
24
20
|
const options = { ...this.getOptions() };
|
|
25
21
|
const sourcePath = `${this.resourcePath}`;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return this.callback(null, source);
|
|
22
|
+
const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath });
|
|
23
|
+
if (shouldDisable) {
|
|
24
|
+
if (shouldPrintDebug) {
|
|
25
|
+
console.log(`Disabling on file via pragma`);
|
|
26
|
+
}
|
|
27
|
+
return callback(null, source);
|
|
33
28
|
}
|
|
34
29
|
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
35
|
-
const extracted = extractToClassNames({
|
|
36
|
-
loader: this,
|
|
30
|
+
const extracted = await extractToClassNames({
|
|
37
31
|
extractor,
|
|
38
|
-
cssLoaderPath: require.resolve("./css"),
|
|
39
32
|
source,
|
|
40
|
-
threaded,
|
|
41
33
|
sourcePath,
|
|
42
|
-
cssPath,
|
|
43
34
|
options,
|
|
44
35
|
shouldPrintDebug
|
|
45
36
|
});
|
|
46
37
|
if (!extracted) {
|
|
47
|
-
return
|
|
38
|
+
return callback(null, source);
|
|
39
|
+
}
|
|
40
|
+
if (extracted.styles) {
|
|
41
|
+
const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
42
|
+
const remReq = this.remainingRequest;
|
|
43
|
+
const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
|
|
44
|
+
extracted.js = `${extracted.js}
|
|
45
|
+
|
|
46
|
+
require(${JSON.stringify(importPath)})`;
|
|
48
47
|
}
|
|
49
48
|
extractedInfoByFile.set(sourcePath, extracted);
|
|
50
49
|
if (!threaded) {
|
|
@@ -52,13 +51,22 @@ function loader(source) {
|
|
|
52
51
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
callback(null, extracted.js, extracted.map);
|
|
56
55
|
} catch (err) {
|
|
57
|
-
|
|
56
|
+
const message = err instanceof Error ? `${err.message}
|
|
57
|
+
${err.stack}` : String(err);
|
|
58
|
+
console.error("Tamagui Webpack Loader Error:\n", ` ${message}
|
|
59
|
+
`);
|
|
60
|
+
if (message.includes(`Cannot create proxy`)) {
|
|
61
|
+
console.log(
|
|
62
|
+
`This is usually due to components not loading at build-time. Check for logs just below the line above:`
|
|
63
|
+
);
|
|
64
|
+
colorLog(Color.FgYellow, `"Tamagui built config and components"`);
|
|
65
|
+
}
|
|
58
66
|
return this.callback(null, source);
|
|
59
67
|
}
|
|
60
|
-
}
|
|
61
|
-
__name(loader, "loader");
|
|
68
|
+
};
|
|
62
69
|
export {
|
|
63
70
|
loader
|
|
64
71
|
};
|
|
72
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loader.ts"],
|
|
4
|
+
"sourcesContent": ["import { Color, colorLog } from '@tamagui/cli-color'\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n getPragmaOptions,\n} from '@tamagui/static'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\nError.stackTraceLimit = Infinity\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader = async function loader(this, sourceIn: Buffer | string) {\n this.cacheable(true)\n const callback = this.async()\n const source = sourceIn.toString()\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath })\n\n if (shouldDisable) {\n if (shouldPrintDebug) {\n // eslint-disable-next-line no-console\n console.log(`Disabling on file via pragma`)\n }\n return callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = await extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return callback(null, source)\n }\n\n // add import to css\n if (extracted.styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = this.remainingRequest\n const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`\n extracted.js = `${extracted.js}\\n\\nrequire(${JSON.stringify(importPath)})`\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 const message = err instanceof Error ? `${err.message}\\n${err.stack}` : String(err)\n\n // eslint-disable-next-line no-console\n console.error('Tamagui Webpack Loader Error:\\n', ` ${message}\\n`)\n\n if (message.includes(`Cannot create proxy`)) {\n // eslint-disable-next-line no-console\n console.log(\n `This is usually due to components not loading at build-time. Check for logs just below the line above:`\n )\n colorLog(Color.FgYellow, `\"Tamagui built config and components\"`)\n }\n\n return this.callback(null, source)\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,gBAAgB;AAChC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,qBAAqB,2BAA2B;AAEzD,MAAM,kBAAkB;AAGxB,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AAEZ,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAS,eAAeA,QAAa,UAA2B;AAC3E,OAAK,UAAU,IAAI;AACnB,QAAM,WAAW,KAAK,MAAM;AAC5B,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,EAAE,eAAe,iBAAiB,IAAI,iBAAiB,EAAE,QAAQ,MAAM,WAAW,CAAC;AAEzF,QAAI,eAAe;AACjB,UAAI,kBAAkB;AAEpB,gBAAQ,IAAI,8BAA8B;AAAA,MAC5C;AACA,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,MAAM,oBAAoB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAGA,QAAI,UAAU,QAAQ;AACpB,YAAM,WAAW,WACb,WAAW,OAAO,KAAK,UAAU,MAAM,EAAE,SAAS,QAAQ,MAC1D,WAAW;AACf,YAAM,SAAS,KAAK;AACpB,YAAM,aAAa,GAAG,aAAa,mBAAmB,YAAY;AAClE,gBAAU,KAAK,GAAG,UAAU;AAAA;AAAA,UAAiB,KAAK,UAAU,UAAU;AAAA,IACxE;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,UAAM,UAAU,eAAe,QAAQ,GAAG,IAAI;AAAA,EAAY,IAAI,UAAU,OAAO,GAAG;AAGlF,YAAQ,MAAM,mCAAmC,KAAK;AAAA,CAAW;AAEjE,QAAI,QAAQ,SAAS,qBAAqB,GAAG;AAE3C,cAAQ;AAAA,QACN;AAAA,MACF;AACA,eAAS,MAAM,UAAU,uCAAuC;AAAA,IAClE;AAEA,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;",
|
|
6
|
+
"names": ["loader"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamagui-loader",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.1-beta.210",
|
|
4
|
+
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
7
7
|
"module:jsx": "dist/jsx",
|
|
8
8
|
"files": [
|
|
9
|
+
"src",
|
|
9
10
|
"types",
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "tamagui-build",
|
|
14
15
|
"watch": "tamagui-build --watch",
|
|
16
|
+
"lint": "eslint",
|
|
17
|
+
"lint:fix": "yarn lint --fix",
|
|
15
18
|
"clean": "tamagui-build clean",
|
|
16
19
|
"clean:build": "tamagui-build clean:build"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@tamagui/
|
|
20
|
-
"
|
|
22
|
+
"@tamagui/cli-color": "^1.0.1-beta.210",
|
|
23
|
+
"@tamagui/static": "^1.0.1-beta.210",
|
|
24
|
+
"fs-extra": "^10.1.0",
|
|
21
25
|
"lodash": "^4.17.21"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
28
|
+
"@tamagui/build": "^1.0.1-beta.210"
|
|
25
29
|
},
|
|
26
30
|
"publishConfig": {
|
|
27
31
|
"access": "public"
|
package/src/css.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'
|
|
2
|
+
import { LoaderContext } from 'webpack'
|
|
3
|
+
|
|
4
|
+
export const extractedInfoByFile = new Map<string, ExtractedResponse>()
|
|
5
|
+
export const stylePathToFilePath = new Map<string, string>()
|
|
6
|
+
|
|
7
|
+
export default function loader(this: LoaderContext<any>) {
|
|
8
|
+
this.async()
|
|
9
|
+
const options: TamaguiOptions = { ...this.getOptions() }
|
|
10
|
+
const sourcePath = `${this.resourcePath}`
|
|
11
|
+
let out = ''
|
|
12
|
+
if (options.cssPath) {
|
|
13
|
+
// get in memory info
|
|
14
|
+
const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath
|
|
15
|
+
const info = extractedInfoByFile.get(pathKey)
|
|
16
|
+
// clear memory
|
|
17
|
+
stylePathToFilePath.delete(sourcePath)
|
|
18
|
+
extractedInfoByFile.delete(pathKey)
|
|
19
|
+
const out = info?.styles
|
|
20
|
+
return this.callback(null, out || '')
|
|
21
|
+
} else if (options.cssData) {
|
|
22
|
+
// get output CSS
|
|
23
|
+
out = Buffer.from(options.cssData, 'base64').toString('utf-8')
|
|
24
|
+
}
|
|
25
|
+
if (out) {
|
|
26
|
+
// use original JS sourcemap
|
|
27
|
+
return this.callback(null, out || '')
|
|
28
|
+
}
|
|
29
|
+
this.callback({ message: `No CSS found`, name: 'missing_css' })
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
|
|
3
|
+
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'
|
|
4
|
+
process.env.TAMAGUI_COMPILE_PROCESS = '1'
|
|
5
|
+
process.env.IS_STATIC = 'is_static'
|
|
6
|
+
|
|
7
|
+
export default require('./loader').loader
|
|
8
|
+
|
|
9
|
+
// helper for webpack exclude specific to tamagui
|
|
10
|
+
|
|
11
|
+
export const shouldExclude = (filePath: string, projectRoot: string) => {
|
|
12
|
+
if (
|
|
13
|
+
filePath.includes('react-native-web') ||
|
|
14
|
+
filePath.includes('react-native-gesture-handler') ||
|
|
15
|
+
filePath.includes('@gorhom') ||
|
|
16
|
+
filePath.includes(projectRoot) ||
|
|
17
|
+
isTamaguiDistJSX(filePath)
|
|
18
|
+
) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isTamaguiDistJSX(filePath: string) {
|
|
25
|
+
return filePath.includes('/dist/jsx/'.replace(/\//g, path.sep))
|
|
26
|
+
}
|
package/src/loader.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Color, colorLog } from '@tamagui/cli-color'
|
|
2
|
+
import {
|
|
3
|
+
TamaguiOptions,
|
|
4
|
+
createExtractor,
|
|
5
|
+
extractToClassNames,
|
|
6
|
+
getPragmaOptions,
|
|
7
|
+
} from '@tamagui/static'
|
|
8
|
+
|
|
9
|
+
import { extractedInfoByFile, stylePathToFilePath } from './css'
|
|
10
|
+
|
|
11
|
+
Error.stackTraceLimit = Infinity
|
|
12
|
+
|
|
13
|
+
// pass loader as path
|
|
14
|
+
const CSS_LOADER_PATH = require.resolve('./css')
|
|
15
|
+
|
|
16
|
+
Error.stackTraceLimit = Infinity
|
|
17
|
+
const extractor = createExtractor()
|
|
18
|
+
|
|
19
|
+
let index = 0
|
|
20
|
+
|
|
21
|
+
process.env.TAMAGUI_TARGET = 'web'
|
|
22
|
+
|
|
23
|
+
export const loader = async function loader(this, sourceIn: Buffer | string) {
|
|
24
|
+
this.cacheable(true)
|
|
25
|
+
const callback = this.async()
|
|
26
|
+
const source = sourceIn.toString()
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const threaded = this.emitFile === undefined
|
|
30
|
+
const options: TamaguiOptions = { ...this.getOptions() }
|
|
31
|
+
const sourcePath = `${this.resourcePath}`
|
|
32
|
+
const { shouldDisable, shouldPrintDebug } = getPragmaOptions({ source, path: sourcePath })
|
|
33
|
+
|
|
34
|
+
if (shouldDisable) {
|
|
35
|
+
if (shouldPrintDebug) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.log(`Disabling on file via pragma`)
|
|
38
|
+
}
|
|
39
|
+
return callback(null, source)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`
|
|
43
|
+
|
|
44
|
+
const extracted = await extractToClassNames({
|
|
45
|
+
extractor,
|
|
46
|
+
source,
|
|
47
|
+
sourcePath,
|
|
48
|
+
options,
|
|
49
|
+
shouldPrintDebug,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
if (!extracted) {
|
|
53
|
+
return callback(null, source)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// add import to css
|
|
57
|
+
if (extracted.styles) {
|
|
58
|
+
const cssQuery = threaded
|
|
59
|
+
? `cssData=${Buffer.from(extracted.styles).toString('base64')}`
|
|
60
|
+
: `cssPath=${cssPath}`
|
|
61
|
+
const remReq = this.remainingRequest
|
|
62
|
+
const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`
|
|
63
|
+
extracted.js = `${extracted.js}\n\nrequire(${JSON.stringify(importPath)})`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
extractedInfoByFile.set(sourcePath, extracted)
|
|
67
|
+
|
|
68
|
+
if (!threaded) {
|
|
69
|
+
if (extracted.stylesPath) {
|
|
70
|
+
stylePathToFilePath.set(extracted.stylesPath, sourcePath)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
callback(null, extracted.js, extracted.map)
|
|
75
|
+
} catch (err) {
|
|
76
|
+
const message = err instanceof Error ? `${err.message}\n${err.stack}` : String(err)
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line no-console
|
|
79
|
+
console.error('Tamagui Webpack Loader Error:\n', ` ${message}\n`)
|
|
80
|
+
|
|
81
|
+
if (message.includes(`Cannot create proxy`)) {
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.log(
|
|
84
|
+
`This is usually due to components not loading at build-time. Check for logs just below the line above:`
|
|
85
|
+
)
|
|
86
|
+
colorLog(Color.FgYellow, `"Tamagui built config and components"`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return this.callback(null, source)
|
|
90
|
+
}
|
|
91
|
+
}
|
package/types/css.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { ExtractedResponse } from '@tamagui/static';
|
|
|
2
2
|
import { LoaderContext } from 'webpack';
|
|
3
3
|
export declare const extractedInfoByFile: Map<string, ExtractedResponse>;
|
|
4
4
|
export declare const stylePathToFilePath: Map<string, string>;
|
|
5
|
-
export default function loader(this: LoaderContext<any
|
|
5
|
+
export default function loader(this: LoaderContext<any>): void;
|
|
6
6
|
//# sourceMappingURL=css.d.ts.map
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
3
|
-
export declare const shouldExclude: (
|
|
3
|
+
export declare const shouldExclude: (filePath: string, projectRoot: string) => boolean;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/types/loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const loader: (this: any, sourceIn: Buffer | string) => Promise<any>;
|
|
3
3
|
//# sourceMappingURL=loader.d.ts.map
|
package/types/css.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,YAWnF,CAAA"}
|
package/types/loader.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|