diff_match_patch is not a constructor when using Require.js
See original GitHub issueI have a project using Require.js (ver 2.1.18) where I’m using CodeMirror (ver 5.5.1) to view/edit a JavaScript file in the browser (this and all CodeMirror addons work as expected).
I now need to show any diffs in the file, so I’ve been trying to implement the merge.js addon, but having troubles with the diff_match_patch.js lib that is also required.
// Firebug + Firefox 39.0.3
// merge.js
// (line 550, col 12)
"TypeError: diff_match_patch is not a constructor
var dmp = new diff_match_patch();"
// Chrome Version 44.0.2403.130 (64-bit)
// merge.js (551)
"Uncaught TypeError: diff_match_patch is not a function"
I can see that diff_match_patch.js is being loaded by Require, but when passed to that function in merge.js, the JavaScript error breaks the page. The Merge view doesn’t show. Changing the line
var dmp = new diff_match_patch();
to
var dmp = diff_match_patch;
allows the 2 views to render, but the dmp.diff_main map is not created.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
diff_match_patch is not a constructor when using Require.js
I have a project using Require.js (ver 2.1.18) where I'm using CodeMirror (ver 5.5.1) to view/edit a JavaScript file in the browser (this ......
Read more >diff_match_patch is not a constructor when using react #6225
here is my code: import diff_match_patch from 'diff_match_patch'; import CodeMirror from 'codemirror'; window.diff_match_patch ...
Read more >how to fix " is not a constructor" - Stack Overflow
I get a javascript file(such as gds.js), it's published from typescript. So, I have to add a *.d.ts file, when I want to...
Read more >https://pagure.io/pagure/c/e2f045f42fa71eccec5e432...
highlight.js-internals.js":2}],2:[function(require,module,exports){ +/* + * + ... + if (addPath) { + // No one else is going to attempt to use this value, ......
Read more >Code coverage report for dist/qunit.js - Trey Hunner
"function" ) { throw new Error( "QUnit logging methods require a callback ... "Member not found" error in IE8 caused by messing with...
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
Hacking the globals with webpack, works for me:
@ajinkyasurya I dumped Require.js about a year ago, and I can’t find the commit where I had this + Require.js working. I do know that I was wasn’t importing CodeMirror-related files vai a package.json file. Perhaps try importing manually?