@digi-frontend/dgate-api-documentation 2.0.1-test.9 → 2.0.2
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/README.md +333 -333
- package/dist/index.cjs +1552 -282
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +45 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +259 -105
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +259 -105
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1555 -285
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,333 +1,333 @@
|
|
|
1
|
-
# DGate API Documentation View
|
|
2
|
-
|
|
3
|
-
A modern, type-safe React component library for rendering and managing API documentation interfaces.
|
|
4
|
-
Built with Zustand for state management and designed for scalability and developer experience.
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- **🎯 Type-Safe State Management**: Built with Zustand and TypeScript for reliable state handling
|
|
9
|
-
- **🏗️ Modular Architecture**: Separation of concerns between view and editor states
|
|
10
|
-
- **⚡ Performance Optimized**: Selective subscriptions to minimize unnecessary re-renders
|
|
11
|
-
- **🛠️ Developer Experience**: Comprehensive TypeScript support with excellent IDE integration
|
|
12
|
-
- **🎨 Theme Support**: Built-in light/dark theme switching capabilities
|
|
13
|
-
- **📝 Content Editing**: Integrated editor state management for content modification workflows
|
|
14
|
-
|
|
15
|
-
## Quick Start
|
|
16
|
-
|
|
17
|
-
### Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pnpm install
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Development
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm run build
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Usage Example
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
import { useStore } from './store'
|
|
33
|
-
|
|
34
|
-
function MyComponent() {
|
|
35
|
-
// State access
|
|
36
|
-
const theme = useStore((state) => state.view.theme)
|
|
37
|
-
const isEditing = useStore((state) => state.editor.isEditing)
|
|
38
|
-
|
|
39
|
-
// Actions
|
|
40
|
-
const setTheme = useStore((state) => state.setTheme)
|
|
41
|
-
const startEdit = useStore((state) => state.startEdit)
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div className={`theme-${theme}`}>
|
|
45
|
-
<button onClick={() => setTheme('dark')}>Switch Theme</button>
|
|
46
|
-
<button onClick={() => startEdit('content')}>Edit Content</button>
|
|
47
|
-
</div>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Architecture
|
|
53
|
-
|
|
54
|
-
### Store Organization
|
|
55
|
-
|
|
56
|
-
The application state is organized into two primary domains:
|
|
57
|
-
|
|
58
|
-
- **View State**: UI preferences, display data, and user interface state
|
|
59
|
-
- **Editor State**: Content editing, form management, and modification tracking
|
|
60
|
-
|
|
61
|
-
### Key Components
|
|
62
|
-
|
|
63
|
-
- **`src/store/`**: Centralized state management with Zustand
|
|
64
|
-
- **`src/store/README.md`**: Complete usage guide with examples
|
|
65
|
-
- **`src/types/`**: TypeScript definitions and interfaces
|
|
66
|
-
|
|
67
|
-
## State Management Patterns
|
|
68
|
-
|
|
69
|
-
### Direct State Access
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
const count = useStore((state) => state.view.count)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Action Dispatching
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
const increment = useStore((state) => state.increment)
|
|
79
|
-
increment()
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Computed Values
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
const totalItems = useStore((state) => state.getItemCount())
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Development Guidelines
|
|
89
|
-
|
|
90
|
-
### Adding New Features
|
|
91
|
-
|
|
92
|
-
1. Define interfaces in the store types
|
|
93
|
-
2. Add initial state values
|
|
94
|
-
3. Implement actions with proper typing
|
|
95
|
-
4. Create computed getters as needed
|
|
96
|
-
5. See `src/store/README.md` for detailed examples
|
|
97
|
-
|
|
98
|
-
### Best Practices
|
|
99
|
-
|
|
100
|
-
- Use TypeScript strictly for all implementations
|
|
101
|
-
- Leverage Immer for immutable state updates
|
|
102
|
-
- Organize actions by domain (view vs editor)
|
|
103
|
-
- Implement computed values for derived state
|
|
104
|
-
- Use selective subscriptions for performance
|
|
105
|
-
|
|
106
|
-
## Technical Stack
|
|
107
|
-
|
|
108
|
-
- **Zustand**: Lightweight state management
|
|
109
|
-
- **TypeScript**: Type safety and developer experience
|
|
110
|
-
- **Immer**: Immutable state updates
|
|
111
|
-
- **React**: UI component framework
|
|
112
|
-
- **DevTools**: Debugging and state inspection
|
|
113
|
-
|
|
114
|
-
## Local Development Setup
|
|
115
|
-
|
|
116
|
-
### Linking this package locally with pnpm
|
|
117
|
-
|
|
118
|
-
This guide explains how to link **`@digi-frontend/dgate-api-documentation`** with a separate React
|
|
119
|
-
app for live development.
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
#### Folder layout
|
|
124
|
-
|
|
125
|
-
Place the app and this library **side-by-side** (for example, on Desktop):
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
Desktop/
|
|
129
|
-
dgate-api-documentation/ ← this repo (the library)
|
|
130
|
-
your-react-app/ ← the consuming app
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
#### 1) In the app: install peer dependencies
|
|
136
|
-
|
|
137
|
-
The app must provide the library's required peers:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
cd .\your-next-app
|
|
141
|
-
pnpm add react react-dom antd @ant-design/cssinjs
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
> In the **library**, keep `react`, `react-dom`, `antd`, and `@ant-design/cssinjs` in
|
|
145
|
-
> **peerDependencies** (and optionally in `devDependencies` for local lib testing).
|
|
146
|
-
> Do **not** put them in `dependencies` in the lib.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
#### 2) In the app: link the library by relative path
|
|
151
|
-
|
|
152
|
-
Remove any previous install and add the link:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
pnpm remove @digi-frontend/dgate-api-documentation
|
|
156
|
-
pnpm add @digi-frontend/dgate-api-documentation@link:../dgate-api-documentation
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
If the path has spaces, quote it:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
pnpm add @digi-frontend/dgate-api-documentation@link:"../dgate-api-documentation"
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
#### 3) In the app: Next.js config (webpack-only)
|
|
168
|
-
|
|
169
|
-
Use webpack in dev and let Next transpile the linked package.
|
|
170
|
-
|
|
171
|
-
**`next.config.ts` (in the app):**
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
import type { NextConfig } from 'next'
|
|
175
|
-
|
|
176
|
-
const config: NextConfig = {
|
|
177
|
-
// Transpile the linked library if it ships TS/ESM source
|
|
178
|
-
transpilePackages: ['@digi-frontend/dgate-api-documentation'],
|
|
179
|
-
|
|
180
|
-
webpack(config) {
|
|
181
|
-
// Follow pnpm symlinks so HMR works across repos
|
|
182
|
-
config.resolve.symlinks = true
|
|
183
|
-
return config
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
eslint: { ignoreDuringBuilds: true },
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export default config
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**Start dev (webpack):**
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
pnpm dev
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
> Don't pass `--turbo`/`--turbopack`. Turbopack does not follow out-of-tree links.
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
#### 4) In the library: start development mode
|
|
203
|
-
|
|
204
|
-
To enable live updates, run the development server in the **library** package:
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
cd ../dgate-api-documentation
|
|
208
|
-
pnpm dev
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
This will start the library in watch mode, allowing changes to be reflected immediately in the
|
|
212
|
-
consuming app.
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
#### 5) Verify the link
|
|
217
|
-
|
|
218
|
-
From the **app** folder:
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
# Show that the dependency is linked
|
|
222
|
-
pnpm list @digi-frontend/dgate-api-documentation
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
# Show the symlink target path on disk
|
|
227
|
-
(Get-Item ./node_modules/@digi-frontend/dgate-api-documentation).Target
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Optionally resolve the entry file:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
# CJS resolution (works if the package exposes a CJS entry)
|
|
234
|
-
node -p "require.resolve('@digi-frontend/dgate-api-documentation')"
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
If your package is ESM-only:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
node --input-type=module -p "import.meta.resolve('@digi-frontend/dgate-api-documentation')"
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
> If `require.resolve('@pkg/package.json')` fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`,
|
|
244
|
-
> that's normal unless you explicitly export `./package.json` in the lib's `exports`.
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
#### 6) Troubleshooting
|
|
249
|
-
|
|
250
|
-
**Fast Refresh performs full reload**
|
|
251
|
-
A module from the lib is likely imported both inside and _outside_ the React render tree.
|
|
252
|
-
Split React components/hooks and non-React utilities into separate modules/entries (e.g.,
|
|
253
|
-
`@pkg/react` vs `@pkg/core`).
|
|
254
|
-
|
|
255
|
-
**"Invalid hook call" (duplicate React)**
|
|
256
|
-
|
|
257
|
-
- Ensure the lib keeps `react` and `react-dom` in **peerDependencies** (not `dependencies`).
|
|
258
|
-
- The app must install compatible versions.
|
|
259
|
-
- If needed, hard-dedupe to the app's React in `next.config.ts`:
|
|
260
|
-
|
|
261
|
-
```ts
|
|
262
|
-
webpack(config) {
|
|
263
|
-
config.resolve.alias = {
|
|
264
|
-
...(config.resolve.alias ?? {}),
|
|
265
|
-
react: require('path').resolve(__dirname, 'node_modules/react'),
|
|
266
|
-
'react-dom': require('path').resolve(__dirname, 'node_modules/react-dom'),
|
|
267
|
-
}
|
|
268
|
-
return config
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
**File watching on Windows is flaky**
|
|
273
|
-
Enable polling temporarily:
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
$env:WATCHPACK_POLLING="true"; pnpm dev
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
**Avoid `pnpm link --global`**
|
|
280
|
-
Global links resolve peers relative to the lib folder and can cause missing/duplicate React/AntD in
|
|
281
|
-
the app.
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
#### 7) Unlink / switch back to registry
|
|
286
|
-
|
|
287
|
-
From the **app** folder:
|
|
288
|
-
|
|
289
|
-
```bash
|
|
290
|
-
pnpm remove @digi-frontend/dgate-api-documentation
|
|
291
|
-
pnpm add @digi-frontend/dgate-api-documentation # install from registry again
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
#### 8) Alternatives (if you don't want a live symlink)
|
|
297
|
-
|
|
298
|
-
**Local tarball**
|
|
299
|
-
|
|
300
|
-
```bash
|
|
301
|
-
# in the lib
|
|
302
|
-
pnpm pack # creates a .tgz
|
|
303
|
-
# in the app
|
|
304
|
-
pnpm add ../dgate-api-documentation/@digi-frontend/dgate-api-documentation-x.y.z.tgz
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**`file:` protocol (no live updates)**
|
|
308
|
-
|
|
309
|
-
```json
|
|
310
|
-
{
|
|
311
|
-
"dependencies": {
|
|
312
|
-
"@digi-frontend/dgate-api-documentation": "file:../dgate-api-documentation"
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
pnpm install
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
### Summary
|
|
324
|
-
|
|
325
|
-
- Link with:
|
|
326
|
-
|
|
327
|
-
```bash
|
|
328
|
-
pnpm add @digi-frontend/dgate-api-documentation@link:../dgate-api-documentation
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
- Run **webpack dev** (`pnpm dev`, no Turbopack).
|
|
332
|
-
- Keep peers in the **app**, not as `dependencies` in the lib.
|
|
333
|
-
- Verify with `pnpm list` and `Get-Item … .Target`.
|
|
1
|
+
# DGate API Documentation View
|
|
2
|
+
|
|
3
|
+
A modern, type-safe React component library for rendering and managing API documentation interfaces.
|
|
4
|
+
Built with Zustand for state management and designed for scalability and developer experience.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **🎯 Type-Safe State Management**: Built with Zustand and TypeScript for reliable state handling
|
|
9
|
+
- **🏗️ Modular Architecture**: Separation of concerns between view and editor states
|
|
10
|
+
- **⚡ Performance Optimized**: Selective subscriptions to minimize unnecessary re-renders
|
|
11
|
+
- **🛠️ Developer Experience**: Comprehensive TypeScript support with excellent IDE integration
|
|
12
|
+
- **🎨 Theme Support**: Built-in light/dark theme switching capabilities
|
|
13
|
+
- **📝 Content Editing**: Integrated editor state management for content modification workflows
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Development
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm run build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Usage Example
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { useStore } from './store'
|
|
33
|
+
|
|
34
|
+
function MyComponent() {
|
|
35
|
+
// State access
|
|
36
|
+
const theme = useStore((state) => state.view.theme)
|
|
37
|
+
const isEditing = useStore((state) => state.editor.isEditing)
|
|
38
|
+
|
|
39
|
+
// Actions
|
|
40
|
+
const setTheme = useStore((state) => state.setTheme)
|
|
41
|
+
const startEdit = useStore((state) => state.startEdit)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className={`theme-${theme}`}>
|
|
45
|
+
<button onClick={() => setTheme('dark')}>Switch Theme</button>
|
|
46
|
+
<button onClick={() => startEdit('content')}>Edit Content</button>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Architecture
|
|
53
|
+
|
|
54
|
+
### Store Organization
|
|
55
|
+
|
|
56
|
+
The application state is organized into two primary domains:
|
|
57
|
+
|
|
58
|
+
- **View State**: UI preferences, display data, and user interface state
|
|
59
|
+
- **Editor State**: Content editing, form management, and modification tracking
|
|
60
|
+
|
|
61
|
+
### Key Components
|
|
62
|
+
|
|
63
|
+
- **`src/store/`**: Centralized state management with Zustand
|
|
64
|
+
- **`src/store/README.md`**: Complete usage guide with examples
|
|
65
|
+
- **`src/types/`**: TypeScript definitions and interfaces
|
|
66
|
+
|
|
67
|
+
## State Management Patterns
|
|
68
|
+
|
|
69
|
+
### Direct State Access
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const count = useStore((state) => state.view.count)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Action Dispatching
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const increment = useStore((state) => state.increment)
|
|
79
|
+
increment()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Computed Values
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const totalItems = useStore((state) => state.getItemCount())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Development Guidelines
|
|
89
|
+
|
|
90
|
+
### Adding New Features
|
|
91
|
+
|
|
92
|
+
1. Define interfaces in the store types
|
|
93
|
+
2. Add initial state values
|
|
94
|
+
3. Implement actions with proper typing
|
|
95
|
+
4. Create computed getters as needed
|
|
96
|
+
5. See `src/store/README.md` for detailed examples
|
|
97
|
+
|
|
98
|
+
### Best Practices
|
|
99
|
+
|
|
100
|
+
- Use TypeScript strictly for all implementations
|
|
101
|
+
- Leverage Immer for immutable state updates
|
|
102
|
+
- Organize actions by domain (view vs editor)
|
|
103
|
+
- Implement computed values for derived state
|
|
104
|
+
- Use selective subscriptions for performance
|
|
105
|
+
|
|
106
|
+
## Technical Stack
|
|
107
|
+
|
|
108
|
+
- **Zustand**: Lightweight state management
|
|
109
|
+
- **TypeScript**: Type safety and developer experience
|
|
110
|
+
- **Immer**: Immutable state updates
|
|
111
|
+
- **React**: UI component framework
|
|
112
|
+
- **DevTools**: Debugging and state inspection
|
|
113
|
+
|
|
114
|
+
## Local Development Setup
|
|
115
|
+
|
|
116
|
+
### Linking this package locally with pnpm
|
|
117
|
+
|
|
118
|
+
This guide explains how to link **`@digi-frontend/dgate-api-documentation`** with a separate React
|
|
119
|
+
app for live development.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
#### Folder layout
|
|
124
|
+
|
|
125
|
+
Place the app and this library **side-by-side** (for example, on Desktop):
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
Desktop/
|
|
129
|
+
dgate-api-documentation/ ← this repo (the library)
|
|
130
|
+
your-react-app/ ← the consuming app
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
#### 1) In the app: install peer dependencies
|
|
136
|
+
|
|
137
|
+
The app must provide the library's required peers:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cd .\your-next-app
|
|
141
|
+
pnpm add react react-dom antd @ant-design/cssinjs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> In the **library**, keep `react`, `react-dom`, `antd`, and `@ant-design/cssinjs` in
|
|
145
|
+
> **peerDependencies** (and optionally in `devDependencies` for local lib testing).
|
|
146
|
+
> Do **not** put them in `dependencies` in the lib.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
#### 2) In the app: link the library by relative path
|
|
151
|
+
|
|
152
|
+
Remove any previous install and add the link:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pnpm remove @digi-frontend/dgate-api-documentation
|
|
156
|
+
pnpm add @digi-frontend/dgate-api-documentation@link:../dgate-api-documentation
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
If the path has spaces, quote it:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pnpm add @digi-frontend/dgate-api-documentation@link:"../dgate-api-documentation"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
#### 3) In the app: Next.js config (webpack-only)
|
|
168
|
+
|
|
169
|
+
Use webpack in dev and let Next transpile the linked package.
|
|
170
|
+
|
|
171
|
+
**`next.config.ts` (in the app):**
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import type { NextConfig } from 'next'
|
|
175
|
+
|
|
176
|
+
const config: NextConfig = {
|
|
177
|
+
// Transpile the linked library if it ships TS/ESM source
|
|
178
|
+
transpilePackages: ['@digi-frontend/dgate-api-documentation'],
|
|
179
|
+
|
|
180
|
+
webpack(config) {
|
|
181
|
+
// Follow pnpm symlinks so HMR works across repos
|
|
182
|
+
config.resolve.symlinks = true
|
|
183
|
+
return config
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
eslint: { ignoreDuringBuilds: true },
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default config
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Start dev (webpack):**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
pnpm dev
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
> Don't pass `--turbo`/`--turbopack`. Turbopack does not follow out-of-tree links.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
#### 4) In the library: start development mode
|
|
203
|
+
|
|
204
|
+
To enable live updates, run the development server in the **library** package:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
cd ../dgate-api-documentation
|
|
208
|
+
pnpm dev
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
This will start the library in watch mode, allowing changes to be reflected immediately in the
|
|
212
|
+
consuming app.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
#### 5) Verify the link
|
|
217
|
+
|
|
218
|
+
From the **app** folder:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Show that the dependency is linked
|
|
222
|
+
pnpm list @digi-frontend/dgate-api-documentation
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Show the symlink target path on disk
|
|
227
|
+
(Get-Item ./node_modules/@digi-frontend/dgate-api-documentation).Target
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Optionally resolve the entry file:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# CJS resolution (works if the package exposes a CJS entry)
|
|
234
|
+
node -p "require.resolve('@digi-frontend/dgate-api-documentation')"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
If your package is ESM-only:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
node --input-type=module -p "import.meta.resolve('@digi-frontend/dgate-api-documentation')"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
> If `require.resolve('@pkg/package.json')` fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`,
|
|
244
|
+
> that's normal unless you explicitly export `./package.json` in the lib's `exports`.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
#### 6) Troubleshooting
|
|
249
|
+
|
|
250
|
+
**Fast Refresh performs full reload**
|
|
251
|
+
A module from the lib is likely imported both inside and _outside_ the React render tree.
|
|
252
|
+
Split React components/hooks and non-React utilities into separate modules/entries (e.g.,
|
|
253
|
+
`@pkg/react` vs `@pkg/core`).
|
|
254
|
+
|
|
255
|
+
**"Invalid hook call" (duplicate React)**
|
|
256
|
+
|
|
257
|
+
- Ensure the lib keeps `react` and `react-dom` in **peerDependencies** (not `dependencies`).
|
|
258
|
+
- The app must install compatible versions.
|
|
259
|
+
- If needed, hard-dedupe to the app's React in `next.config.ts`:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
webpack(config) {
|
|
263
|
+
config.resolve.alias = {
|
|
264
|
+
...(config.resolve.alias ?? {}),
|
|
265
|
+
react: require('path').resolve(__dirname, 'node_modules/react'),
|
|
266
|
+
'react-dom': require('path').resolve(__dirname, 'node_modules/react-dom'),
|
|
267
|
+
}
|
|
268
|
+
return config
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**File watching on Windows is flaky**
|
|
273
|
+
Enable polling temporarily:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
$env:WATCHPACK_POLLING="true"; pnpm dev
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Avoid `pnpm link --global`**
|
|
280
|
+
Global links resolve peers relative to the lib folder and can cause missing/duplicate React/AntD in
|
|
281
|
+
the app.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
#### 7) Unlink / switch back to registry
|
|
286
|
+
|
|
287
|
+
From the **app** folder:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
pnpm remove @digi-frontend/dgate-api-documentation
|
|
291
|
+
pnpm add @digi-frontend/dgate-api-documentation # install from registry again
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
#### 8) Alternatives (if you don't want a live symlink)
|
|
297
|
+
|
|
298
|
+
**Local tarball**
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# in the lib
|
|
302
|
+
pnpm pack # creates a .tgz
|
|
303
|
+
# in the app
|
|
304
|
+
pnpm add ../dgate-api-documentation/@digi-frontend/dgate-api-documentation-x.y.z.tgz
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**`file:` protocol (no live updates)**
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"dependencies": {
|
|
312
|
+
"@digi-frontend/dgate-api-documentation": "file:../dgate-api-documentation"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
pnpm install
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### Summary
|
|
324
|
+
|
|
325
|
+
- Link with:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
pnpm add @digi-frontend/dgate-api-documentation@link:../dgate-api-documentation
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
- Run **webpack dev** (`pnpm dev`, no Turbopack).
|
|
332
|
+
- Keep peers in the **app**, not as `dependencies` in the lib.
|
|
333
|
+
- Verify with `pnpm list` and `Get-Item … .Target`.
|