@astrojs/mdx 5.0.0-beta.8 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js
CHANGED
|
@@ -33,7 +33,7 @@ async function renderToStaticMarkup(Component, props = {}, { default: children =
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
function throwEnhancedErrorIfMdxComponent(error, Component) {
|
|
36
|
-
if (Component[Symbol.for("mdx-component")]) {
|
|
36
|
+
if (Component[/* @__PURE__ */ Symbol.for("mdx-component")]) {
|
|
37
37
|
if (AstroError.is(error)) return;
|
|
38
38
|
error.title = error.name;
|
|
39
39
|
error.hint = `This issue often occurs when your MDX component encounters runtime errors.`;
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
USES_ASTRO_IMAGE_FLAG
|
|
6
6
|
} from "./rehype-images-to-component.js";
|
|
7
7
|
import { getFileInfo } from "./utils.js";
|
|
8
|
-
import { mdxMetadataMap } from "./vite-plugin-mdx.js";
|
|
9
8
|
const underscoreFragmentImportRegex = /[\s,{]_Fragment[\s,}]/;
|
|
10
9
|
const astroTagComponentImportRegex = /[\s,{]__astro_tag_component__[\s,}]/;
|
|
11
10
|
function vitePluginMdxPostprocess(astroConfig) {
|
|
@@ -18,13 +17,6 @@ function vitePluginMdxPostprocess(astroConfig) {
|
|
|
18
17
|
handler(code, id) {
|
|
19
18
|
const fileInfo = getFileInfo(id, astroConfig);
|
|
20
19
|
const [imports, exports] = parse(code);
|
|
21
|
-
const usesShiki = astroConfig.markdown.syntaxHighlight === "shiki" || astroConfig.markdown.syntaxHighlight === void 0;
|
|
22
|
-
const metadata = mdxMetadataMap.get(id);
|
|
23
|
-
const hasCodeBlocks = metadata?.hasCodeBlocks ?? false;
|
|
24
|
-
if (usesShiki && hasCodeBlocks) {
|
|
25
|
-
code = `import 'virtual:astro:shiki-styles.css';
|
|
26
|
-
${code}`;
|
|
27
|
-
}
|
|
28
20
|
code = injectUnderscoreFragmentImport(code, imports);
|
|
29
21
|
code = injectMetadataExports(code, exports, fileInfo);
|
|
30
22
|
code = transformContentExport(code, exports);
|
package/dist/vite-plugin-mdx.js
CHANGED
|
@@ -2,7 +2,6 @@ import { getAstroMetadata } from "astro/jsx/rehype.js";
|
|
|
2
2
|
import { VFile } from "vfile";
|
|
3
3
|
import { createMdxProcessor } from "./plugins.js";
|
|
4
4
|
import { safeParseFrontmatter } from "./utils.js";
|
|
5
|
-
const mdxMetadataMap = /* @__PURE__ */ new Map();
|
|
6
5
|
function vitePluginMdx(opts) {
|
|
7
6
|
let processor;
|
|
8
7
|
let sourcemapEnabled;
|
|
@@ -59,8 +58,6 @@ function vitePluginMdx(opts) {
|
|
|
59
58
|
}
|
|
60
59
|
try {
|
|
61
60
|
const compiled = await processor.process(vfile);
|
|
62
|
-
const hasCodeBlocks = vfile.data.astro?.hasCodeBlocks ?? false;
|
|
63
|
-
mdxMetadataMap.set(id, { hasCodeBlocks });
|
|
64
61
|
return {
|
|
65
62
|
code: String(compiled.value),
|
|
66
63
|
map: compiled.map,
|
|
@@ -90,12 +87,9 @@ function getMdxMeta(vfile) {
|
|
|
90
87
|
// Setting this vite metadata to `ts` causes Vite to resolve .js
|
|
91
88
|
// extensions to .ts files.
|
|
92
89
|
lang: "ts"
|
|
93
|
-
}
|
|
94
|
-
// Pass hasCodeBlocks flag to postprocess plugin
|
|
95
|
-
hasCodeBlocks: vfile.data.astro?.hasCodeBlocks ?? false
|
|
90
|
+
}
|
|
96
91
|
};
|
|
97
92
|
}
|
|
98
93
|
export {
|
|
99
|
-
mdxMetadataMap,
|
|
100
94
|
vitePluginMdx
|
|
101
95
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/mdx",
|
|
3
3
|
"description": "Add support for MDX pages in your Astro site",
|
|
4
|
-
"version": "5.0.0
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mdx-js/mdx": "^3.1.1",
|
|
32
|
-
"acorn": "^8.
|
|
32
|
+
"acorn": "^8.16.0",
|
|
33
33
|
"es-module-lexer": "^2.0.0",
|
|
34
34
|
"estree-util-visit": "^2.0.0",
|
|
35
35
|
"hast-util-to-html": "^9.0.5",
|
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
"source-map": "^0.7.6",
|
|
41
41
|
"unist-util-visit": "^5.1.0",
|
|
42
42
|
"vfile": "^6.0.3",
|
|
43
|
-
"@astrojs/markdown-remark": "7.0.0
|
|
43
|
+
"@astrojs/markdown-remark": "7.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"astro": "^6.0.0-alpha.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@shikijs/rehype": "^4.0.0",
|
|
50
|
+
"@shikijs/twoslash": "^4.0.0",
|
|
49
51
|
"@types/estree": "^1.0.8",
|
|
50
52
|
"@types/hast": "^3.0.4",
|
|
51
53
|
"@types/mdast": "^4.0.4",
|
|
@@ -57,12 +59,11 @@
|
|
|
57
59
|
"rehype-pretty-code": "^0.14.1",
|
|
58
60
|
"remark-math": "^6.0.0",
|
|
59
61
|
"remark-rehype": "^11.1.2",
|
|
60
|
-
"remark-shiki-twoslash": "^3.1.3",
|
|
61
62
|
"remark-toc": "^9.0.0",
|
|
62
|
-
"shiki": "^
|
|
63
|
+
"shiki": "^4.0.0",
|
|
63
64
|
"unified": "^11.0.5",
|
|
64
65
|
"vite": "^7.3.1",
|
|
65
|
-
"astro": "6.0.0
|
|
66
|
+
"astro": "6.0.0",
|
|
66
67
|
"astro-scripts": "0.0.14"
|
|
67
68
|
},
|
|
68
69
|
"engines": {
|