Error: DiffMatchPatch is not a constructor
See original GitHub issueHi all,
I am using angular-diff-match-patch 0.2.4 library with angular 1.5. My project configuration includes typescript and webpack. When I use semantic diff directive, for example:
<pre semantic-diff left-obj="..." right-obj="..."></pre>
I always receive this exception:
Error: DiffMatchPatch is not a constructor
How can I make it working with webpack?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Using google-diff-match-patch in angular - Stack Overflow
Problem is, how do I import diff_match_patch for this line? var dmp = new diff_match_patch();. javascript · angular · typescript · google-diff- ......
Read more >diff_match_patch is not a constructor when using react #6225
console error: Uncaught TypeError: diff_match_patch is not a constructor at getDiff (merge.js:649) at DiffView.init (merge.js:53)
Read more >DiffMatchPatch class - diff_match_patch library - Dart API
Class containing the diff, match and patch methods. Also contains the behaviour settings. Constructors. DiffMatchPatch(). Properties.
Read more >DiffMatchPatch (netxms-java-components 4.3-SNAPSHOT API)
public class DiffMatchPatch extends Object. Class containing the diff, match and patch methods. Also contains the behaviour settings.
Read more >How to use the diff-match-patch.diff_match_patch function in diff ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
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
See https://github.com/amweiss/angular-diff-match-patch/pull/46.
This would streamline above required steps:
Install single required webpack module. Type in the terminal:
expose diff-match-patch library in js file:
OR via webpack config
Update for @ufoscout - this ended up being how I got around the error:
then, in my service:
It’s pretty ugly and I’m sure there’s a better way to do this via Webpack.