Skip to content

Tracking Issue: Generate and publish npm package of JavaScript library. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmsnell opened this issue Jan 31, 2024 · 5 comments · Fixed by #6
Closed

Tracking Issue: Generate and publish npm package of JavaScript library. #3

dmsnell opened this issue Jan 31, 2024 · 5 comments · Fixed by #6

Comments

@dmsnell
Copy link
Owner

dmsnell commented Jan 31, 2024

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 to npm.

@dmsnell dmsnell pinned this issue Jan 31, 2024
@dmsnell dmsnell changed the title Tracking issue: Generate and publish npm package of JavaScript library. Tracking Issue: Generate and publish npm package of JavaScript library. Jan 31, 2024
@TheSpyder
Copy link

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.

@dmsnell
Copy link
Owner Author

dmsnell commented Jan 31, 2024

@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?

@TheSpyder
Copy link

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 😂

@TheSpyder
Copy link

This might be a more interesting migration than I expected. The NPM package made some slight tweaks to the API, such as JackuB/diff-match-patch#18

And given that I use it as ESM, perhaps I'll take the ideas in JackuB/diff-match-patch#20 and PR those too at some point.

@TheSpyder
Copy link

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.

TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue Feb 16, 2024
TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue Feb 19, 2024
TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue May 2, 2024
TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue Jun 17, 2024
…JackuB/diff-match-patch. Swap to ESM. Fixes dmsnell#3.

Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>
TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue Jun 17, 2024
…JackuB/diff-match-patch. Swap to ESM. Fixes dmsnell#3.

Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>
TheSpyder added a commit to TheSpyder/diff-match-patch that referenced this issue Jun 17, 2024
…JackuB/diff-match-patch. Swap to ESM. Fixes dmsnell#3.

Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants