@chidchanun/bcp 0.3.1 → 0.3.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/docs/api-freeze-snapshot.json +13 -2
- package/docs/api-manifest.json +22 -14
- package/docs/docs-web-manifest.json +6 -4
- package/docs/module-system-v2.md +386 -0
- package/docs/platform-manifest.json +19 -4
- package/docs/releases/0.3.2.md +125 -0
- package/package.json +7 -1
- package/packages/bundler/src/client-boundary.ts +1 -0
- package/packages/client/src/application.mjs +434 -30
- package/packages/client/src/modules.mjs +392 -0
- package/packages/client/src/modules.ts +17 -0
- package/packages/server/src/application.ts +58 -9
- package/packages/server/src/modules.ts +682 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# BCP Framework 0.3.2 — Module System v2
|
|
2
|
+
|
|
3
|
+
**State:** unreleased
|
|
4
|
+
|
|
5
|
+
BCP Framework `0.3.2` adds a first-class server-side application module system on top of the Application Platform and Dependency Injection container introduced in `0.3.0` and `0.3.1`.
|
|
6
|
+
|
|
7
|
+
## Highlights
|
|
8
|
+
|
|
9
|
+
- new server-only `bcp/modules` public entrypoint;
|
|
10
|
+
- dependency-first module import graph;
|
|
11
|
+
- duplicate-name and circular-dependency detection;
|
|
12
|
+
- typed DI providers owned by modules;
|
|
13
|
+
- explicit token exports and imported-token re-exports;
|
|
14
|
+
- existing BCP plugin contribution from modules;
|
|
15
|
+
- legacy shared-service contribution for plugin interoperability;
|
|
16
|
+
- module-owned Deployment Platform resources;
|
|
17
|
+
- module `setup/start/stop/dispose` lifecycle;
|
|
18
|
+
- startup cleanup when a module setup/start hook fails;
|
|
19
|
+
- module config parser/schema support;
|
|
20
|
+
- module graph/record diagnostics;
|
|
21
|
+
- `createApp()` integration with both Module System v2 and legacy `bcp/plugins` modules;
|
|
22
|
+
- compiled `modules.mjs` production runtime;
|
|
23
|
+
- browser poison boundary for `bcp/modules`;
|
|
24
|
+
- unit and prepared-package smoke coverage.
|
|
25
|
+
|
|
26
|
+
## Public API
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
MODULE_V2_KIND,
|
|
31
|
+
ModuleDependencyError,
|
|
32
|
+
ModuleLifecycleError,
|
|
33
|
+
composeModules,
|
|
34
|
+
defineModule,
|
|
35
|
+
isModuleDefinition,
|
|
36
|
+
resolveModuleOrder,
|
|
37
|
+
} from "bcp/modules";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Important public types:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
ModuleDefinition
|
|
44
|
+
ModuleInput
|
|
45
|
+
ModuleContext
|
|
46
|
+
ModuleComposition
|
|
47
|
+
ModuleRecord
|
|
48
|
+
ModuleConfigSchema
|
|
49
|
+
ModuleConfigParser
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Application integration
|
|
53
|
+
|
|
54
|
+
`ApplicationDefinition.modules` now accepts both:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
legacy PluginModule from bcp/plugins
|
|
58
|
+
ModuleDefinition from bcp/modules
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The application exposes:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
app.modules
|
|
65
|
+
app.context.modules
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Module providers are registered into `app.container`; module plugins are composed into `app.plugins`; module shared services are composed into `app.services`; and module resources/lifecycle are registered into `app.deployment`.
|
|
69
|
+
|
|
70
|
+
## Lifecycle ordering
|
|
71
|
+
|
|
72
|
+
For v2 modules, imports are resolved before importers. Within each module, resources start before the module lifecycle hook:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
imported modules
|
|
76
|
+
↓
|
|
77
|
+
module resources
|
|
78
|
+
↓
|
|
79
|
+
module setup/start
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Shutdown reverses this order:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
module stop/dispose
|
|
86
|
+
↓
|
|
87
|
+
module resources
|
|
88
|
+
↓
|
|
89
|
+
imported modules
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If a module's own setup/start fails, its dispose hook is run before the error propagates and Deployment Platform rolls back previously started resources.
|
|
93
|
+
|
|
94
|
+
## Compatibility
|
|
95
|
+
|
|
96
|
+
Previous baseline: `0.3.1`.
|
|
97
|
+
|
|
98
|
+
Intentional breaking changes from `0.3.1`: **none**.
|
|
99
|
+
|
|
100
|
+
The existing `defineModule()` from `bcp/plugins` remains supported and unchanged. New application modules should import `defineModule()` from `bcp/modules`.
|
|
101
|
+
|
|
102
|
+
## Packaging
|
|
103
|
+
|
|
104
|
+
Prepared npm packages add:
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
bcp/modules -> packages/client/src/modules.mjs
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
with TypeScript types from `packages/client/src/modules.ts` and the standard server-only browser boundary.
|
|
111
|
+
|
|
112
|
+
## Validation
|
|
113
|
+
|
|
114
|
+
Before tagging or publishing `0.3.2`:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
npm run typecheck
|
|
118
|
+
npm run test:unit
|
|
119
|
+
npm run test:integration
|
|
120
|
+
npm run test:e2e
|
|
121
|
+
npm run test:package
|
|
122
|
+
npm run api:check
|
|
123
|
+
npm run release:readiness
|
|
124
|
+
npm run rc:check
|
|
125
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chidchanun/bcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "BCP Framework - a React full-stack application platform with routing, SSR, APIs, lifecycle composition and standalone production builds.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"framework",
|
|
19
19
|
"application-platform",
|
|
20
20
|
"dependency-injection",
|
|
21
|
+
"module-system",
|
|
21
22
|
"ssr",
|
|
22
23
|
"routing",
|
|
23
24
|
"fullstack"
|
|
@@ -109,6 +110,11 @@
|
|
|
109
110
|
"browser": "./packages/client/src/server-only.browser.mjs",
|
|
110
111
|
"default": "./packages/client/src/container.mjs"
|
|
111
112
|
},
|
|
113
|
+
"./modules": {
|
|
114
|
+
"types": "./packages/client/src/modules.ts",
|
|
115
|
+
"browser": "./packages/client/src/server-only.browser.mjs",
|
|
116
|
+
"default": "./packages/client/src/modules.mjs"
|
|
117
|
+
},
|
|
112
118
|
"./application": {
|
|
113
119
|
"types": "./packages/client/src/application.ts",
|
|
114
120
|
"browser": "./packages/client/src/server-only.browser.mjs",
|