diff --git a/src/transforms/babel.js b/src/transforms/babel.js index 9bd13218327..0a09df25f83 100644 --- a/src/transforms/babel.js +++ b/src/transforms/babel.js @@ -21,7 +21,8 @@ const JSX_EXTENSIONS = { const JSX_PRAGMA = { react: 'React.createElement', - preact: 'h' + preact: 'h', + nervjs: 'Nerv.createElement' }; async function babelTransform(asset) { diff --git a/test/integration/jsx-nervjs/index.js b/test/integration/jsx-nervjs/index.js new file mode 100644 index 00000000000..8d097d55d7f --- /dev/null +++ b/test/integration/jsx-nervjs/index.js @@ -0,0 +1 @@ +module.exports =
; diff --git a/test/integration/jsx-nervjs/package.json b/test/integration/jsx-nervjs/package.json new file mode 100644 index 00000000000..2116d0e162c --- /dev/null +++ b/test/integration/jsx-nervjs/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "nervjs": "*" + } +} diff --git a/test/javascript.js b/test/javascript.js index 4c8693a760a..e394ba47407 100644 --- a/test/javascript.js +++ b/test/javascript.js @@ -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');