Skip to content

Commit e52023f

Browse files
committed
feat: support jsx
1 parent 160640e commit e52023f

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/core/constant.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ export const comments: Comment[] = [
88
end: '',
99
regex: /^\/\/\s?(.*)$/,
1010
},
11+
// jsx
12+
{
13+
type: 'jsx',
14+
start: '{/* ',
15+
end: ' */}',
16+
regex: /^\{\s?\/\*\s?(.*)\s?\*\/\s?\}$/,
17+
},
1118
// css
1219
{
1320
type: 'css',

test/__snapshots__/if.test.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ console.log('!DEV else')
5353
console.log('TEST')
5454
console.log('else')"
5555
`;
56+
57+
exports[`if > should parse if.jsx, dev = false 1`] = `
58+
"const Component = () => <div>
59+
</div>;"
60+
`;
61+
62+
exports[`if > should parse if.jsx, dev = true 1`] = `
63+
"const Component = () => <div>
64+
DEV
65+
DEV=true
66+
</div>;"
67+
`;

test/fixtures/if.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const Component = () => <div>
2+
{/* #if DEV */}
3+
DEV
4+
{/* #endif */}
5+
{/* #if DEV=true */}
6+
DEV=true
7+
{/* #endif */}
8+
{/* #if !PROD!=true */}
9+
!PROD!=true
10+
{/* #endif */}
11+
</div>;

0 commit comments

Comments
 (0)