-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor svg2js to use txml #1301
Conversation
Using txml as XML parser fixes a ton of open svgo issues related to XML parsing.
Edit: Added a PR with tests that pass when tXML parser is used: https://github.com/strarsis/svgo/tree/parser-tests |
@GreLI: It would be great if this can be reviewed and merged! 🐱 |
Nice to see there is some new work going on here with svgo. I see the svg parser is now a sync function and I think this is good. I would refactor this PR to also work synchronous. That would actually be the default behavior of @TrySound but first I would like to hear your opinion. |
Changing parser is a big shift. I will try to fix existing issues first and then come back to this change. Through2 look not necessary. Can be replaced with
AFAIK rollup will still hoist lazy requires to convert into es modules. You better split stream based extension into separate entry point. |
hi, I made an update to txml, to work better with rollup. having two entry points as you suggested, that is pretty good. (now on github only, will publish that update soon to npm.) The parser is now 17kb(uncompressed and still include all comments and formatting.) I tried to run the refactoring I made in this PR, with the new version. All your new updates and updated tests. Local I have it so far, as that all tests run through, but many produce a somewhat different result (not good). Are you still interested to consider using txml for svgo? Then I would see if I can pass all tests again within the new version. @TrySound @strarsis |
just a little update, on my current work, I have the current and my refactoring in theory produce the same output just compared via |
@TobiasNickel @SethFalco: It would be great if this could be merged! A purely JS, fast and efficiently designed XML parser as drop-in replacement would be a great improvement for
|
Hey hey! I'll look at this in future, but for now, I've been prioritizing bug fixes and optimizations in existing plugins, similarly to TrySound when he was reviewing this. I've also been putting off touching dependencies in general:
I wanted to look at our XML library anyway, since our "maintained fork" of If we were to change the library, Once I've gotten the repository to a more manageable/stable state, it'll be a lot easier to pester all the maintainers to spare some time to discuss this publicly in an RFC (GitHub issue). I'll ping you in it too ofc. |
Hi,
I refactored the svg2js file. The goal was to use txml instead of the sax parser. The reason for that is, that txml is pure js. There will be no issues about compiling any native modules. It is also much faster than the native module.
Please see: The only files changed are
package.json
,package-lock.json
and thesvg2js.js
. Even dough there is such a fundamental refactoring, all tests are still passing ! ! !What do you think of this? Do you think this can help people who are using SVGO, running it on various platform (local + docker) and it can help people who do not have a c compiler installed.
DISCLAIMER: I am the author of txml