siefkenj / unified-latex

Utilities for parsing and manipulating LaTeX ASTs with the Unified.js framework
MIT License
85 stars 20 forks source link

Possibility of downgrading `unified` dependency to 9.2.2 #32

Closed James-Yu closed 1 year ago

James-Yu commented 1 year ago

First, thank you so much for your implementation of LaTeX parser!

I am the author and maintainer of a Visual Studio Code extension called LaTeX Workshop, which provides all-in-one typesetting help to Code users.

We recently launched an initiative to adopt unified-latex as the backbone parser of the extension in https://github.com/James-Yu/LaTeX-Workshop/pull/3879 . The result is very promising except for one thing: Code cannot consume ESM.

I have gone through the tracker and noticed that it is unified who is ESM-only in #15 . So I wonder if there is a possibility that unified-latex may have a variant that depends on the previous major version, i.e., v9.2.2? This change will absolutely improve the exposure of unified-latex to the electron or Code people, and some other major unified users are still sticking to that version, e.g., prettier.

Looking forward to your comment!

siefkenj commented 1 year ago

It's great to hear from you. LaTeX Workshop is a great project!

I've never thought about downgrading before (though I have experienced the annoyance of unifiedjs not having a cjs option...).

I have two thoughts:

  1. If you do a search-and-replace for the unified versions and downgrade them all, if the test suite passes, I wouldn't mind a PR that downgrades the dep.
  2. Currently unified-latex builds esm and cjs versions, but the cjs version doesn't work...That's because the build script externalizes the same modules for the esm and cjs build. Unifiedjs is externalized in the cjs build, but obviously it cannot be loaded as cjs. I think a good solution would be to modify the build.js files to not externalize any of the strictly-esm deps. Doing so would make the files bigger and would add duplicate dependencies, but at this point, cjs would mostly be used from disk, and so the larger size probably wouldn't be an issue.
James-Yu commented 1 year ago

Nice! I will try the first route in the following days and see if that may work.