slim down jsdom
dependency to parse5
#355
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: jsdom imports a ton of stuff. This is usually not a problem as it's been treeshaked from the different build tools. But it causes an issue when you are trying to use the
babel-solid-preset
entirely in the browser. For examplejsdom
importschild_process
, that just doesn't exist in the browser, and places likeesm.sh
cannot treeshake it because it doesn't know if it is going to be used or not. This is causing problems to projects like https://github.com/bigmistqke/repl and possibly some others.Upon investigation, it seems that
jsdom
it's using behind the scenesparse5
. So trying to slim down the dependencies I replaced it with that. This also gives me more confidence into the approach taken to validate the HTML because the functions fromparse5
actually claim they are mirroringinnerHTML
behaviour.Links:
jsdom importing parse5
https://github.com/jsdom/jsdom/blob/04541b377d9949d6ab56866760b7883a23db0577/lib/jsdom/browser/parser/html.js#L3
claim that should do the same as
innerHTML
https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/index.ts#L64
I have updated my transform to use parse5 too, so its been tested on my stuff besides
npm run test
on the babel pluginhttps://github.com/potahtml/pota/blob/master/babel-preset/transform/validate.js
We will appreciate please a patch release(whenever there's time and that's possible) so projects like https://github.com/bigmistqke/repl can continue development.
Lastly, we are not entirely sure if this will actually fix the "use in browser issue", but it will narrow it greatly to investigate further in case that's necessary.I can confirm it works entirely in the browserThanks!