require('codemirror') loads react-codemirror component
See original GitHub issueI’ve tried to embed react-codemirror
into the app as described in the example, but faced strange issue.
I got an error TypeError: CM.fromTextArea is not a function
.
After some investigation, I found that react-codemirror
loads itself here https://github.com/JedWatson/react-codemirror/blob/master/lib/Codemirror.js#L6
CM
contains CodeMirror react component.
I’m bundling project with webpack and babel. Result bundle contains 2 equal module IDs 648 and 649, and 649 depends on 648, react-codemirror
both.
Here is a sample of webpack config:
module.exports = {
context: join(__dirname, '/src'),
entry: {
app: [
'babel-polyfill',
'./scripts/master',
'./index.html'
]
},
output: {
path: join(__dirname, '/dist'),
filename: '[name].js'
},
debug: true,
devtool: null,
module: {
loaders: [
{
test: /(\.js|\.jsx)$/,
include: [
join(__dirname, 'src'),
join(__dirname, 'node_modules/react-codemirror')
],
loader: 'babel'
},
{
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&' +
'localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox')
},
]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.scss', '.css'],
modulesDirectories: [
'node_modules',
'src/scripts',
'src'
]
},
};
Issue Analytics
- State:
- Created 8 years ago
- Comments:6
Top Results From Across the Web
react-codemirror - npm
Start using react-codemirror in your project by running `npm i ... Require the CodeMirror component and render it with JSX: var React ...
Read more >scniro/react-codemirror2: Codemirror integrated ... - GitHub
requiring codemirror resources Since codemirror ships mostly unconfigured, the user is left with the responsibility for requiring any additional resources ...
Read more >[Help] Running into loader-related issue when trying to use ...
Hi, I'm just starting out with programming and trying to implement CodeMirror into a Javascript React project I'm working on.
Read more >React CodeMirror v4.19.5
CodeMirror allows to serialize editor state to JSON representation with toJSON function for persistency or other needs. This JSON representation can be later ......
Read more >CodeMirror component for React
requiring codemirror resources, This is often the case when specifying certain language modes and themes. Just set the mode, the language ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@balkonsmoke, @joshbuckley182, the issue is caused by these lines in your webpack configurations:
This causes
react-codemirror
to look forcodemirror
in its ownsrc
directory before looking innode_modules
. I would suggest changing that to something like:If this issue still persists please give react-codemirror2 a look. I’m planning on maintaining this moving forward. Better docs will be coming. Feel free to open up any issues/suggestions as I’ll be trying to gather as much constructive feedback from the community moving forward