@tamagui/metro-plugin 1.115.1 → 1.115.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,46 +2,35 @@ 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,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
6
  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
- };
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
+ };
20
15
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
16
  // If the importer is in node compatibility mode or this is not an ESM
22
17
  // file that has been converted to a CommonJS file using a Babel-
23
18
  // compatible transform (i.e. "__esModule" has not been set), then set
24
19
  // "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);
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
32
23
  var src_exports = {};
33
24
  __export(src_exports, {
34
25
  withTamagui: () => withTamagui
35
26
  });
36
27
  module.exports = __toCommonJS(src_exports);
37
- var import_static = require("@tamagui/static"),
38
- import_metro = require("react-native-css-interop/metro");
28
+ var import_static = require("@tamagui/static"), import_metro = require("react-native-css-interop/metro");
39
29
  function withTamagui(metroConfig, optionsIn) {
40
30
  const options = {
41
- ...optionsIn,
42
- ...(0, import_static.loadTamaguiBuildConfigSync)(optionsIn)
43
- },
44
- extractor = (0, import_static.createExtractor)();
31
+ ...optionsIn,
32
+ ...(0, import_static.loadTamaguiBuildConfigSync)(optionsIn)
33
+ }, extractor = (0, import_static.createExtractor)();
45
34
  options.disable || extractor.loadTamagui(options), options.disableCSSInterop ? metroConfig.resolver = {
46
35
  ...metroConfig.resolver,
47
36
  sourceExts: [...metroConfig.resolver.sourceExts, "css"]
@@ -58,4 +47,5 @@ function withTamagui(metroConfig, optionsIn) {
58
47
  disableInitialBuild: !0
59
48
  }
60
49
  }, metroConfig;
61
- }
50
+ }
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,95 @@
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 transformer_exports = {};
24
+ __export(transformer_exports, {
25
+ transform: () => transform
26
+ });
27
+ module.exports = __toCommonJS(transformer_exports);
28
+ var import_fs_extra = require("fs-extra"), import_metro_transform_worker = __toESM(require("metro-transform-worker")), import_node_path = require("node:path"), import_static = require("@tamagui/static");
29
+ const extractor = (0, import_static.createExtractor)();
30
+ async function transform(config, projectRoot, filename, data, options) {
31
+ const ogPath = config.ogTransformPath || config.transformerPath, transformer = ogPath ? require(ogPath).transform : import_metro_transform_worker.default.transform;
32
+ if (config.tamagui.disable || options.platform !== "web" || options.type === "asset" || filename.includes("node_modules"))
33
+ return transformer(config, projectRoot, filename, data, options);
34
+ if (
35
+ // could by a styled() call:
36
+ filename.endsWith(".ts") || filename.endsWith(".tsx") || filename.endsWith(".jsx")
37
+ ) {
38
+ const sourcePath = toPosixPath((0, import_node_path.join)(projectRoot, filename)), source = `${data}`, out = await (0, import_static.extractToClassNames)({
39
+ extractor,
40
+ options: {
41
+ // @ts-ignore
42
+ platform: "web",
43
+ ...config.tamagui
44
+ },
45
+ shouldPrintDebug: source.startsWith("// debug-verbose") ? "verbose" : source.startsWith("// debug"),
46
+ source,
47
+ sourcePath
48
+ });
49
+ if (out?.styles) {
50
+ const tmpDir = (0, import_node_path.join)(projectRoot, ".tamagui", "css"), outStylePath = toPosixPath(
51
+ (0, import_node_path.join)(tmpDir, `${filename}`.replace(/[^a-zA-Z0-9]/gi, "") + ".css")
52
+ );
53
+ if (process.env.DEBUG?.includes("tamagui") && console.info(" Outputting CSS file:", outStylePath), process.env.TAMAGUI_METRO_INLINE_CSS !== "0") {
54
+ const cssInjectionCode = `
55
+ (function() {
56
+ if (typeof document !== 'undefined') {
57
+ var css = ${JSON.stringify(out.styles)};
58
+ var style = document.createElement('style');
59
+ style.type = 'text/css';
60
+ style.appendChild(document.createTextNode(css));
61
+ document.head.appendChild(style);
62
+ }
63
+ })();
64
+ `;
65
+ return transformer(
66
+ config,
67
+ projectRoot,
68
+ filename,
69
+ Buffer.from(`${out.js}
70
+ ${cssInjectionCode}`, "utf-8"),
71
+ options
72
+ );
73
+ }
74
+ const existsAlready = await (0, import_fs_extra.pathExists)(outStylePath);
75
+ return await (0, import_fs_extra.outputFile)(outStylePath, out.styles, "utf-8"), existsAlready || await new Promise(
76
+ (res) => setTimeout(
77
+ res,
78
+ process.env.TAMAGUI_METRO_CSS_EMIT_DELAY ? +process.env.TAMAGUI_METRO_CSS_EMIT_DELAY : 1e3
79
+ )
80
+ ), transformer(
81
+ config,
82
+ projectRoot,
83
+ filename,
84
+ Buffer.from(`${out.js}
85
+ require("${outStylePath}")`, "utf-8"),
86
+ options
87
+ );
88
+ }
89
+ }
90
+ return transformer(config, projectRoot, filename, data, options);
91
+ }
92
+ function toPosixPath(path) {
93
+ return path.split(import_node_path.sep).join(import_node_path.posix.sep);
94
+ }
95
+ //# sourceMappingURL=transformer.js.map
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tamagui/metro-plugin",
3
- "version": "1.115.1",
3
+ "version": "1.115.2",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
- "main": "dist/cjs/index.cjs",
6
+ "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm",
8
8
  "files": [
9
9
  "src",
@@ -23,13 +23,13 @@
23
23
  "clean:build": "tamagui-build clean:build"
24
24
  },
