Skip to content

Commit

Permalink
add JSX support for "Nerv" (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane authored and devongovett committed Feb 16, 2018
1 parent 852f6b3 commit 1e12975
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 @@ -21,7 +21,8 @@ const JSX_EXTENSIONS = {

const JSX_PRAGMA = {
react: 'React.createElement',
preact: 'h'
preact: 'h',
nervjs: 'Nerv.createElement'
};

async function babelTransform(asset) {
Expand Down
1 change: 1 addition & 0 deletions test/integration/jsx-nervjs/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-nervjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"nervjs": "*"
}
}
7 changes: 7 additions & 0 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ describe('javascript', function() {
assert(file.includes('h("div"'));
});

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

let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
assert(file.includes('Nerv.createElement("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 1e12975

Please sign in to comment.