Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Dec 19, 2024
1 parent 6d3c7d2 commit 1bfcffb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = {
// Replaced by root workspace command
ignoreDuringBuilds: true,
},
serverExternalPackages: ['ts-morph', 'typescript'],
serverExternalPackages: ['ts-morph', 'typescript', 'oxc-transform'],
experimental: {
reactCompiler: true,
},
Expand Down
1 change: 1 addition & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"katex": "^0.16.17",
"lucide-react": "^0.468.0",
"next": "15.1.1",
"oxc-transform": "^0.42.0",
"phenomenon": "^1.6.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
8 changes: 7 additions & 1 deletion apps/docs/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
import { transformerTwoslash } from 'fumadocs-twoslash';
import remarkMath from 'remark-math';
import { fileGenerator, remarkDocGen, remarkInstall } from 'fumadocs-docgen';
import {
fileGenerator,
remarkDocGen,
remarkInstall,
remarkTypeScriptToJavaScript,
} from 'fumadocs-docgen';
import rehypeKatex from 'rehype-katex';
import { z } from 'zod';
import { remarkMermaid } from '@theguild/remark-mermaid';
Expand Down Expand Up @@ -78,6 +83,7 @@ export default defineConfig({
remarkMath,
[remarkInstall, { persist: { id: 'package-manager' } }],
[remarkDocGen, { generators: [fileGenerator()] }],
remarkTypeScriptToJavaScript,
],
rehypePlugins: (v) => [rehypeKatex, ...v],
},
Expand Down
8 changes: 4 additions & 4 deletions packages/doc-gen/src/remark-ts2js.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Transformer } from 'unified';
import { type Transformer } from 'unified';
import { type Code, Root } from 'mdast';
import { visit } from 'unist-util-visit';
import { createElement, expressionToAttribute } from '@/utils';
import oxc from 'oxc-transform';

export interface TypeScriptToJavaScriptOptions {
/**
Expand Down Expand Up @@ -40,10 +39,11 @@ export function remarkTypeScriptToJavaScript({
persist = false,
disableTrigger = false,
}: TypeScriptToJavaScriptOptions = {}): Transformer<Root> {
return (tree, file) => {
return async (tree, file) => {
const oxc = await import('oxc-transform');

visit(tree, 'code', (node) => {
if (node.lang !== 'ts' && node.lang !== 'tsx') return;

if (!disableTrigger && !node.meta?.includes('ts2js')) return;

const result = oxc.transform(
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1bfcffb

Please sign in to comment.