25
25
  "dependencies": {
26
- "@tamagui/static": "1.115.1",
26
+ "@tamagui/static": "1.115.2",
27
27
  "fs-extra": "^11.2.0",
28
28
  "metro-config": "^0.80.4",
29
29
  "metro-transform-worker": "^0.80.4",
30
30
  "react-native-css-interop": "~0.0.21"
31
31
  },
32
32
  "devDependencies": {
33
- "@tamagui/build": "1.115.1"
33
+ "@tamagui/build": "1.115.2"
34
34
  }
35
35
  }
@@ -1,89 +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,
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 transformer_exports = {};
33
- __export(transformer_exports, {
34
- transform: () => transform
35
- });
36
- module.exports = __toCommonJS(transformer_exports);
37
- var import_fs_extra = require("fs-extra"),
38
- import_metro_transform_worker = __toESM(require("metro-transform-worker")),
39
- import_node_path = require("node:path"),
40
- import_static = require("@tamagui/static");
41
- const extractor = (0, import_static.createExtractor)();
42
- async function transform(config, projectRoot, filename, data, options) {
43
- const ogPath = config.ogTransformPath || config.transformerPath,
44
- transformer = ogPath ? require(ogPath).transform : import_metro_transform_worker.default.transform;
45
- if (config.tamagui.disable || options.platform !== "web" || options.type === "asset" || filename.includes("node_modules")) return transformer(config, projectRoot, filename, data, options);
46
- if (
47
- // could by a styled() call:
48
- filename.endsWith(".ts") || filename.endsWith(".tsx") || filename.endsWith(".jsx")) {
49
- const sourcePath = toPosixPath((0, import_node_path.join)(projectRoot, filename)),
50
- source = `${data}`,
51
- out = await (0, import_static.extractToClassNames)({
52
- extractor,
53
- options: {
54
- // @ts-ignore
55
- platform: "web",
56
- ...config.tamagui
57
- },
58
- shouldPrintDebug: source.startsWith("// debug-verbose") ? "verbose" : source.startsWith("// debug"),
59
- source,
60
- sourcePath
61
- });
62
- if (out?.styles) {
63
- const tmpDir = (0, import_node_path.join)(projectRoot, ".tamagui", "css"),
64
- outStylePath = toPosixPath((0, import_node_path.join)(tmpDir, `${filename}`.replace(/[^a-zA-Z0-9]/gi, "") + ".css"));
65
- if (process.env.DEBUG?.includes("tamagui") && console.info(" Outputting CSS file:", outStylePath), process.env.TAMAGUI_METRO_INLINE_CSS !== "0") {
66
- const cssInjectionCode = `
67
- (function() {
68
- if (typeof document !== 'undefined') {
69
- var css = ${JSON.stringify(out.styles)};
70
- var style = document.createElement('style');
71
- style.type = 'text/css';
72
- style.appendChild(document.createTextNode(css));
73
- document.head.appendChild(style);
74
- }
75
- })();
76
- `;
77
- return transformer(config, projectRoot, filename, Buffer.from(`${out.js}
78
- ${cssInjectionCode}`, "utf-8"), options);
79
- }
80
- const existsAlready = await (0, import_fs_extra.pathExists)(outStylePath);
81
- return await (0, import_fs_extra.outputFile)(outStylePath, out.styles, "utf-8"), existsAlready || (await new Promise(res => setTimeout(res, process.env.TAMAGUI_METRO_CSS_EMIT_DELAY ? +process.env.TAMAGUI_METRO_CSS_EMIT_DELAY : 1e3))), transformer(config, projectRoot, filename, Buffer.from(`${out.js}
82
- require("${outStylePath}")`, "utf-8"), options);
83
- }
84
- }
85
- return transformer(config, projectRoot, filename, data, options);
86
- }
87
- function toPosixPath(path) {
88
- return path.split(import_node_path.sep).join(import_node_path.posix.sep);
89
- }
File without changes