Skip to content

Commit

Permalink
Add JSX support for Hyperapp. (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgebucaran authored and devongovett committed Feb 16, 2018
1 parent c7ba56a commit 246edd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transforms/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const JSX_EXTENSIONS = {
const JSX_PRAGMA = {
react: 'React.createElement',
preact: 'h',
nervjs: 'Nerv.createElement'
nervjs: 'Nerv.createElement',
hyperapp: 'h'
};

async function babelTransform(asset) {
Expand Down
1 change: 1 addition & 0 deletions test/integration/jsx-hyperapp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = <div />;
5 changes: 5 additions & 0 deletions test/integration/jsx-hyperapp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"hyperapp": "*"
}
}
7 changes: 7 additions & 0 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@ describe('javascript', function() {
let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
assert(file.includes('Nerv.createElement("div"'));
});

it('should support compiling JSX in JS files with Hyperapp dependency', async function() {
await bundle(__dirname + '/integration/jsx-hyperapp/index.js');

let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
assert(file.includes('h("div"'));
});

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

0 comments on commit 246edd4

Please sign in to comment.