rehype-parse-isomorphic
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

For pull requests, please read the contributing guidelines.

License

Apache License 2.0

This is not an official Google product.

Package Sidebar

Install

npm i rehype-parse-isomorphic

Weekly Downloads

50

Version

1.0.0

License

Apache-2.0

Unpacked Size

16.3 kB

Total Files

6

Last publish

Collaborators

  • tomeraberbach