tamagui-loader 1.114.4 → 1.115.0

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.
@@ -0,0 +1,157 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var TamaguiPlugin_exports = {};
33
+ __export(TamaguiPlugin_exports, {
34
+ TamaguiPlugin: () => TamaguiPlugin
35
+ });
36
+ module.exports = __toCommonJS(TamaguiPlugin_exports);
37
+ var import_static = __toESM(require("@tamagui/static")),
38
+ import_node_fs = require("node:fs"),
39
+ import_node_path = require("node:path"),
40
+ import_webpack = __toESM(require("webpack")),
41
+ import_requireResolve = require("./requireResolve.cjs");
42
+ const {
43
+ watchTamaguiConfig
44
+ } = import_static.default;
45
+ class TamaguiPlugin {
46
+ constructor(options = {
47
+ platform: "web",
48
+ components: ["@tamagui/core"]
49
+ }) {
50
+ this.options = options;
51
+ }
52
+ pluginName = "TamaguiPlugin";
53
+ safeResolves = (resolves, multiple = !1) => {
54
+ const res = [];
55
+ for (const [out, mod] of resolves) {
56
+ if (out.endsWith("$")) {
57
+ res.push([out, mod]);
58
+ continue;
59
+ }
60
+ try {
61
+ res.push([out, (0, import_requireResolve.requireResolve)(mod)]), multiple && res.push([out, (0, import_requireResolve.requireResolve)(mod)]);
62
+ } catch (err) {
63
+ if (out.includes("@gorhom/bottom-sheet")) continue;
64
+ process.env.DEBUG?.startsWith("tamagui") && console.info(` withTamagui skipping resolving ${out}`, err);
65
+ }
66
+ }
67
+ return res;
68
+ };
69
+ get componentsFullPaths() {
70
+ return this.safeResolves(this.options.components?.map(moduleName => [moduleName, moduleName]) || [], !0);
71
+ }
72
+ get componentsBaseDirs() {
73
+ return this.componentsFullPaths.map(([_, fullPath]) => {
74
+ let rootPath = (0, import_node_path.dirname)(fullPath);
75
+ for (; rootPath.length > 1;) {
76
+ const pkg = (0, import_node_path.join)(rootPath, "package.json");
77
+ if ((0, import_node_fs.existsSync)(pkg)) return rootPath;
78
+ rootPath = (0, import_node_path.join)(rootPath, "..");
79
+ }
80
+ throw new Error(`Couldn't find package.json in any path above: ${fullPath}`);
81
+ });
82
+ }
83
+ isInComponentModule = fullPath => this.componentsBaseDirs.some(componentDir => fullPath.startsWith(componentDir));
84
+ get defaultAliases() {
85
+ return Object.fromEntries(this.safeResolves([["@tamagui/core/reset.css", "@tamagui/core/reset.css"], ["@tamagui/core", "@tamagui/core"], ["@tamagui/web", "@tamagui/web"],
86
+ // fixes https://github.com/kentcdodds/mdx-bundler/issues/143
87
+ ["react/jsx-runtime.js", "react/jsx-runtime"], ["react/jsx-runtime", "react/jsx-runtime"], ["react/jsx-dev-runtime.js", "react/jsx-dev-runtime"], ["react/jsx-dev-runtime", "react/jsx-dev-runtime"], ...(this.options.useTamaguiSVG ? [["react-native-svg", "@tamagui/react-native-svg"]] : []), ...(this.options.useReactNativeWebLite ? [["react-native$", "@tamagui/react-native-web-lite"], ["react-native-web$", "@tamagui/react-native-web-lite"]] : [["react-native$", "react-native-web"], ["react-native-web$", "react-native-web"]])]));
88
+ }
89
+ apply(compiler) {
90
+ if (import_static.default.loadTamaguiSync(this.options), compiler.options.mode === "development" && !this.options.disableWatchConfig && watchTamaguiConfig(this.options).then(watcher => {
91
+ process.once("exit", () => {
92
+ watcher?.dispose();
93
+ });
94
+ }), compiler.hooks.normalModuleFactory.tap(this.pluginName, nmf => {
95
+ nmf.hooks.createModule.tap(this.pluginName,
96
+ // @ts-expect-error CreateData is typed as 'object'...
97
+ createData => {
98
+ createData.matchResource?.endsWith(".tamagui.css") && (createData.settings.sideEffects = !0);
99
+ });
100
+ }), !this.options.disableAliases) {
101
+ const existingAlias = compiler.options.resolve.alias;
102
+ Array.isArray(existingAlias) || typeof existingAlias == "object" && Object.assign(existingAlias, this.defaultAliases);
103
+ }
104
+ const excludeExports = this.options.excludeReactNativeWebExports;
105
+ if (excludeExports && Array.isArray(excludeExports)) try {
106
+ const regexStr = `react-native-web(-lite)?/.*(${excludeExports.join("|")}).*js`,
107
+ regex = new RegExp(regexStr);
108
+ compiler.hooks.environment.tap("MyPlugin", () => {
109
+ new import_webpack.default.NormalModuleReplacementPlugin(regex, (0, import_requireResolve.requireResolve)("@tamagui/proxy-worm")).apply(compiler);
110
+ });
111
+ } catch {
112
+ console.warn(`Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(", ")}`);
113
+ }
114
+ this.options.emitSingleCSSFile && (console.info(" \u27A1 [tamagui] \u{1F3A8} combining css into one file"), compiler.hooks.make.tap(this.pluginName, compilation => {
115
+ compilation.hooks.processAssets.tap(this.pluginName, assets => {
116
+ try {
117
+ const cssFiles = Object.keys(assets).filter(asset => asset.endsWith(".css"));
118
+ if (cssFiles.length === 0) return;
119
+ const combinedCSS = cssFiles.reduce((acc, file) => {
120
+ const cssContent = compilation.assets[file].source();
121
+ return `${acc}
122
+ ${cssContent}`;
123
+ }, "");
124
+ for (const [index, cssFile] of cssFiles.entries()) index > 0 ? compilation.updateAsset(cssFile, new compiler.webpack.sources.RawSource("")) : (console.info(` \u27A1 [tamagui] \u{1F3A8} emitting single css to ${cssFile}`), compilation.updateAsset(cssFile, new compiler.webpack.sources.RawSource(Buffer.from(combinedCSS))));
125
+ } catch (error) {
126
+ compilation.errors.push(error);
127
+ }
128
+ });
129
+ })), compiler.options.resolve.extensions = [... /* @__PURE__ */new Set([".web.tsx", ".web.ts", ".web.js", ".ts", ".tsx", ".js", ...(compiler.options.resolve.extensions || [])])], compiler.options.resolve.fallback ||= {}, compiler.options.resolve.fallback.crypto ||= !1;
130
+ const mainFields = compiler.options.resolve.mainFields;
131
+ if (mainFields && (compiler.options.resolve.mainFields = Array.isArray(mainFields) ? mainFields : [mainFields], this.options.disableModuleJSXEntry || mainFields.unshift("module:jsx")), !compiler.options.module) return;
132
+ const {
133
+ jsLoader
134
+ } = this.options,
135
+ existing = compiler.options.module.rules,
136
+ rules = existing.find(x => typeof x == "object" && "oneOf" in x ? x : null)?.oneOf ?? existing,
137
+ tamaguiLoader = {
138
+ loader: (0, import_requireResolve.requireResolve)("tamagui-loader"),
139
+ options: {
140
+ ...this.options,
141
+ _disableLoadTamagui: !0
142
+ }
143
+ };
144
+ let didReplaceNextJS = !1;
145
+ for (const [index, rule] of rules.entries()) (rule?.use?.loader === "next-swc-loader" || Array.isArray(rule?.use) && rule?.use[0].loader === "next-swc-loader") && !rule.issuerLayer && (didReplaceNextJS = !0, rules[index] = {
146
+ ...rule,
147
+ test: this.options.test ?? rule.test ?? /\.m?[jt]sx?$/,
148
+ exclude: this.options.exclude ?? rule.exclude,
149
+ use: [...(jsLoader ? [jsLoader] : []), ...(rule.use ? [].concat(rule.use) : []), tamaguiLoader]
150
+ });
151
+ didReplaceNextJS || compiler.options.mode === "development" && existing.push({
152
+ test: this.options.test ?? /\.tsx$/,
153
+ exclude: this.options.exclude,
154
+ use: [tamaguiLoader]
155
+ });
156
+ }
157
+ }
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var css_exports = {};
22
+ __export(css_exports, {
23
+ default: () => loader
24
+ });
25
+ module.exports = __toCommonJS(css_exports);
26
+ function loader() {
27
+ this.async();
28
+ const options = {
29
+ ...this.getOptions()
30
+ };
31
+ let out = Buffer.from(options.cssData, "base64").toString("utf-8");
32
+ if (out) return this.callback(null, out || "");
33
+ this.callback({
34
+ message: "No CSS found",
35
+ name: "missing_css"
36
+ });
37
+ }
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ },
18
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
20
+ value: !0
21
+ }), mod);
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ default: () => src_default
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var import_polyfills = require("./polyfills.cjs"),
28
+ import_loader = require("./loader.cjs");
29
+ __reExport(src_exports, require("./TamaguiPlugin.cjs"), module.exports);
30
+ __reExport(src_exports, require("./shouldExclude.cjs"), module.exports);
31
+ var src_default = import_loader.loader;
@@ -0,0 +1,108 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var loader_exports = {};
33
+ __export(loader_exports, {
34
+ loader: () => loader
35
+ });
36
+ module.exports = __toCommonJS(loader_exports);
37
+ var import_static = __toESM(require("@tamagui/static")),
38
+ import_requireResolve = require("./requireResolve.cjs");
39
+ const {
40
+ createExtractor,
41
+ extractToClassNames,
42
+ getPragmaOptions
43
+ } = import_static.default;
44
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
45
+ let CSS_LOADER_PATH = "";
46
+ try {
47
+ CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.cjs");
48
+ } catch {
49
+ try {
50
+ CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.esm");
51
+ } catch {
52
+ CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.js");
53
+ }
54
+ }
55
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
56
+ const extractor = createExtractor();
57
+ let index = 0;
58
+ process.env.TAMAGUI_TARGET = "web";
59
+ const loader = async function (sourceIn) {
60
+ this.cacheable(!0);
61
+ const callback = this.async(),
62
+ sourcePath = `${this.resourcePath}`;
63
+ if (sourcePath.includes("node_modules") || sourcePath.includes("lucide-icons")) return callback(null, sourceIn);
64
+ const source = sourceIn.toString();
65
+ try {
66
+ const options = {
67
+ // @ts-ignore
68
+ platform: "web",
69
+ ...this.getOptions()
70
+ },
71
+ {
72
+ shouldDisable,
73
+ shouldPrintDebug
74
+ } = getPragmaOptions({
75
+ source,
76
+ path: sourcePath
77
+ });
78
+ if (shouldPrintDebug === "verbose" && (console.warn(`
79
+
80
+ --- Incoming source ---
81
+
82
+ `), console.warn(source)), shouldDisable) return shouldPrintDebug && console.info("Disabling on file via pragma"), callback(null, source);
83
+ const cssPath = `${sourcePath}.${index++}.tamagui.css`,
84
+ extracted = await extractToClassNames({
85
+ extractor,
86
+ source,
87
+ sourcePath,
88
+ options,
89
+ shouldPrintDebug
90
+ });
91
+ if (!extracted) return callback(null, source);
92
+ if (extracted.styles) {
93
+ const cssQuery = `cssData=${Buffer.from(extracted.styles).toString("base64")}`,
94
+ remReq = this.remainingRequest,
95
+ importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
96
+ extracted.js = `${extracted.js}
97
+
98
+ require(${JSON.stringify(importPath)})`;
99
+ }
100
+ callback(null, extracted.js, extracted.map);
101
+ } catch (err) {
102
+ const message = err instanceof Error ? `${err.message}
103
+ ${err.stack}` : String(err);
104
+ console.error(`Tamagui Webpack Loader Error:
105
+ `, ` ${message}
106
+ `), message.includes("Cannot create proxy") && console.info("This is usually due to components not loading at build-time. Check for logs just below the line above:"), callback(null, source);
107
+ }
108
+ };
@@ -0,0 +1,3 @@
1
+ process.env.TAMAGUI_TARGET = "web";
2
+ process.env.IS_STATIC = "is_static";
3
+ process.env.TAMAGUI_IS_SERVER = "true";
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var requireResolve_exports = {};
22
+ __export(requireResolve_exports, {
23
+ requireResolve: () => requireResolve
24
+ });
25
+ module.exports = __toCommonJS(requireResolve_exports);
26
+ var import_node_module = require("node:module");
27
+ const import_meta = {},
28
+ requireResolve = "url" in import_meta ? (0, import_node_module.createRequire)(import_meta.url).resolve : require.resolve;
@@ -2,24 +2,33 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
15
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
21
  // If the importer is in node compatibility mode or this is not an ESM
