-
-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Subject
The exported toHast support passing options.handlers to provide customized logic to process certain node. The documentation for this options suggest to "Take a look at lib/handlers/ for examples.".
Most of the handlers under lib/handlers/ are written using the helper function all, one, etc. So it seems quite reasonable for custom handlers to also want to use those helper functions.
Problem
Pre-ESM migration, we can import/require directly from mdast-util-to-hast/lib/all and it will worked.
Post-ESM migration, .mjs file can't import from mdast-util-to-hast/lib/all.js since it is written using esm syntax, but does not have .mjs extension (seems like for direct file import, the type: module config in package.json is ignored?)
Solution
in index.js, we should reexport the helper functions
export {all} from './lib/all.js'
export {one} from './lib/one.js'
export {toHast} from './lib/index.js'so that we can import it like import { all, toHash } from 'mdast-util-to-hast';..
Alternatives
Copy+paste the helper functions?