Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(remix-dev): replace xdm with @mdx-js/mdx v2 #4054

Merged
merged 8 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
- jacargentina
- jacob-ebey
- JacobParis
- jacobwgillespie
- jack-r-warren
- jakeginnivan
- jakewtaylor
Expand Down
10 changes: 5 additions & 5 deletions packages/remix-dev/compiler/plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function mdxPlugin({ config }: Pick<Context, "config">): esbuild.Plugin {
return {
name: "remix-mdx",
async setup(build) {
let [xdm, { default: remarkFrontmatter }] = await Promise.all([
import("xdm"),
let [mdx, { default: remarkFrontmatter }] = await Promise.all([
import("@mdx-js/mdx"),
import("remark-frontmatter") as any,
]);

Expand Down Expand Up @@ -48,7 +48,7 @@ export function mdxPlugin({ config }: Pick<Context, "config">): esbuild.Plugin {
let absolutePath = path.join(config.appDirectory, args.path);

return processMDX(
xdm,
mdx,
remarkFrontmatter,
config,
args.path,
Expand All @@ -61,7 +61,7 @@ export function mdxPlugin({ config }: Pick<Context, "config">): esbuild.Plugin {

export async function processMDX(
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
xdm: typeof import("xdm"),
mdx: typeof import("@mdx-js/mdx"),
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
remarkFrontmatter: typeof import("remark-frontmatter")["default"],
config: Pick<Context, "config">["config"],
Expand Down Expand Up @@ -97,7 +97,7 @@ export const meta = typeof attributes !== "undefined" && attributes.meta;
export const handle = typeof attributes !== "undefined" && attributes.handle;
`;

let compiled = await xdm.compile(fileContents, {
let compiled = await mdx.compile(fileContents, {
jsx: true,
jsxRuntime: "automatic",
rehypePlugins,
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/utils/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const loaders: { [ext: string]: esbuild.Loader } = {
".js": "jsx",
".jsx": "jsx",
".json": "json",
// We preprocess md and mdx files using XDM and send through
// We preprocess md and mdx files using @mdx-js/mdx and send through
// the JSX for esbuild to handle
".md": "jsx",
".mdx": "jsx",
Expand Down
24 changes: 2 additions & 22 deletions packages/remix-dev/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,34 +67,14 @@ declare module "*.jpg" {
export default asset;
}
declare module "*.md" {
import type { ComponentType, ReactHTML } from "react";
import "mdx/types";
export let attributes: any;
export let filename: string;
let Component: ComponentType<
Readonly<Record<string, unknown>> & {
components?: Readonly<
Partial<
Record<keyof ReactHTML | "wrapper", keyof ReactHTML | ComponentType>
>
>;
}
>;
export default Component;
}
declare module "*.mdx" {
import type { ComponentType, ReactHTML } from "react";
import "mdx/types";
export let attributes: any;
export let filename: string;
let Component: ComponentType<
Readonly<Record<string, unknown>> & {
components?: Readonly<
Partial<
Record<keyof ReactHTML | "wrapper", keyof ReactHTML | ComponentType>
>
>;
}
>;
export default Component;
}
declare module "*.mp3" {
let asset: string;
Expand Down
5 changes: 3 additions & 2 deletions packages/remix-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"@babel/preset-typescript": "^7.21.5",
"@babel/traverse": "^7.21.5",
"@babel/types": "^7.21.5",
"@mdx-js/mdx": "^2.3.0",
"@npmcli/package-json": "^2.0.0",
"@remix-run/server-runtime": "1.19.2",
"@types/mdx": "^2.0.5",
"@vanilla-extract/integration": "^6.2.0",
"arg": "^5.0.1",
"cacache": "^17.1.3",
Expand Down Expand Up @@ -68,8 +70,7 @@
"sort-package-json": "^1.55.0",
"tar-fs": "^2.1.1",
"tsconfig-paths": "^4.0.0",
"ws": "^7.4.5",
"xdm": "^2.0.0"
"ws": "^7.4.5"
},
"devDependencies": {
"@remix-run/serve": "1.19.2",
Expand Down
Loading