From eb9e4a529c8a596db3a52be6a2afe53e03da6da7 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 18 Jan 2018 20:10:23 +0800 Subject: [PATCH] feat: transpile .jsx files --- lib/builder/webpack/base.config.js | 2 +- test/basic.ssr.test.js | 5 +++++ test/fixtures/basic/pages/jsx-link.js | 5 +++++ test/fixtures/basic/pages/jsx-link.jsx | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/basic/pages/jsx-link.js create mode 100644 test/fixtures/basic/pages/jsx-link.jsx diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index bc12f57a12..bca749c1cd 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -63,7 +63,7 @@ module.exports = function webpackBaseConfig({ name, isServer }) { options: vueLoader.call(this, { isServer }) }, { - test: /\.js$/, + test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, options: this.getBabelOptions({ isServer }) diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index 64657f1158..45d0d230fc 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -306,6 +306,11 @@ test('/jsx', async t => { t.true(html.includes('

JSX Page

')) }) +test('/jsx-link', async t => { + const { html } = await nuxt.renderRoute('/jsx-link') + t.true(html.includes('

JSX Link Page

')) +}) + test('/js-link', async t => { const { html } = await nuxt.renderRoute('/js-link') t.true(html.includes('

vue file is first-class

')) diff --git a/test/fixtures/basic/pages/jsx-link.js b/test/fixtures/basic/pages/jsx-link.js new file mode 100644 index 0000000000..58424174c3 --- /dev/null +++ b/test/fixtures/basic/pages/jsx-link.js @@ -0,0 +1,5 @@ +import renderLink from './jsx-link.jsx' + +export default { + render: renderLink +} diff --git a/test/fixtures/basic/pages/jsx-link.jsx b/test/fixtures/basic/pages/jsx-link.jsx new file mode 100644 index 0000000000..e36e7df03b --- /dev/null +++ b/test/fixtures/basic/pages/jsx-link.jsx @@ -0,0 +1,5 @@ +export default function (h) { + return (
+

JSX Link Page

+
) +}