treycordova / nativejsx

JSX to native DOM API transpilation. :yellow_heart: <div> ⟹ document.createElement('div')!
MIT License
154 stars 14 forks source link

Enable ES2017 #27

Closed fregante closed 7 years ago

fregante commented 7 years ago

This should enable async/await support. es2017 has been recently finalized and published.

fregante commented 7 years ago

Actually I tested this and for whatever reason this still doesn't work :(

ERROR in ./src/content.js
Module build failed: SyntaxError: Unexpected token (147:6)
    at Parser.pp$4.raise (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp.semicolon (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:966:10)
    at Parser.pp$1.parseStatement (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:730:24)
    at Parser.pp$1.parseTopLevel (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (./node_modules/acorn-jsx/node_modules/acorn/dist/acorn.js:3098:39)
    at Object.nativejsx.transpile (./node_modules/nativejsx/source/nativejsx.js:103:21)
    at Object.module.exports (./node_modules/nativejsx-loader/index.js:10:15)

I tried passing it as an option but, while it's picked up, acorn pushes out that error.


    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'nativejsx-loader',
                    options: {
                        variablePrefix: '_',
                        acorn: {
                            ecmaVersion: 8,
                            sourceType: 'module',
                            plugins: {jsx: true},
                        }
                    }
                }
            }
        ]
    }
fregante commented 7 years ago

I think this is due to acorn-jsx 3 and acorn 4. Both need to be +1'd

treycordova commented 7 years ago

Thanks for the upgrade, @bfred-it.