kjelsrud.dev/node_modules/hast-util-to-estree/lib/handlers/mdxjs-esm.js
2023-07-19 21:31:30 +02:00

27 lines
651 B
JavaScript

/**
* @typedef {import('mdast-util-mdxjs-esm').MdxjsEsm} MdxjsEsm
* @typedef {import('../state.js').State} State
*/
import {attachComments} from 'estree-util-attach-comments'
/**
* Handle an MDX ESM node.
*
* @param {MdxjsEsm} node
* hast node to transform.
* @param {State} state
* Info passed around about the current state.
* @returns {void}
* Nothing.
*/
export function mdxjsEsm(node, state) {
const estree = node.data && node.data.estree
const comments = (estree && estree.comments) || []
if (estree) {
state.comments.push(...comments)
attachComments(estree, comments)
state.esm.push(...estree.body)
}
}