Skip to content

Invalid babel syntax #20

Description

@tauren

I'd like to display some code samples within the page, not actually render it. But I'm getting an error.

I'm not quite sure if the problem is in this loader or not. When I add the following to a markdown file that is processed through this loader and then through babel, I get a BabelLoaderError: SyntaxError: Unexpected token (46:227) error.

```js
function Sample () {
  return 'hi'
}
​```

Here is the full error:

ERROR in ./src/elements/Hello/readme.md
Module build failed: SyntaxError: Unexpected token (46:227)

  44 |     </code></pre>
  45 |   </div>
> 46 | </div><pre><code className="language-js"><span className="token keyword" >function</span> Sample <span className="token punctuation" >(</span><span className="token punctuation" >)</span> <span className="token punctuation" >{</span>
     |                                                                                                                                                                                                                                    ^
  47 |   <span className="token keyword" >return</span> <span className="token string" >'hi'</span>
  48 | <span className="token punctuation" >}</span>
  49 | </code></pre>

BabelLoaderError: SyntaxError: Unexpected token (46:227)

  44 |     </code></pre>
  45 |   </div>
> 46 | </div><pre><code className="language-js"><span className="token keyword" >function</span> Sample <span className="token punctuation" >(</span><span className="token punctuation" >)</span> <span className="token punctuation" >{</span>
     |                                                                                                                                                                                                                                    ^
  47 |   <span className="token keyword" >return</span> <span className="token string" >'hi'</span>
  48 | <span className="token punctuation" >}</span>
  49 | </code></pre>

    at transpile (/Users/tauren/repos/component-lab/node_modules/babel-loader/lib/index.js:61:13)
    at Object.module.exports (/Users/tauren/repos/component-lab/node_modules/babel-loader/lib/index.js:155:20)
 @ ./src/elements/index.js 14:0-44
 @ ./src/app/Main/index.js
 @ ./src/app/App/index.js
 @ ./src/app/Root/index.js
 @ ./src/index.js
 @ multi ./~/react-hot-loader/patch.js ./~/babel-polyfill/lib/index.js ./src/index.js webpack-dev-server/client?http://localhost:5000/ webpack/hot/dev-server

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions