tamagui-loader 1.0.1-rc.8 → 1.0.1
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/jsx/css.js +4 -3
- package/dist/jsx/css.js.map +3 -3
- package/dist/jsx/index.js +2 -7
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/loader.js +21 -29
- package/dist/jsx/loader.js.map +3 -3
- package/dist/jsx/plugin.js +9 -12
- package/dist/jsx/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/jsx/css.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
const extractedInfoByFile = /* @__PURE__ */ new Map();
|
|
2
2
|
const stylePathToFilePath = /* @__PURE__ */ new Map();
|
|
3
3
|
function loader() {
|
|
4
|
+
var _a;
|
|
4
5
|
this.async();
|
|
5
6
|
const options = { ...this.getOptions() };
|
|
6
7
|
const sourcePath = `${this.resourcePath}`;
|
|
7
8
|
let out = "";
|
|
8
9
|
if (options.cssPath) {
|
|
9
|
-
const pathKey = stylePathToFilePath.get(sourcePath)
|
|
10
|
+
const pathKey = (_a = stylePathToFilePath.get(sourcePath)) != null ? _a : sourcePath;
|
|
10
11
|
const info = extractedInfoByFile.get(pathKey);
|
|
11
12
|
stylePathToFilePath.delete(sourcePath);
|
|
12
13
|
extractedInfoByFile.delete(pathKey);
|
|
13
|
-
const out2 = info
|
|
14
|
+
const out2 = info == null ? void 0 : info.styles;
|
|
14
15
|
return this.callback(null, out2 || "");
|
|
15
16
|
} else if (options.cssData) {
|
|
16
17
|
out = Buffer.from(options.cssData, "base64").toString("utf-8");
|
|
@@ -18,7 +19,7 @@ function loader() {
|
|
|
18
19
|
if (out) {
|
|
19
20
|
return this.callback(null, out || "");
|
|
20
21
|
}
|
|
21
|
-
this.callback({ message:
|
|
22
|
+
this.callback({ message: `No CSS found`, name: "missing_css" });
|
|
22
23
|
}
|
|
23
24
|
export {
|
|
24
25
|
loader as default,
|
package/dist/jsx/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
|
|
5
|
-
"mappings": "AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,
|
|
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,kBAA0C;AANzD;AAOE,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,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,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import path from "path";
|
|
2
1
|
process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
|
|
3
2
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
4
3
|
process.env.IS_STATIC = "is_static";
|
|
5
|
-
export * from "./plugin";
|
|
6
4
|
var src_default = require("./loader").loader;
|
|
7
|
-
const shouldExclude = (
|
|
8
|
-
if (
|
|
5
|
+
const shouldExclude = (path, projectRoot) => {
|
|
6
|
+
if (path.includes("react-native-web") || path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes("@gorhom/portal") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
|
|
9
7
|
return false;
|
|
10
8
|
}
|
|
11
9
|
return true;
|
|
12
10
|
};
|
|
13
|
-
function isTamaguiDistJSX(filePath) {
|
|
14
|
-
return filePath.includes("/dist/jsx/".replace(/\//g, path.sep));
|
|
15
|
-
}
|
|
16
11
|
export {
|
|
17
12
|
src_default as default,
|
|
18
13
|
shouldExclude
|
package/dist/jsx/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["process.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 = (path: string, projectRoot: string) => {\n if (\n path.includes('react-native-web') ||\n path.includes('react-native-reanimated') ||\n path.includes('react-native-gesture-handler') ||\n path.includes('@gorhom/portal') ||\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;AACtC,QAAQ,IAAI,YAAY;AAExB,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,MAAc,gBAAwB;AAClE,MACE,KAAK,SAAS,kBAAkB,KAChC,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,gBAAgB,KAC9B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/loader.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
Error.stackTraceLimit = Infinity;
|
|
2
2
|
import {
|
|
3
3
|
createExtractor,
|
|
4
4
|
extractToClassNames,
|
|
5
|
-
|
|
5
|
+
patchReactNativeWeb
|
|
6
6
|
} from "@tamagui/static";
|
|
7
7
|
import { extractedInfoByFile, stylePathToFilePath } from "./css";
|
|
8
|
-
Error.stackTraceLimit = Infinity;
|
|
9
8
|
const CSS_LOADER_PATH = require.resolve("./css");
|
|
10
9
|
Error.stackTraceLimit = Infinity;
|
|
11
10
|
const extractor = createExtractor();
|
|
12
11
|
let index = 0;
|
|
12
|
+
let hasPatched = false;
|
|
13
13
|
process.env.TAMAGUI_TARGET = "web";
|
|
14
|
-
const loader =
|
|
14
|
+
const loader = function loader2(sourceIn) {
|
|
15
15
|
this.cacheable(true);
|
|
16
|
-
|
|
16
|
+
this.async();
|
|
17
17
|
const source = sourceIn.toString();
|
|
18
|
+
if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
|
|
19
|
+
patchReactNativeWeb();
|
|
20
|
+
hasPatched = true;
|
|
21
|
+
}
|
|
18
22
|
try {
|
|
19
23
|
const threaded = this.emitFile === void 0;
|
|
20
24
|
const options = { ...this.getOptions() };
|
|
21
25
|
const sourcePath = `${this.resourcePath}`;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (shouldDisable) {
|
|
27
|
-
if (shouldPrintDebug) {
|
|
28
|
-
console.log("Disabling on file via pragma");
|
|
29
|
-
}
|
|
30
|
-
return callback(null, source);
|
|
26
|
+
const startsWithComment = source[0] === "/" && source[1] === "/";
|
|
27
|
+
let shouldPrintDebug = !!process.env.DEBUG && (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true) || startsWithComment && (source.startsWith("// debug") || source.startsWith("//! debug"));
|
|
28
|
+
if (shouldPrintDebug && source.startsWith("// debug-verbose")) {
|
|
29
|
+
shouldPrintDebug = "verbose";
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (startsWithComment && (source.startsWith("// tamagui-ignore") || source.startsWith("//! tamagui-ignore"))) {
|
|
32
|
+
return this.callback(null, source);
|
|
33
|
+
}
|
|
34
|
+
const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
|
|
35
|
+
const extracted = extractToClassNames({
|
|
34
36
|
extractor,
|
|
35
37
|
source,
|
|
36
38
|
sourcePath,
|
|
@@ -38,10 +40,9 @@ const loader = async function loader2(sourceIn) {
|
|
|
38
40
|
shouldPrintDebug
|
|
39
41
|
});
|
|
40
42
|
if (!extracted) {
|
|
41
|
-
return callback(null, source);
|
|
43
|
+
return this.callback(null, source);
|
|
42
44
|
}
|
|
43
45
|
if (extracted.styles) {
|
|
44
|
-
this.addDependency(cssPath);
|
|
45
46
|
const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
46
47
|
const remReq = this.remainingRequest;
|
|
47
48
|
const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
|
|
@@ -55,18 +56,9 @@ require(${JSON.stringify(importPath)})`;
|
|
|
55
56
|
stylePathToFilePath.set(extracted.stylesPath, sourcePath);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
callback(null, extracted.js, extracted.map);
|
|
59
|
+
this.callback(null, extracted.js, extracted.map);
|
|
59
60
|
} catch (err) {
|
|
60
|
-
|
|
61
|
-
${err.stack}` : String(err);
|
|
62
|
-
console.error("Tamagui Webpack Loader Error:\n", ` ${message}
|
|
63
|
-
`);
|
|
64
|
-
if (message.includes("Cannot create proxy")) {
|
|
65
|
-
console.log(
|
|
66
|
-
"This is usually due to components not loading at build-time. Check for logs just below the line above:"
|
|
67
|
-
);
|
|
68
|
-
colorLog(Color.FgYellow, `"Tamagui built config and components"`);
|
|
69
|
-
}
|
|
61
|
+
console.error("ERROR", err);
|
|
70
62
|
return this.callback(null, source);
|
|
71
63
|
}
|
|
72
64
|
};
|
package/dist/jsx/loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/loader.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["Error.stackTraceLimit = Infinity\n\nimport {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport type { RawLoaderDefinitionFunction } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader: RawLoaderDefinitionFunction<TamaguiOptions> = function loader(this, sourceIn) {\n this.cacheable(true)\n this.async()\n const source = sourceIn.toString()\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 extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.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 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,MAAM,kBAAkB;AAExB;AAAA;AAAA;AAAA;AAAA;AAQA;AAGA,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAsD,iBAAsB,UAAU;AACjG,OAAK,UAAU,IAAI;AACnB,OAAK,MAAM;AACX,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,wBAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;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,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;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/jsx/plugin.js
CHANGED
|
@@ -6,15 +6,14 @@ class TamaguiPlugin {
|
|
|
6
6
|
this.pluginName = "TamaguiPlugin";
|
|
7
7
|
}
|
|
8
8
|
apply(compiler) {
|
|
9
|
+
var _a, _b, _c;
|
|
9
10
|
compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
|
|
10
|
-
nmf.hooks.createModule.tap(
|
|
11
|
-
|
|
12
|
-
(createData)
|
|
13
|
-
|
|
14
|
-
createData.settings.sideEffects = true;
|
|
15
|
-
}
|
|
11
|
+
nmf.hooks.createModule.tap(this.pluginName, (createData) => {
|
|
12
|
+
var _a2;
|
|
13
|
+
if ((_a2 = createData.matchResource) == null ? void 0 : _a2.endsWith(".tamagui.css")) {
|
|
14
|
+
createData.settings.sideEffects = true;
|
|
16
15
|
}
|
|
17
|
-
);
|
|
16
|
+
});
|
|
18
17
|
});
|
|
19
18
|
compiler.options.resolve.extensions = [
|
|
20
19
|
.../* @__PURE__ */ new Set([
|
|
@@ -37,14 +36,12 @@ class TamaguiPlugin {
|
|
|
37
36
|
}
|
|
38
37
|
const { jsLoader } = this.options;
|
|
39
38
|
const existing = compiler.options.module.rules;
|
|
40
|
-
const rules = existing.find((x) => typeof x === "object" && "oneOf" in x ? x : null)
|
|
41
|
-
const nextJsRules = rules.findIndex(
|
|
42
|
-
(x) => x?.use && x.use.loader === "next-swc-loader" && x.issuerLayer !== "api"
|
|
43
|
-
);
|
|
39
|
+
const rules = (_b = (_a = existing.find((x) => typeof x === "object" && "oneOf" in x ? x : null)) == null ? void 0 : _a.oneOf) != null ? _b : existing;
|
|
40
|
+
const nextJsRules = rules.findIndex((x) => (x == null ? void 0 : x.use) && x.use.loader === "next-swc-loader" && x.issuerLayer !== "api");
|
|
44
41
|
const startIndex = nextJsRules ? nextJsRules + 1 : 0;
|
|
45
42
|
const existingLoader = nextJsRules ? rules[startIndex] : void 0;
|
|
46
43
|
rules.splice(startIndex, 0, {
|
|
47
|
-
test: this.options.test
|
|
44
|
+
test: (_c = this.options.test) != null ? _c : /\.(jsx?|tsx?)$/,
|
|
48
45
|
exclude: this.options.exclude,
|
|
49
46
|
use: [
|
|
50
47
|
...jsLoader ? [jsLoader] : [],
|
package/dist/jsx/plugin.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugin.ts"],
|
|
4
4
|
"sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.(jsx?|tsx?)$/,\n exclude: this.options.exclude,\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
|
|
5
|
-
"mappings": "AAUO,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;
|
|
5
|
+
"mappings": "AAUO,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAnB5B;AAqBI,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa,IACrB,KAAK,YAEL,CAAC,eAAgF;AAzBzF;AA0BU,YAAI,kBAAW,kBAAX,oBAA0B,SAAS,iBAAiB;AACtD,qBAAW,SAAS,cAAc;AAAA,QACpC;AAAA,MACF,CACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAI,YAAY;AACd,eAAS,QAAQ,QAAQ,aAAa,MAAM,QAAQ,UAAU,IAC1D,aACA,CAAC,UAAU;AACf,iBAAW,QAAQ,YAAY;AAAA,IACjC;AAEA,QAAI,CAAC,SAAS,QAAQ,QAAQ;AAC5B;AAAA,IACF;AAEA,UAAM,EAAE,aAAa,KAAK;AAE1B,UAAM,WAAW,SAAS,QAAQ,OAAO;AAEzC,UAAM,QACH,qBAAS,KAAK,CAAC,MAAO,OAAO,MAAM,YAAY,WAAW,IAAI,IAAI,IAAK,MAAvE,mBACG,UADH,YACsB;AAEzB,UAAM,cAAc,MAAM,UACxB,CAAC,MAAM,wBAAG,QAAO,EAAE,IAAI,WAAW,qBAAqB,EAAE,gBAAgB,KAC3E;AAEA,UAAM,aAAa,cAAc,cAAc,IAAI;AACnD,UAAM,iBAAiB,cAAc,MAAM,cAAc;AAEzD,UAAM,OAAO,YAAY,GAAG;AAAA,MAC1B,MAAM,WAAK,QAAQ,SAAb,YAAqB;AAAA,MAC3B,SAAS,KAAK,QAAQ;AAAA,MACtB,KAAK;AAAA,QACH,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;AAAA,QAC7B,GAAI,kBAAkB,cAAc,CAAC,EAAE,OAAO,eAAe,GAAG,IAAI,CAAC;AAAA,QACrE,GAAI,CAAE,aAAY,kBACd;AAAA,UACE;AAAA,YACE,QAAwB;AAAA,YACxB,SAAS;AAAA,cACP,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,gBACN,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,cACV;AAAA,cAEA,aAAa;AAAA,gBACX,QAAQ,KAAK,QAAQ,WAAW,aAAa;AAAA,gBAC7C,iBAAiB;AAAA,gBACjB,KAAK;AAAA,gBACL,mBAAmB;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL;AAAA,UACE,QAAwB;AAAA,UACxB,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamagui-loader",
|
|
3
|
-
"version": "1.0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/cli-color": "^1.0.1
|
|
22
|
-
"@tamagui/static": "^1.0.1
|
|
21
|
+
"@tamagui/cli-color": "^1.0.1",
|
|
22
|
+
"@tamagui/static": "^1.0.1",
|
|
23
23
|
"fs-extra": "^10.1.0",
|
|
24
24
|
"loader-utils": "^3.2.1",
|
|
25
25
|
"lodash": "^4.17.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "^1.0.1
|
|
28
|
+
"@tamagui/build": "^1.0.1",
|
|
29
29
|
"webpack": "^5.74.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|