@oktis-works/theme-builder 0.2.1 → 0.2.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 +85 -0
- package/package.json +14 -8
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @oktis-works/theme-builder
|
|
2
|
+
|
|
3
|
+
Builds compiled React/Solid themes into self-contained Vite SSR artifacts.
|
|
4
|
+
|
|
5
|
+
## Build Output
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
themes/meu-tema/
|
|
9
|
+
├── dist/
|
|
10
|
+
│ ├── theme.css # CSS isolado [data-theme="meu-tema"]
|
|
11
|
+
│ ├── theme-components.css # CSS dos componentes (scoped)
|
|
12
|
+
│ ├── server/
|
|
13
|
+
│ │ └── entry.js # SSR bundle (ESM, target node22)
|
|
14
|
+
│ ├── client/
|
|
15
|
+
│ │ └── entry.js # Client bundle (se hydration: islands)
|
|
16
|
+
│ └── theme-build.json # Manifest do artifact (buildId, templates, client, styles)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Source Maps
|
|
20
|
+
|
|
21
|
+
**Produção (`sourcemap: false` no server bundle):**
|
|
22
|
+
|
|
23
|
+
| Aspecto | Decisão |
|
|
24
|
+
|---------|---------|
|
|
25
|
+
| Tamanho bundle | ~30-50% menor sem `.js.map` |
|
|
26
|
+
| Segurança | Código fonte não exposto em erro/stack |
|
|
27
|
+
| Debug prod | Stack trace minificado |
|
|
28
|
+
| Error tracking | Requer upload manual se usar APM |
|
|
29
|
+
|
|
30
|
+
**Quando habilitar (`sourcemap: true`):** Se integrar **Sentry/Datadog/outro APM** que aceite upload automático de source maps. Sem APM configurado, `false` é melhor (menor superfície, bundle menor).
|
|
31
|
+
|
|
32
|
+
**Dev:** Não usa Vite HMR — usa polling rebuild + full SSR rebuild (paridade exata com prod, captura erros de build que HMR não pega, funciona em containers sem WebSocket issues).
|
|
33
|
+
|
|
34
|
+
## CLI
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Build único (prod/CI)
|
|
38
|
+
okcms theme:build --name meu-tema
|
|
39
|
+
|
|
40
|
+
# Watch mode (dev)
|
|
41
|
+
okcms theme:dev --name meu-tema
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { buildTheme, watchTheme, verifyThemeBuild } from '@oktis-works/theme-builder';
|
|
48
|
+
|
|
49
|
+
// Build único
|
|
50
|
+
const result = await buildTheme({ themesRoot, themeName: 'meu-tema', mode: 'all' });
|
|
51
|
+
|
|
52
|
+
// Watch (dev)
|
|
53
|
+
const stop = await watchTheme(
|
|
54
|
+
{ themesRoot, themeName: 'meu-tema' },
|
|
55
|
+
(event) => { if (event.type === 'build') console.log('rebuilt', event.result.buildId); }
|
|
56
|
+
);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Theme Manifest (theme.json)
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"name": "meu-tema",
|
|
64
|
+
"version": "1.0.0",
|
|
65
|
+
"type": "theme",
|
|
66
|
+
"render": {
|
|
67
|
+
"engine": "react",
|
|
68
|
+
"apiVersion": 1,
|
|
69
|
+
"hydration": "none",
|
|
70
|
+
"entry": "src/entry-server.tsx"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Hydration Modes
|
|
76
|
+
|
|
77
|
+
| Mode | Client Bundle | Uso |
|
|
78
|
+
|------|---------------|-----|
|
|
79
|
+
| `none` | Não | SSR puro, HTML estático |
|
|
80
|
+
| `islands` | Sim (`dist/client/entry.js`) | Hidratação seletiva de componentes interativos |
|
|
81
|
+
|
|
82
|
+
### Entry Points
|
|
83
|
+
|
|
84
|
+
- **Server (obrigatório):** `src/entry-server.tsx` — exporta `templateKeys: string[]` e `render(key, data): { html: string }`
|
|
85
|
+
- **Client (opcional):** `src/entry-client.tsx` — necessário para `hydration: "islands"`, exporta `hydrateRoot()` / `hydrate()`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oktis-works/theme-builder",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@oktis-works/theme-runtime": "
|
|
20
|
-
"@oktis-works/theme-sdk": "
|
|
21
|
-
"@oktis-works/types": "
|
|
22
|
-
"@oktis-works/validation": "
|
|
19
|
+
"@oktis-works/theme-runtime": "^0.14.1",
|
|
20
|
+
"@oktis-works/theme-sdk": "^0.10.1",
|
|
21
|
+
"@oktis-works/types": "^0.11.1",
|
|
22
|
+
"@oktis-works/validation": "^0.9.1",
|
|
23
23
|
"@vitejs/plugin-react": "^6.3.0",
|
|
24
24
|
"babel-preset-solid": "^1.9.16",
|
|
25
25
|
"vite": "^8.3.3",
|
|
@@ -31,9 +31,15 @@
|
|
|
31
31
|
"solid-js": "^1.8.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
|
-
"react": {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
"react": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"react-dom": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"solid-js": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
37
43
|
},
|
|
38
44
|
"devDependencies": {
|
|
39
45
|
"typescript": "5.7.3"
|