rehype-parse-isomorphic
v1.0.0
Published
A module that exports rehype-parse for Node.js and rehype-dom-parse for the browser.
Downloads
26
Maintainers
Readme
Install
$ npm i rehype-parse-isomorphic
Usage
Use just like
rehype-parse
and
rehype-dom-parse
.
[!WARNING]
The two libraries do not have exactly the same options. Make sure you account for the differences when the library is used in Node.js vs the browser.
Why?
It's better to use rehype-dom-parse
than rehype-parse
in the browser because
the former has a significantly smaller bundle size
(~8 kB vs
~63 kB).
Typically it's possible to just import rehype-parse
in Node.js and
rehype-dom-parse
in the browser, but not always. Sometimes you want to parse
HTML in code that can be used in either the browser or Node.js (i.e. in
isomorphic code). Which
library would you import in that code?
Without this module you'd be forced to import the lowest common denominator, the
library that works in both Node.js and the browser, which would be
rehype-parse
. And now your browser JavaScript bundle is ~55 kB bigger than it
should have been! With this module, you use the right library in each
environment.
Contributing
Stars are always welcome!
For bugs and feature requests, please create an issue.
For pull requests, please read the contributing guidelines.
License
This is not an official Google product.