@insforge/shared 1.1.1-dev.3 → 1.1.1
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 +62 -62
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# @insforge/shared
|
|
2
|
-
|
|
3
|
-
Shared utilities, types, and React contexts for Insforge packages.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
This package centralizes React Context definitions to prevent duplication issues when using `tsup` with multiple entry points. By defining contexts here, all Insforge packages (`@insforge/react`, `@insforge/nextjs`, etc.) import from the same source, ensuring a single Context instance.
|
|
8
|
-
|
|
9
|
-
## Architecture Pattern
|
|
10
|
-
|
|
11
|
-
Inspired by `@clerk/shared`, this package solves the Context duplication problem:
|
|
12
|
-
|
|
13
|
-
### The Problem
|
|
14
|
-
|
|
15
|
-
When using `bundle: true` with multiple entry points:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
// tsup.config.ts
|
|
19
|
-
entry: {
|
|
20
|
-
index: 'src/index.ts',
|
|
21
|
-
hooks: 'src/hooks/index.ts',
|
|
22
|
-
components: 'src/components/index.ts'
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Each entry point bundles its own copy of Context → Provider uses Context instance A, but components use Context instance B → `useContext` returns `undefined`.
|
|
27
|
-
|
|
28
|
-
### The Solution
|
|
29
|
-
|
|
30
|
-
1. **Centralized Context**: Define all Contexts in `@insforge/shared`
|
|
31
|
-
2. **External React**: Mark `react` as external in tsup config
|
|
32
|
-
3. **Shared Import**: All packages import Context from `@insforge/shared`
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
// packages/shared/tsup.config.ts
|
|
36
|
-
export default defineConfig({
|
|
37
|
-
external: ['react', 'react-dom'], // Critical!
|
|
38
|
-
bundle: true,
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Exports
|
|
43
|
-
|
|
44
|
-
### Main Entry (`@insforge/shared`)
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import type { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### React Entry (`@insforge/shared/react`)
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
import { InsforgeContext } from '@insforge/shared/react';
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Usage
|
|
57
|
-
|
|
58
|
-
This package is intended for internal use within the Insforge monorepo. Application developers should not need to import from it directly.
|
|
59
|
-
|
|
60
|
-
## License
|
|
61
|
-
|
|
62
|
-
MIT
|
|
1
|
+
# @insforge/shared
|
|
2
|
+
|
|
3
|
+
Shared utilities, types, and React contexts for Insforge packages.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package centralizes React Context definitions to prevent duplication issues when using `tsup` with multiple entry points. By defining contexts here, all Insforge packages (`@insforge/react`, `@insforge/nextjs`, etc.) import from the same source, ensuring a single Context instance.
|
|
8
|
+
|
|
9
|
+
## Architecture Pattern
|
|
10
|
+
|
|
11
|
+
Inspired by `@clerk/shared`, this package solves the Context duplication problem:
|
|
12
|
+
|
|
13
|
+
### The Problem
|
|
14
|
+
|
|
15
|
+
When using `bundle: true` with multiple entry points:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// tsup.config.ts
|
|
19
|
+
entry: {
|
|
20
|
+
index: 'src/index.ts',
|
|
21
|
+
hooks: 'src/hooks/index.ts',
|
|
22
|
+
components: 'src/components/index.ts'
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Each entry point bundles its own copy of Context → Provider uses Context instance A, but components use Context instance B → `useContext` returns `undefined`.
|
|
27
|
+
|
|
28
|
+
### The Solution
|
|
29
|
+
|
|
30
|
+
1. **Centralized Context**: Define all Contexts in `@insforge/shared`
|
|
31
|
+
2. **External React**: Mark `react` as external in tsup config
|
|
32
|
+
3. **Shared Import**: All packages import Context from `@insforge/shared`
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// packages/shared/tsup.config.ts
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
external: ['react', 'react-dom'], // Critical!
|
|
38
|
+
bundle: true,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Exports
|
|
43
|
+
|
|
44
|
+
### Main Entry (`@insforge/shared`)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import type { InsforgeUser, InsforgeContextValue, OAuthProvider } from '@insforge/shared';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### React Entry (`@insforge/shared/react`)
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { InsforgeContext } from '@insforge/shared/react';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
This package is intended for internal use within the Insforge monorepo. Application developers should not need to import from it directly.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insforge/shared",
|
|
3
|
-
"version": "1.1.1
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Shared utilities and React contexts for Insforge packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"react": ">=18.0.0 <20.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@insforge/shared-schemas": "^1.1.
|
|
43
|
+
"@insforge/shared-schemas": "^1.1.39"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/react": "^19.2.2",
|