Skip to content

Commit 5162e02

Browse files
update: move html-tag-jsx-loader to utils/custom-loader
1 parent 45da4f6 commit 5162e02

File tree

2 files changed

+4
-38
lines changed

2 files changed

+4
-38
lines changed

rspack.config.js

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,18 @@ module.exports = (env, options) => {
6262
exclude: /node_modules/,
6363
use: [
6464
// First: Transform JSX to tag() calls
65-
path.resolve(__dirname, 'html-tag-jsx-loader.js'),
65+
path.resolve(__dirname, 'utils/custom-loaders/html-tag-jsx-loader.js'),
6666
// Then: Use SWC for TypeScript and ES6+ transpilation
6767
{
6868
loader: 'builtin:swc-loader',
6969
options: {
7070
jsc: {
7171
parser: {
7272
syntax: 'typescript',
73-
tsx: true, // Still parse JSX syntax (before it gets transformed)
73+
tsx: true,
7474
},
7575
target: 'es2015',
7676
},
77-
// env: {
78-
// mode: 'usage',
79-
// coreJs: '3.22',
80-
// targets: 'defaults',
81-
// },
8277
},
8378
},
8479
],
@@ -100,9 +95,6 @@ module.exports = (env, options) => {
10095
},
10196
target: 'es2015',
10297
},
103-
// env: {
104-
// targets: 'defaults',
105-
// },
10698
},
10799
},
108100
],
@@ -116,37 +108,12 @@ module.exports = (env, options) => {
116108
jsc: {
117109
parser: {
118110
syntax: 'ecmascript',
119-
// NO jsx - it's already removed by custom loader below
120111
},
121112
target: 'es2015',
122113
},
123-
// env: {
124-
// mode: 'usage',
125-
// coreJs: '3.22',
126-
// targets: 'defaults',
127-
// },
128114
},
129115
},
130-
// First: Transform JSX to tag() calls
131-
path.resolve(__dirname, 'html-tag-jsx-loader.js'),
132-
// Then: Use SWC for ES6+ transpilation
133-
// {
134-
// loader: 'builtin:swc-loader',
135-
// options: {
136-
// jsc: {
137-
// parser: {
138-
// syntax: 'ecmascript',
139-
// // JSX is already transformed by custom loader above
140-
// },
141-
// target: 'es2015',
142-
// },
143-
// // env: {
144-
// // mode: 'usage',
145-
// // coreJs: '3.22',
146-
// // targets: 'defaults',
147-
// // },
148-
// },
149-
// },
116+
path.resolve(__dirname, 'utils/custom-loaders/html-tag-jsx-loader.js'),
150117
],
151118
},
152119
],

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ module.exports = function htmlTagJsxLoader(source) {
1515

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

2020
// Determine file type from extension
2121
const isTypeScript = /\.tsx?$/.test(this.resourcePath);
22-
const isJavaScript = /\.(jsx?|mjs)$/.test(this.resourcePath);
2322

2423
// Quick check: if no JSX syntax at all, pass through unchanged
2524
// Look for JSX opening tags: < followed by a letter or uppercase

0 commit comments

Comments
 (0)