diff --git a/index.js b/index.js index ee6168d..c867066 100644 --- a/index.js +++ b/index.js @@ -151,16 +151,19 @@ var extensions = { '.js': null, '.json': null, '.json5': 'json5/lib/register', - '.jsx': { - module: '@babel/register', - register: function (hook) { - hook({ - extensions: '.jsx', - rootMode: 'upward-optional', - overrides: [{ only: [endsInJsx] }], - }); + '.jsx': [ + { + module: '@babel/register', + register: function (hook) { + hook({ + extensions: '.jsx', + rootMode: 'upward-optional', + overrides: [{ only: [endsInJsx] }], + }); + }, }, - }, + 'sucrase/register/jsx' + ], '.litcoffee': 'coffeescript/register', '.mjs': mjsStub, '.node': null, diff --git a/test/fixtures/jsx/1/package.json b/test/fixtures/jsx/1/package.json new file mode 100644 index 0000000..dc0534c --- /dev/null +++ b/test/fixtures/jsx/1/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "sucrase": "^3.12.1" + } +} diff --git a/test/fixtures/jsx/1/test.jsx b/test/fixtures/jsx/1/test.jsx new file mode 100644 index 0000000..1e2bee9 --- /dev/null +++ b/test/fixtures/jsx/1/test.jsx @@ -0,0 +1,17 @@ +const React = { + createElement: function (Component) { + return Component(); + }, +}; + +// Test harmony arrow functions +const Component = () => { + var trueKey = true; + var falseKey = false; + var subKey = { subProp: 1 }; + // Test harmony object short notation + return { data: { trueKey, falseKey, subKey } }; +}; + +// Test JSX syntax +module.exports = ;