@@ -7,10 +7,25 @@ import { existsSync } from 'node:fs';
77const apisidebarPath = './apisidebar.json' ;
88let hasAPIsidebar = existsSync ( apisidebarPath ) ;
99
10- const plugins = [
10+ // Only include it when running on the server (during Node execution).
11+ const isRanOnTheServer = typeof window === 'undefined' ;
12+
13+ const plugins : any [ ] = [
1114 require . resolve ( './sitePlugin' ) ,
1215 [ 'docusaurus-node-polyfills' , { excludeAliases : [ 'console' ] } ] ,
1316 'docusaurus-plugin-sass' ,
17+ ( ) => ( {
18+ name : 'exclude-typedoc-from-client' ,
19+ configureWebpack ( ) {
20+ return {
21+ resolve : {
22+ alias : {
23+ typedoc : false , // Exclude typedoc from browser bundle
24+ }
25+ }
26+ } ;
27+ }
28+ } ) ,
1429 [
1530 'doc-docusaurus-rfg-plugin' ,
1631 {
@@ -22,32 +37,39 @@ const plugins = [
2237 }
2338 ] ,
2439 // Only include this plugin when the apisidebar file has been generated.
25- hasAPIsidebar
40+ ... ( hasAPIsidebar
2641 ? [
27- '@docusaurus/plugin-content-docs' ,
28- {
29- id : 'api' ,
30- path : 'api' ,
31- routeBasePath : 'api' ,
32- sidebarPath : require . resolve ( apisidebarPath ) ,
33- disableVersioning : false
34- }
42+ [
43+ '@docusaurus/plugin-content-docs' ,
44+ {
45+ id : 'api' ,
46+ path : 'api' ,
47+ routeBasePath : 'api' ,
48+ sidebarPath : require . resolve ( apisidebarPath ) ,
49+ disableVersioning : false
50+ }
51+ ]
3552 ]
36- : null ,
37- [
38- 'doc-docusaurus-typedoc-plugin' ,
39- {
40- version,
41- outDir : './api' ,
42- sidebarFile : './apisidebar.json' ,
43- typedoc : {
44- entryPoints : [ '../../packages/render/src/index.ts' ] ,
45- tsconfig : '../../packages/render/tsconfig.json' ,
46- excludePrivate : true
47- }
48- }
49- ]
50- ] . filter ( ( c ) => c !== null ) ;
53+ : [ ] ) ,
54+ // Typedoc plugin depends on Node-only modules (child_process, inspector, etc.).
55+ ...( isRanOnTheServer
56+ ? [
57+ [
58+ 'doc-docusaurus-typedoc-plugin' ,
59+ {
60+ version,
61+ outDir : './api' ,
62+ sidebarFile : './apisidebar.json' ,
63+ typedoc : {
64+ entryPoints : [ '../../packages/render/src/index.ts' ] ,
65+ tsconfig : '../../packages/render/tsconfig.json' ,
66+ excludePrivate : true
67+ }
68+ }
69+ ]
70+ ]
71+ : [ ] )
72+ ] ;
5173
5274const config : Config = {
5375 title : 'React Native Render HTML' ,
0 commit comments