Skip to content

Commit a2139ac

Browse files
update: fmt
1 parent d66dbd5 commit a2139ac

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

utils/custom-loaders/html-tag-jsx-loader.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ module.exports = function htmlTagJsxLoader(source) {
1515

1616
try {
1717
// Debug logging - verify loader is running
18-
// console.log(`🔧 Custom JSX loader processing: ${this.resourcePath}\n`);
18+
console.log(`🔧 Custom JSX loader processing: ${this.resourcePath}\n`);
1919

2020
// Determine file type from extension
2121
const isTypeScript = /\.tsx?$/.test(this.resourcePath);
2222

2323
// Quick check: if no JSX syntax at all, pass through unchanged
2424
// Look for complete JSX opening tags with proper spacing
25-
const hasJSXLike = /<[A-Z][a-zA-Z0-9]*(?:\s|\/?>)|<[a-z]+(?:\s|\/?>)/.test(source);
25+
const hasJSXLike =
26+
/<\/?[A-Z][a-zA-Z0-9]*[^>]*>|<\/?[a-z][a-z0-9-]*[^>]*>/.test(source);
27+
console.log(`loader :: ${this.resourcePath}`, { hasJSXLike });
2628
if (!hasJSXLike) {
27-
return callback(null, source)
29+
return callback(null, source);
2830
}
2931

3032
// Parse with appropriate plugins
@@ -42,8 +44,12 @@ module.exports = function htmlTagJsxLoader(source) {
4244
let needsTagImport = false;
4345
let hasJSX = false;
4446
const hasExistingImport =
45-
/import\s+(?:\{[^}]*\btag\b[^}]*\}|tag(?:\s+as\s+\w+)?)\s+from\s+['"]html-tag-js['"]/.test(source) ||
46-
/(?:const|let|var)\s+(?:\{[^}]*\btag\b[^}]*\}|tag)\s*=\s*require\s*\(\s*['"]html-tag-js['"]\s*\)/.test(source);
47+
/import\s+(?:\{[^}]*\btag\b[^}]*\}|tag(?:\s+as\s+\w+)?)\s+from\s+['"]html-tag-js['"]/.test(
48+
source,
49+
) ||
50+
/(?:const|let|var)\s+(?:\{[^}]*\btag\b[^}]*\}|tag)\s*=\s*require\s*\(\s*['"]html-tag-js['"]\s*\)/.test(
51+
source,
52+
);
4753

4854
// Transform JSX elements
4955
traverse(ast, {

0 commit comments

Comments
 (0)