🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
42
node_modules/@mdx-js/mdx/lib/plugin/recma-stringify.js
generated
vendored
Normal file
42
node_modules/@mdx-js/mdx/lib/plugin/recma-stringify.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @typedef {import('estree-jsx').Program} Program
|
||||
* @typedef {typeof import('source-map').SourceMapGenerator} SourceMapGenerator
|
||||
*
|
||||
* @typedef RecmaStringifyOptions
|
||||
* Configuration for internal plugin `recma-stringify`.
|
||||
* @property {SourceMapGenerator | null | undefined} [SourceMapGenerator]
|
||||
* Generate a source map by passing a `SourceMapGenerator` from `source-map`
|
||||
* in.
|
||||
*/
|
||||
|
||||
import {toJs, jsx} from 'estree-util-to-js'
|
||||
|
||||
/**
|
||||
* A plugin that adds an esast compiler: a small wrapper around `astring` to add
|
||||
* support for serializing JSX.
|
||||
*
|
||||
* @this {import('unified').Processor}
|
||||
* @type {import('unified').Plugin<[RecmaStringifyOptions | null | undefined] | [], Program, string>}
|
||||
*/
|
||||
export function recmaStringify(options) {
|
||||
// Always given inside `@mdx-js/mdx`
|
||||
/* c8 ignore next */
|
||||
const {SourceMapGenerator} = options || {}
|
||||
|
||||
Object.assign(this, {Compiler: compiler})
|
||||
|
||||
/** @type {import('unified').CompilerFunction<Program, string>} */
|
||||
function compiler(tree, file) {
|
||||
const result = SourceMapGenerator
|
||||
? toJs(tree, {
|
||||
filePath: file.path || 'unknown.mdx',
|
||||
SourceMapGenerator,
|
||||
handlers: jsx
|
||||
})
|
||||
: toJs(tree, {handlers: jsx})
|
||||
|
||||
file.map = result.map
|
||||
|
||||
return result.value
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue