Closed dmsnell closed 4 months ago
I'm not sure how exactly google publishes from this repo to NPM, but here are the imports I use across two files
import { Diff, DIFF_DELETE, DIFF_INSERT } from 'diff-match-patch';
import { Diff, DIFF_EQUAL, diff_match_patch } from 'diff-match-patch';
Which seems to be all of the exports from index.js
in the NPM package. We also use @types/diff-match-patch
, but once the NPM publishing is sorted I can probably PR shipping types within the module.
@TheSpyder are you using a fork's npm
package? I believe one does exist but it's unlinked from diff-match-patch
itself. Or have you created your own package?
Oh wow, I don't think my team realised the diff-match-patch NPM package was itself a fork ðŸ«
I hadn't quite figured out how I wanted to deploy the fork internally yet, it makes sense now why it seemed so difficult 😂
This might be a more interesting migration than I expected. The NPM package made some slight tweaks to the API, such as https://github.com/JackuB/diff-match-patch/pull/18
And given that I use it as ESM, perhaps I'll take the ideas in https://github.com/JackuB/diff-match-patch/pull/20 and PR those too at some point.
I'm tracking through the history and it looks like the JackuB
fork was inherited from a previous owner. But in the end the sum of it's changes are not very much. Comparing to before your surrogate pairs fix:
diff.patch
It replaces the global export with module exports:
module.exports = diff_match_patch;
module.exports['diff_match_patch'] = diff_match_patch;
module.exports['DIFF_DELETE'] = DIFF_DELETE;
module.exports['DIFF_INSERT'] = DIFF_INSERT;
module.exports['DIFF_EQUAL'] = DIFF_EQUAL;
And replaces the entire diff_match_patch.Diff
array-like class with a simple array to support JavaScript destructuring:
diff_match_patch.Diff = function(op, text) {
return [op, text];
};
I think these are very sensible changes, I'll include them in a PR to add the other NPM package boilerplate unless you have strong opposition.
There is no official
npm
package for this library. There are some which package it separately. It should build an artifact that be published directly tonpm
.