@dokebi/module 0.1.1 → 0.1.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/AI.md CHANGED
@@ -1,4 +1,4 @@
1
- # AI 작업 안내 — @dokebi/module 0.1.1
1
+ # AI 작업 안내 — @dokebi/module 0.1.2
2
2
 
3
3
  모듈은 **기능 하나의 업무 단위**다(D-0032). 컨트롤러·모델·뷰·라우트·소켓을 한 폴더에 담고, 앱이 접두사로 붙인다. 웹이 없는 업무(Job handler, 이벤트 구독, 공통 API)도 모듈로 만든다. Node >=24.0.0, core ^0.2.0. 세부는 [README](README.md)다.
4
4
 
@@ -74,6 +74,7 @@ export default defineModule({
74
74
  - `createPlugin({ app, entry: { modules } })`: 여러 모듈을 의존성 그래프로 묶는다. API는 `{ names }`. `defineModule`이 만든 것만 받고 중복은 `INVALID_PLUGIN_INPUT`.
75
75
  - 훅: setup(라우트 등록·API 반환) → start → drain(새 유입 차단, 진행 업무 대기) → defer 정리. drain은 의존 역순(이 모듈에 의존하는 모듈이 먼저), 무관한 모듈은 동시에.
76
76
  - 모듈 인스턴스는 Application 하나에만 쓴다. 실행 중 자동 검색·동적 import·hot reload는 없다.
77
+ - debug 로그(D-0047): `Modules registered`(묶음)·`Module set up`(requires·컨트롤러 수·views 접두사·ms)·`Module start finished`·`Module drain finished`. `views/default/`가 없거나 읽을 수 없으면 시작 실패이고 원래 파일 오류는 `cause`에 남는다.
77
78
 
78
79
  ## 6. 주의 사항
79
80
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @dokebi/module 0.1.1
1
+ # @dokebi/module 0.1.2
2
2
 
3
3
  Node >=24.0.0, core ^0.2.0의 선택 패키지다(npm 공개). 모듈은 **기능 하나의 MVC 업무 단위**다([D-0022](../../docs/decisions/D-0022-plugin-boundaries-and-db.md), [D-0032](../../docs/decisions/D-0032-feature-modules.md)). 컨트롤러·모델·뷰·라우트·소켓을 한 폴더에 담고, 앱이 접두사로 붙인다. HTTP 전용 묶음이 아니어서 웹 없는 업무(Job 처리, 이벤트 구독)도 모듈로 만든다.
4
4
 
package/dist/index.js CHANGED
@@ -88,7 +88,14 @@ export function defineModule(definition) {
88
88
  let controllers;
89
89
  let current;
90
90
  const prefix = `module.${name}`;
91
- const hook = (key) => (context) => definition[key]?.(current ?? moduleContext(context, name, declared, () => controllers));
91
+ const hook = (key) => async (context) => {
92
+ const begin = performance.now();
93
+ await definition[key]?.(current ?? moduleContext(context, name, declared, () => controllers));
94
+ context.logger.log('debug', `Module ${key} finished`, {
95
+ module: name,
96
+ ms: Math.round(performance.now() - begin),
97
+ });
98
+ };
92
99
  const plugin = {
93
100
  metadata: Object.freeze({
94
101
  name: 'dokebi-module.' + name,
@@ -101,17 +108,35 @@ export function defineModule(definition) {
101
108
  throw new Error('Create one module instance per Application');
102
109
  started = true;
103
110
  current = moduleContext(context, name, declared, () => controllers);
111
+ const begin = performance.now();
104
112
  if (definition.controllers?.length) {
105
113
  const { createControllers } = await import('@dokebi/controller');
106
114
  controllers = await createControllers(current, definition.controllers);
107
115
  }
108
116
  if (views) {
109
117
  const folder = fileURLToPath(new URL('default/', views));
110
- if (!(await stat(folder).catch(() => undefined))?.isDirectory())
111
- throw new Error(`Module ${name} has no views/default/ folder`);
118
+ // A missing folder and an unreadable one both stop setup; the stat error is the cause.
119
+ let failure;
120
+ const info = await stat(folder).catch((cause) => {
121
+ failure = cause;
122
+ return undefined;
123
+ });
124
+ if (!info?.isDirectory())
125
+ throw new Error(`Module ${name} has no views/default/ folder`, failure === undefined ? undefined : { cause: failure });
112
126
  await context.getDependency(templates ?? ejs).addDirectory(views, prefix);
113
127
  }
114
- return (await definition.setup?.(current));
128
+ const api = (await definition.setup?.(current));
129
+ context.logger.log('debug', 'Module set up', {
130
+ module: name,
131
+ version,
132
+ requires: dependencies.map((dependency) => dependency.name),
133
+ controllers: definition.controllers?.length ?? 0,
134
+ views: views ? prefix : false,
135
+ routes: Boolean(definition.routes),
136
+ sockets: Boolean(definition.sockets),
137
+ ms: Math.round(performance.now() - begin),
138
+ });
139
+ return api;
115
140
  },
116
141
  ...(definition.start ? { start: hook('start') } : {}),
117
142
  ...(definition.drain ? { drain: hook('drain') } : {}),
@@ -183,13 +208,14 @@ class ModuleGroupRuntime {
183
208
  constructor(names) {
184
209
  this.names = names;
185
210
  }
186
- setup() {
211
+ setup(context) {
212
+ context.logger.log('debug', 'Modules registered', { modules: this.names });
187
213
  return Object.freeze({ names: this.names });
188
214
  }
189
215
  }
190
216
  export const createPlugin = definePlugin({
191
217
  name: 'dokebi-module',
192
- version: '0.1.1',
218
+ version: '0.1.2',
193
219
  core: '^0.2.0',
194
220
  options: parseOptions,
195
221
  entry: parseEntry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dokebi/module",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -67,10 +67,10 @@
67
67
  }
68
68
  },
69
69
  "devDependencies": {
70
- "@dokebi/controller": "0.1.1",
71
- "@dokebi/template-ejs": "0.1.1",
72
- "@dokebi/template-inertia": "0.1.1",
73
- "@dokebi/web": "0.1.1"
70
+ "@dokebi/controller": "0.1.2",
71
+ "@dokebi/template-ejs": "0.1.2",
72
+ "@dokebi/template-inertia": "0.1.3",
73
+ "@dokebi/web": "0.1.2"
74
74
  },
75
75
  "publishConfig": {
76
76
  "access": "public",