Skip to content

A module that exports rehype-parse for Node.js and rehype-dom-parse for the browser.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
license-apache
MIT
license-mit
Notifications You must be signed in to change notification settings

TomerAberbach/rehype-parse-isomorphic

Repository files navigation

rehype-parse-isomorphic

A module that exports rehype-parse for Node.js and rehype-dom-parse for the browser.

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.

License

MIT © Tomer Aberbach
Apache 2.0 © Google

About

A module that exports rehype-parse for Node.js and rehype-dom-parse for the browser.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
license-apache
MIT
license-mit

Stars

Watchers

Forks

Sponsor this project