mdx-bundler
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -63,2 +63,7 @@ "use strict"; | ||
} | ||
/** @type {(vfile: unknown) => vfile is import('vfile').VFile} */ | ||
function isVFile(vfile) { | ||
return typeof vfile === 'object' && vfile !== null && 'value' in vfile; | ||
} | ||
if (typeof source === 'string') { | ||
@@ -71,2 +76,9 @@ // The user has supplied MDX source. | ||
absoluteFiles[entryPath] = source; | ||
} else if (isVFile(source)) { | ||
const value = String(source.value); | ||
/** @type any */ // Slight type hack to get the graymatter front matter typed correctly. | ||
const gMatter = (0, _grayMatter.default)(value, grayMatterOptions({})); | ||
matter = gMatter; | ||
entryPath = source.path ? _path.default.isAbsolute(source.path) ? source.path : _path.default.join(source.cwd, source.path) : _path.default.join(cwd, `./_mdx_bundler_entry_point-${(0, _uuid.v4)()}.mdx`); | ||
absoluteFiles[entryPath] = value; | ||
} else if (typeof file === 'string') { | ||
@@ -73,0 +85,0 @@ // The user has supplied a file. |
@@ -11,2 +11,3 @@ // This file is for defining types that are annoying to define with jsdoc syntax | ||
import type {GrayMatterOption, Input, GrayMatterFile} from 'gray-matter' | ||
import type {VFile,VFileOptions} from 'vfile' | ||
@@ -23,3 +24,3 @@ type ESBuildOptions = BuildOptions | ||
*/ | ||
source: string | ||
source: string | VFile | VFileOptions | ||
file?: undefined | ||
@@ -26,0 +27,0 @@ } & BundleMDXOptions<Frontmatter> |
{ | ||
"name": "mdx-bundler", | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "Compile and bundle your MDX files and their dependencies. FAST.", | ||
@@ -49,3 +49,4 @@ "main": "dist/index.js", | ||
"remark-mdx-frontmatter": "^1.1.1", | ||
"uuid": "^8.3.2" | ||
"uuid": "^8.3.2", | ||
"vfile": "^5.3.2" | ||
}, | ||
@@ -52,0 +53,0 @@ "peerDependencies": { |
@@ -496,3 +496,3 @@ <div align="center"> | ||
This feature is best used with tweaks to `mdxOptions` and `esbuildOptions`. In | ||
the example below and `.png` files are written to the disk and then served from | ||
the example below `.png` files are written to the disk and then served from | ||
`/file/`. | ||
@@ -841,2 +841,6 @@ | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/theMosaad"><img src="https://avatars.githubusercontent.com/u/48773133?v=4?s=100" width="100px;" alt="Mosaad"/><br /><sub><b>Mosaad</b></sub></a><br /><a href="https://github.com/kentcdodds/mdx-bundler/commits?author=theMosaad" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://github.com/stefanprobst"><img src="https://avatars.githubusercontent.com/u/20753323?v=4?s=100" width="100px;" alt="stefanprobst"/><br /><sub><b>stefanprobst</b></sub></a><br /><a href="https://github.com/kentcdodds/mdx-bundler/commits?author=stefanprobst" title="Code">💻</a> <a href="https://github.com/kentcdodds/mdx-bundler/commits?author=stefanprobst" title="Tests">⚠️</a></td> | ||
</tr> | ||
</tbody> | ||
@@ -843,0 +847,0 @@ </table> |
56852
519
884
10
15
+ Addedvfile@^5.3.2