react-diff-viewer icon indicating copy to clipboard operation
react-diff-viewer copied to clipboard

"jsdiff" methods Tree Shaking removing

Open claviustales opened this issue 5 years ago • 0 comments
trafficstars

We use Tree Shaking in our project. It removes dead-code.

It is removing "diffChars" method from "jsdiff" lib.

We are doing the following workaround:

- import DiffViewer from "react-diff-viewer";
+ import DiffViewer, { DiffMethod } from "react-diff-viewer";
+ import { diffChars } from "diff";

  <DiffViewer
    oldValue={props.oldValue}
    newValue={props.newValue}
+   compareMethod={diffChars.name as DiffMethod.CHARS}
  />

We suggest to improve typing on following code to prevent Tree Shaking:

https://github.com/praneshr/react-diff-viewer/blob/9ac4ba90643f0695179aebab6ce6311adbad0f11/src/compute-lines.ts#L3

claviustales avatar Aug 12 '20 20:08 claviustales