17
22
  // file that has been converted to a CommonJS file using a Babel-
18
23
  // compatible transform (i.e. "__esModule" has not been set), then set
19
24
  // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
23
32
  var shouldExclude_exports = {};
24
33
  __export(shouldExclude_exports, {
25
34
  shouldExclude: () => shouldExclude
@@ -29,5 +38,4 @@ var import_node_path = __toESM(require("node:path"));
29
38
  const shouldExclude = (filePath, projectRoot) => !(projectRoot && filePath.includes(projectRoot) && filePath.endsWith("sx") || isTamaguiDistJSX(filePath));
30
39
  function isTamaguiDistJSX(filePath) {
31
40
  return filePath.includes("/dist/jsx/".replace(/\//g, import_node_path.default.sep));
32
- }
33
- //# sourceMappingURL=shouldExclude.js.map
41
+ }
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var test_exports = {};
22
+ __export(test_exports, {
23
+ default: () => loader
24
+ });
25
+ module.exports = __toCommonJS(test_exports);
26
+ async function loader(sourceIn) {
27
+ this.cacheable(!0);
28
+ const callback = this.async(),
29
+ sourcePath = `${this.resourcePath}`;
30
+ return callback(null, sourceIn);
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamagui-loader",
3
- "version": "1.114.4",
3
+ "version": "1.115.0",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -22,14 +22,16 @@
22
22
  ".": {
23
23
  "types": "./types/index.d.ts",
24
24
  "import": "./dist/esm/index.mjs",
25
- "require": "./dist/cjs/index.js"
25
+ "require": "./dist/cjs/index.cjs",
26
+ "react-native": "./dist/cjs/index.native.js",
27
+ "default": "./dist/cjs/index.native.js"
26
28
  }
27
29
  },
28
30
  "dependencies": {
29
- "@tamagui/cli-color": "1.114.4",
30
- "@tamagui/core": "1.114.4",
31
- "@tamagui/static": "1.114.4",
32
- "@tamagui/web": "1.114.4",
31
+ "@tamagui/cli-color": "1.115.0",
32
+ "@tamagui/core": "1.115.0",
33
+ "@tamagui/static": "1.115.0",
34
+ "@tamagui/web": "1.115.0",
33
35
  "esbuild-loader": "^4.2.2",
34
36
  "esm-resolve": "^1.0.8",
35
37
  "fs-extra": "^11.2.0",
@@ -37,7 +39,7 @@
37
39
  "lodash": "^4.17.21"
38
40
  },
39
41
  "devDependencies": {
40
- "@tamagui/build": "1.114.4",
42
+ "@tamagui/build": "1.115.0",
41
43
  "prettyjson": "^1.2.5",
42
44
  "webpack": "^5.88.2"
43
45
  },
@@ -1,197 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var TamaguiPlugin_exports = {};
24
- __export(TamaguiPlugin_exports, {
25
- TamaguiPlugin: () => TamaguiPlugin
26
- });
27
- module.exports = __toCommonJS(TamaguiPlugin_exports);
28
- var import_static = __toESM(require("@tamagui/static")), import_node_fs = require("node:fs"), import_node_path = require("node:path"), import_webpack = __toESM(require("webpack")), import_requireResolve = require("./requireResolve");
29
- const { watchTamaguiConfig } = import_static.default;
30
- class TamaguiPlugin {
31
- constructor(options = {
32
- platform: "web",
33
- components: ["@tamagui/core"]
34
- }) {
35
- this.options = options;
36
- }
37
- pluginName = "TamaguiPlugin";
38
- safeResolves = (resolves, multiple = !1) => {
39
- const res = [];
40
- for (const [out, mod] of resolves) {
41
- if (out.endsWith("$")) {
42
- res.push([out, mod]);
43
- continue;
44
- }
45
- try {
46
- res.push([out, (0, import_requireResolve.requireResolve)(mod)]), multiple && res.push([out, (0, import_requireResolve.requireResolve)(mod)]);
47
- } catch (err) {
48
- if (out.includes("@gorhom/bottom-sheet"))
49
- continue;
50
- process.env.DEBUG?.startsWith("tamagui") && console.info(` withTamagui skipping resolving ${out}`, err);
51
- }
52
- }
53
- return res;
54
- };
55
- get componentsFullPaths() {
56
- return this.safeResolves(
57
- this.options.components?.map(
58
- (moduleName) => [moduleName, moduleName]
59
- ) || [],
60
- !0
61
- );
62
- }
63
- get componentsBaseDirs() {
64
- return this.componentsFullPaths.map(([_, fullPath]) => {
65
- let rootPath = (0, import_node_path.dirname)(fullPath);
66
- for (; rootPath.length > 1; ) {
67
- const pkg = (0, import_node_path.join)(rootPath, "package.json");
68
- if ((0, import_node_fs.existsSync)(pkg))
69
- return rootPath;
70
- rootPath = (0, import_node_path.join)(rootPath, "..");
71
- }
72
- throw new Error(`Couldn't find package.json in any path above: ${fullPath}`);
73
- });
74
- }
75
- isInComponentModule = (fullPath) => this.componentsBaseDirs.some(
76
- (componentDir) => fullPath.startsWith(componentDir)
77
- );
78
- get defaultAliases() {
79
- return Object.fromEntries(
80
- this.safeResolves([
81
- ["@tamagui/core/reset.css", "@tamagui/core/reset.css"],
82
- ["@tamagui/core", "@tamagui/core"],
83
- ["@tamagui/web", "@tamagui/web"],
84
- // fixes https://github.com/kentcdodds/mdx-bundler/issues/143
85
- ["react/jsx-runtime.js", "react/jsx-runtime"],
86
- ["react/jsx-runtime", "react/jsx-runtime"],
87
- ["react/jsx-dev-runtime.js", "react/jsx-dev-runtime"],
88
- ["react/jsx-dev-runtime", "react/jsx-dev-runtime"],
89
- ...this.options.useTamaguiSVG ? [["react-native-svg", "@tamagui/react-native-svg"]] : [],
90
- ...this.options.useReactNativeWebLite ? [
91
- ["react-native$", "@tamagui/react-native-web-lite"],
92
- ["react-native-web$", "@tamagui/react-native-web-lite"]
93
- ] : [
94
- ["react-native$", "react-native-web"],
95
- ["react-native-web$", "react-native-web"]
96
- ]
97
- ])
98
- );
99
- }
100
- apply(compiler) {
101
- if (import_static.default.loadTamaguiSync(this.options), compiler.options.mode === "development" && !this.options.disableWatchConfig && watchTamaguiConfig(this.options).then((watcher) => {
102
- process.once("exit", () => {
103
- watcher?.dispose();
104
- });
105
- }), compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
106
- nmf.hooks.createModule.tap(
107
- this.pluginName,
108
- // @ts-expect-error CreateData is typed as 'object'...
109
- (createData) => {
110
- createData.matchResource?.endsWith(".tamagui.css") && (createData.settings.sideEffects = !0);
111
- }
112
- );
113
- }), !this.options.disableAliases) {
114
- const existingAlias = compiler.options.resolve.alias;
115
- Array.isArray(existingAlias) || typeof existingAlias == "object" && Object.assign(existingAlias, this.defaultAliases);
116
- }
117
- const excludeExports = this.options.excludeReactNativeWebExports;
118
- if (excludeExports && Array.isArray(excludeExports))
119
- try {
120
- const regexStr = `react-native-web(-lite)?/.*(${excludeExports.join("|")}).*js`, regex = new RegExp(regexStr);
121
- compiler.hooks.environment.tap("MyPlugin", () => {
122
- new import_webpack.default.NormalModuleReplacementPlugin(
123
- regex,
124
- (0, import_requireResolve.requireResolve)("@tamagui/proxy-worm")
125
- ).apply(compiler);
126
- });
127
- } catch {
128
- console.warn(
129
- `Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(
130
- ", "
131
- )}`
132
- );
133
- }
134
- this.options.emitSingleCSSFile && (console.info(" \u27A1 [tamagui] \u{1F3A8} combining css into one file"), compiler.hooks.make.tap(this.pluginName, (compilation) => {
135
- compilation.hooks.processAssets.tap(this.pluginName, (assets) => {
136
- try {
137
- const cssFiles = Object.keys(assets).filter((asset) => asset.endsWith(".css"));
138
- if (cssFiles.length === 0)
139
- return;
140
- const combinedCSS = cssFiles.reduce((acc, file) => {
141
- const cssContent = compilation.assets[file].source();
142
- return `${acc}
143
- ${cssContent}`;
144
- }, "");
145
- for (const [index, cssFile] of cssFiles.entries())
146
- index > 0 ? compilation.updateAsset(
147
- cssFile,
148
- new compiler.webpack.sources.RawSource("")
149
- ) : (console.info(` \u27A1 [tamagui] \u{1F3A8} emitting single css to ${cssFile}`), compilation.updateAsset(
150
- cssFile,
151
- new compiler.webpack.sources.RawSource(Buffer.from(combinedCSS))
152
- ));
153
- } catch (error) {
154
- compilation.errors.push(error);
155
- }
156
- });
157
- })), compiler.options.resolve.extensions = [
158
- .../* @__PURE__ */ new Set([
159
- ".web.tsx",
160
- ".web.ts",
161
- ".web.js",
162
- ".ts",
163
- ".tsx",
164
- ".js",
165
- ...compiler.options.resolve.extensions || []
166
- ])
167
- ], compiler.options.resolve.fallback ||= {}, compiler.options.resolve.fallback.crypto ||= !1;
168
- const mainFields = compiler.options.resolve.mainFields;
169
- if (mainFields && (compiler.options.resolve.mainFields = Array.isArray(mainFields) ? mainFields : [mainFields], this.options.disableModuleJSXEntry || mainFields.unshift("module:jsx")), !compiler.options.module)
170
- return;
171
- const { jsLoader } = this.options, existing = compiler.options.module.rules, rules = existing.find((x) => typeof x == "object" && "oneOf" in x ? x : null)?.oneOf ?? existing, tamaguiLoader = {
172
- loader: (0, import_requireResolve.requireResolve)("tamagui-loader"),
173
- options: {
174
- ...this.options,
175
- _disableLoadTamagui: !0
176
- }
177
- };
178
- let didReplaceNextJS = !1;
179
- for (const [index, rule] of rules.entries())
180
- (rule?.use?.loader === "next-swc-loader" || Array.isArray(rule?.use) && rule?.use[0].loader === "next-swc-loader") && !rule.issuerLayer && (didReplaceNextJS = !0, rules[index] = {
181
- ...rule,
182
- test: this.options.test ?? rule.test ?? /\.m?[jt]sx?$/,
183
- exclude: this.options.exclude ?? rule.exclude,
184
- use: [
185
- ...jsLoader ? [jsLoader] : [],
186
- ...rule.use ? [].concat(rule.use) : [],
187
- tamaguiLoader
188
- ]
189
- });
190
- didReplaceNextJS || compiler.options.mode === "development" && existing.push({
191
- test: this.options.test ?? /\.tsx$/,
192
- exclude: this.options.exclude,
193
- use: [tamaguiLoader]
194
- });
195
- }
196
- }
197
- //# sourceMappingURL=TamaguiPlugin.js.map
package/dist/cjs/css.js DELETED
@@ -1,28 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var css_exports = {};
16
- __export(css_exports, {
17
- default: () => loader
18
- });
19
- module.exports = __toCommonJS(css_exports);
20
- function loader() {
21
- this.async();
22
- const options = { ...this.getOptions() };
23
- let out = Buffer.from(options.cssData, "base64").toString("utf-8");
24
- if (out)
25
- return this.callback(null, out || "");
26
- this.callback({ message: "No CSS found", name: "missing_css" });
27
- }
28
- //# sourceMappingURL=css.js.map
package/dist/cjs/index.js DELETED
@@ -1,24 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var src_exports = {};
16
- __export(src_exports, {
17
- default: () => src_default
18
- });
19
- module.exports = __toCommonJS(src_exports);
20
- var import_polyfills = require("./polyfills"), import_loader = require("./loader");
21
- __reExport(src_exports, require("./TamaguiPlugin"), module.exports);
22
- __reExport(src_exports, require("./shouldExclude"), module.exports);
23
- var src_default = import_loader.loader;
24
- //# sourceMappingURL=index.js.map
@@ -1,92 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var loader_exports = {};
24
- __export(loader_exports, {
25
- loader: () => loader
26
- });
27
- module.exports = __toCommonJS(loader_exports);
28
- var import_static = __toESM(require("@tamagui/static")), import_requireResolve = require("./requireResolve");
29
- const { createExtractor, extractToClassNames, getPragmaOptions } = import_static.default;
30
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
31
- let CSS_LOADER_PATH = "";
32
- try {
33
- CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.cjs");
34
- } catch {
35
- try {
36
- CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.esm");
37
- } catch {
38
- CSS_LOADER_PATH = (0, import_requireResolve.requireResolve)("./css.js");
39
- }
40
- }
41
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
42
- const extractor = createExtractor();
43
- let index = 0;
44
- process.env.TAMAGUI_TARGET = "web";
45
- const loader = async function(sourceIn) {
46
- this.cacheable(!0);
47
- const callback = this.async(), sourcePath = `${this.resourcePath}`;
48
- if (sourcePath.includes("node_modules") || sourcePath.includes("lucide-icons"))
49
- return callback(null, sourceIn);
50
- const source = sourceIn.toString();
51
- try {
52
- const options = {
53
- // @ts-ignore
54
- platform: "web",
55
- ...this.getOptions()
56
- }, { shouldDisable, shouldPrintDebug } = getPragmaOptions({
57
- source,
58
- path: sourcePath
59
- });
60
- if (shouldPrintDebug === "verbose" && (console.warn(`
61
-
62
- --- Incoming source ---
63
-
64
- `), console.warn(source)), shouldDisable)
65
- return shouldPrintDebug && console.info("Disabling on file via pragma"), callback(null, source);
66
- const cssPath = `${sourcePath}.${index++}.tamagui.css`, extracted = await extractToClassNames({
67
- extractor,
68
- source,
69
- sourcePath,
70
- options,
71
- shouldPrintDebug
72
- });
73
- if (!extracted)
74
- return callback(null, source);
75
- if (extracted.styles) {
76
- const cssQuery = `cssData=${Buffer.from(extracted.styles).toString("base64")}`, remReq = this.remainingRequest, importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
77
- extracted.js = `${extracted.js}
78
-
79
- require(${JSON.stringify(importPath)})`;
80
- }
81
- callback(null, extracted.js, extracted.map);
82
- } catch (err) {
83
- const message = err instanceof Error ? `${err.message}
84
- ${err.stack}` : String(err);
85
- console.error(`Tamagui Webpack Loader Error:
86
- `, ` ${message}
87
- `), message.includes("Cannot create proxy") && console.info(
88
- "This is usually due to components not loading at build-time. Check for logs just below the line above:"
89
- ), callback(null, source);
90
- }
91
- };
92
- //# sourceMappingURL=loader.js.map
@@ -1,4 +0,0 @@
1
- process.env.TAMAGUI_TARGET = "web";
2
- process.env.IS_STATIC = "is_static";
3
- process.env.TAMAGUI_IS_SERVER = "true";
4
- //# sourceMappingURL=polyfills.js.map
@@ -1,22 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var requireResolve_exports = {};
16
- __export(requireResolve_exports, {
17
- requireResolve: () => requireResolve
18
- });
19
- module.exports = __toCommonJS(requireResolve_exports);
20
- var import_node_module = require("node:module");
21
- const import_meta = {}, requireResolve = "url" in import_meta ? (0, import_node_module.createRequire)(import_meta.url).resolve : require.resolve;
22
- //# sourceMappingURL=requireResolve.js.map
package/dist/cjs/test.js DELETED
@@ -1,25 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var test_exports = {};
16
- __export(test_exports, {
17
- default: () => loader
18
- });
19
- module.exports = __toCommonJS(test_exports);
20
- async function loader(sourceIn) {
21
- this.cacheable(!0);
22
- const callback = this.async(), sourcePath = `${this.resourcePath}`;
23
- return callback(null, sourceIn);
24
- }
25
- //# sourceMappingURL=test.js.map
File without changes
File without changes
File without changes
File without changes