question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES6 compatibility

See original GitHub issue

I’m trying to use react-codemirror in my ES6 project but it fails.

Importing it that way:

import CodeMirror from 'react-codemirror';

Getting the following error:

[0] ./~/react-codemirror/src/codemirror.js
[0] Module parse failed: app/node_modules/react-codemirror/src/codemirror.js Unexpected token (76:3)
[0] You may need an appropriate loader to handle this file type.
[0] SyntaxError: Unexpected token (76:3)
...
[0]  @ ./~/react-codemirror/lib/Codemirror.js 20:42-63

Am I doing something wrong or is the project not compatible yet?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
fantasy8-mecommented, May 30, 2016

I encounter a similar error

Time: 21025ms
 Asset     Size  Chunks       Chunk Names
app.js  8.46 MB       0       main
chunk    {0} app.js (main) 3.09 MB [rendered]

ERROR in ./~/react-codemirror/src/codemirror.js
Module parse failed: /Users/me/Work/WS/sublime-master-ws/prj-reedsec/reedsec-dashboard/node_modules/react-codemirror/src/codemirror.js Unexpected token (76:3)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (76:3)

I found the problem caused by webpack loading setting, in below line https://github.com/JedWatson/react-codemirror/blob/master/src/Codemirror.js#L17

it is expected to load ‘codemirror’ in ‘node_module’

But if we have webpack like below, which treat ‘src’ as module folder too, then ‘https://github.com/JedWatson/react-codemirror/blob/master/src/Codemirror.js’ itself might be load and cause the error

  resolve: {
    modulesDirectories: [
      'src',
      'node_modules'
    ],
    extensions: ['', '.json', '.js', '.jsx']
  },

Remove above resolve setting can solve the problem, but can we change the src file name(Codemirror.js) to avoid conflict with the ‘codemirror’ module for safety

0reactions
OleksiiShevchenkocommented, Dec 28, 2016

You can change webpack config rather than rename a file https://github.com/JedWatson/react-codemirror/issues/39#issuecomment-220799966

Read more comments on GitHub >

github_iconTop Results From Across the Web

"es6" | Can I use... Support tables for HTML5, CSS3, etc
As ES6 refers to a huge specification and browsers have various levels of support, "Supported" means at least 95% of the spec is...
Read more >
ECMAScript 6 compatibility table
Feature name▻ Current browser 98% ES6 Trans‑ piler 25% Trace... Optimisation Optimisation Optimisation Optimi... §proper tail calls (tail call optimisation)▻ 0/2 0/2 0/2 §direct recursionc No...
Read more >
JavaScript Versions - W3Schools
ECMAScript versions have been abbreviated to ES1, ES2, ES3, ES5, and ES6. ... Internet Explorer 9 does not support ECMAScript 5 "use strict"....
Read more >
Browser Compatibility Testing of JAVASCRIPT with ES6 classes
BROWSER SUPPORT FOR JAVASCRIPT ES6 classes · Google Chrome · Mozilla Firefox · Internet Explorer · Safari · Microsoft Edge · Opera.
Read more >
Why You Should Use ES6 - ITNEXT
It is called a “compiler” because it converts ES6 code to ES5 code so that as long as your browser can support ES5,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found