Skip to content

Commit 246edd4

Browse files
jorgebucarandevongovett
authored andcommitted
Add JSX support for Hyperapp. (#825)
1 parent c7ba56a commit 246edd4

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/transforms/babel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const JSX_EXTENSIONS = {
2222
const JSX_PRAGMA = {
2323
react: 'React.createElement',
2424
preact: 'h',
25-
nervjs: 'Nerv.createElement'
25+
nervjs: 'Nerv.createElement',
26+
hyperapp: 'h'
2627
};
2728

2829
async function babelTransform(asset) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = <div />;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"hyperapp": "*"
4+
}
5+
}

test/javascript.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,13 @@ describe('javascript', function() {
683683
let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
684684
assert(file.includes('Nerv.createElement("div"'));
685685
});
686+
687+
it('should support compiling JSX in JS files with Hyperapp dependency', async function() {
688+
await bundle(__dirname + '/integration/jsx-hyperapp/index.js');
689+
690+
let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
691+
assert(file.includes('h("div"'));
692+
});
686693

687694
it('should support optional dependencies in try...catch blocks', async function() {
688695
let b = await bundle(__dirname + '/integration/optional-dep/index.js');

0 commit comments

Comments
 (0)