macaly-tagger 1.0.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"macaly-tagger-loader.d.ts","sourceRoot":"","sources":["../src/macaly-tagger-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAuFjB,QAAA,MAAM,kBAAkB,EAAE,kBAmIzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"macaly-tagger-loader.d.ts","sourceRoot":"","sources":["../src/macaly-tagger-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAgGjB,QAAA,MAAM,kBAAkB,EAAE,kBAqIzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -57,7 +57,7 @@ function isElementAlreadyTagged(attributes) {
57
57
  attr.name?.type === 'JSXIdentifier' &&
58
58
  attr.name.name === 'data-macaly-loc') ?? false);
59
59
  }
60
- function getJSXElementInfo(node) {
60
+ function getJSXElementInfo(node, debug = false) {
61
61
  let tagName;
62
62
  let insertPosition;
63
63
  if (node.name?.type === 'JSXIdentifier') {
@@ -72,16 +72,25 @@ function getJSXElementInfo(node) {
72
72
  insertPosition = node.name.end ?? 0;
73
73
  }
74
74
  else {
75
- console.log('[macaly-tagger] Unsupported JSX element type:', node.name?.type);
75
+ if (debug) {
76
+ console.log('[macaly-tagger] Unsupported JSX element type:', node.name?.type);
77
+ }
76
78
  return null;
77
79
  }
78
80
  if (!tagName || insertPosition === 0) {
79
- console.log('[macaly-tagger] Missing tagName or insertPosition:', { tagName, insertPosition });
81
+ if (debug) {
82
+ console.log('[macaly-tagger] Missing tagName or insertPosition:', {
83
+ tagName,
84
+ insertPosition,
85
+ });
86
+ }
80
87
  return null;
81
88
  }
82
89
  const loc = node.loc?.start;
83
90
  if (!loc) {
84
- console.log('[macaly-tagger] No location info for element:', tagName);
91
+ if (debug) {
92
+ console.log('[macaly-tagger] No location info for element:', tagName);
93
+ }
85
94
  return null;
86
95
  }
87
96
  return {
@@ -91,9 +100,11 @@ function getJSXElementInfo(node) {
91
100
  };
92
101
  }
93
102
  const macalyTaggerLoader = function (code) {
94
- console.log('[macaly-tagger] Loader called with:', this.resourcePath);
95
103
  const callback = this.async();
96
104
  const options = this.getOptions() || {};
105
+ if (options.debug) {
106
+ console.log('[macaly-tagger] Loader called with:', this.resourcePath);
107
+ }
97
108
  if (!callback) {
98
109
  throw new Error('[macaly-tagger] Async callback not available');
99
110
  }
@@ -135,7 +146,7 @@ const macalyTaggerLoader = function (code) {
135
146
  }
136
147
  return;
137
148
  }
138
- const elementInfo = getJSXElementInfo(jsxNode);
149
+ const elementInfo = getJSXElementInfo(jsxNode, !!options.debug);
139
150
  if (!elementInfo)
140
151
  return;
141
152
  const { tagName, insertPosition, location } = elementInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macaly-tagger",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A webpack loader that adds location metadata to JSX elements for development debugging",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",