Skip to content

Commit 142bec3

Browse files
authored
fix: module not found in docs (#24)
1 parent 7fdd09f commit 142bec3

File tree

18 files changed

+6243
-41
lines changed

18 files changed

+6243
-41
lines changed

api-extractor.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@
4141
}
4242
}
4343
},
44-
4544
"apiReport": {
4645
"enabled": false
4746
},
47+
4848
"docModel": {
4949
"enabled": true,
5050
"apiJsonFilePath": "<projectFolder>/docs/docs.api.json"
5151
},
5252
"dtsRollup": {
53-
"enabled": false,
53+
"enabled": true,
5454
"untrimmedFilePath": "<projectFolder>/dist/esm/index.d.ts"
5555
},
56-
"tsdocMetadata": {},
5756
"newlineKind": "lf",
5857
"messages": {
5958
"compilerMessageReporting": {

apps/wapijs.co/next.config.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
4-
};
3+
reactStrictMode: true,
4+
compiler: {
5+
removeConsole: process.env.NODE_ENV === 'production'
6+
}
7+
}
58

6-
export default nextConfig;
9+
export default nextConfig

apps/wapijs.co/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"dev": "NODE_ENV=development next dev",
66
"build": "NODE_ENV=production next build",
7-
"start": "NODE_ENV=production next start",
7+
"start": "NODE_ENV=production next start ",
88
"lint": "next lint",
99
"pretty": "pnpm prettier --write \"src/**/*.{ts,tsx,css}\""
1010
},
Binary file not shown.
-11 Bytes
Loading

apps/wapijs.co/src/app/docs/[version]/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { resolveItemUri } from '~/reusable-function'
44
import { notFound } from 'next/navigation'
55
import { addPackageToModel, fetchDocumentationJsonDataFromSlug } from '~/utils/api-extractor'
66

7+
export const revalidate = 60 * 60 * 24 * 30
8+
export const dynamicParams = true
9+
710
export default async function VersionHomeLayout({
811
children,
912
params

apps/wapijs.co/src/app/docs/[version]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { readFile } from 'node:fs/promises'
88
import getWasm from 'shiki/wasm'
99
import { fetchVersions } from '~/reusable-function'
1010

11+
export const revalidate = 60 * 60 * 24 * 30
12+
export const dynamicParams = true
13+
1114
async function fetchReadMeFileFromGithub() {
1215
if (IS_DEVELOPMENT) {
1316
const fileContent = await readFile(join(process.cwd(), '..', '..', 'README.md'), 'utf8')
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use client'
2+
3+
import Link from 'next/link'
4+
import { Button } from '@wapijs/ui'
5+
import { ArrowPathIcon, ChatBubbleBottomCenterIcon } from '@heroicons/react/24/solid'
6+
7+
export default function GlobalError({
8+
reset,
9+
error
10+
}: {
11+
error: Error & { digest?: string }
12+
reset: () => void
13+
}) {
14+
console.log({ error: error, stack: error.stack })
15+
return (
16+
<div className="flex h-[70vh] min-h-screen flex-col items-center justify-center gap-4">
17+
<h2 className="mx-auto text-center text-xl text-gray-900">
18+
Oops! Something went wrong{' '}
19+
</h2>
20+
<div className="flex gap-4">
21+
<Button onClick={() => reset()} size={'medium'}>
22+
<ArrowPathIcon className="h-6 w-6 text-white" /> Try again
23+
</Button>
24+
<Link title="contact-support" href={'/'} rel="">
25+
<Button size={'medium'} variant={'outline'}>
26+
<ChatBubbleBottomCenterIcon className="h-6 w-6 text-white" /> Contact
27+
Support
28+
</Button>
29+
</Link>
30+
</div>
31+
</div>
32+
)
33+
}

apps/wapijs.co/src/utils/api-extractor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { type ResolvedParameter } from '~/types'
1818
import { TSDocConfiguration } from '@microsoft/tsdoc'
1919
import { TSDocConfigFile } from '@microsoft/tsdoc-config'
2020
import { readFile } from 'node:fs/promises'
21-
import { join } from 'node:path'
21+
import path, { join } from 'node:path'
22+
import { readdirSync } from 'node:fs'
2223

2324
export async function fetchDocumentationJsonDataFromSlug(version: string) {
2425
try {
@@ -43,7 +44,7 @@ export async function fetchDocumentationJsonDataFromSlug(version: string) {
4344
return response
4445
}
4546
} catch (error) {
46-
console.log(error)
47+
console.error(error)
4748
return null
4849
}
4950
}
@@ -188,6 +189,9 @@ export function parametersString(item: ApiDocumentedItem & ApiParameterListMixin
188189
}
189190

190191
export function addPackageToModel(model: ApiModel, data: any) {
192+
const nodeModulesPath = path.join(process.cwd(), 'node_modules')
193+
const files = readdirSync(nodeModulesPath)
194+
console.log('node_modules:', files)
191195
const tsdocConfiguration = new TSDocConfiguration()
192196
const tsdocConfigFile = TSDocConfigFile.loadFromObject(data.metadata.tsdocConfig)
193197
tsdocConfigFile.configureParser(tsdocConfiguration)

apps/wapijs.co/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"**/*.tsx",
1414
".next/types/**/*.ts",
1515
"tailwind.config.js",
16+
"prettier.config.js",
1617
".eslintrc.js"
1718
],
1819
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)