@hozu/bundle 0.1.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 olevatorr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @hozu/bundle
|
|
2
|
+
|
|
3
|
+
Bundles Hozu widget client modules with esbuild.
|
|
4
|
+
|
|
5
|
+
Part of [Hozu](https://github.com/olevatorr/Hozu#readme), an AI-first web framework. Most apps start from
|
|
6
|
+
`npm create hozu@latest`, which installs the right packages and sets up Claude Code or `AGENTS.md` agents.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @hozu/bundle
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Requires Node 22.18 or newer. Documentation: the [README](https://github.com/olevatorr/Hozu#readme) and the
|
|
13
|
+
agent skill that `create-hozu` writes into each app.
|
|
14
|
+
|
|
15
|
+
MIT © olevatorr
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type BuildResult, type Diagnostic } from '@hozu/core/ir';
|
|
2
|
+
export interface WidgetBundle {
|
|
3
|
+
urls: Record<string, string>;
|
|
4
|
+
files: Record<string, string>;
|
|
5
|
+
diagnostics: Diagnostic[];
|
|
6
|
+
}
|
|
7
|
+
export declare function bundleWidgets(project: BuildResult, { minify }?: {
|
|
8
|
+
minify?: boolean;
|
|
9
|
+
}): Promise<WidgetBundle>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAS,KAAK,UAAU,EAAQ,MAAM,eAAe,CAAA;AAG9E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,WAAW,EAAE,UAAU,EAAE,CAAA;CAC1B;AAID,wBAAsB,aAAa,CACjC,OAAO,EAAE,WAAW,EACpB,EAAE,MAAa,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3C,OAAO,CAAC,YAAY,CAAC,CA8CvB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { codes, join } from '@hozu/core/ir';
|
|
3
|
+
import { build } from 'esbuild';
|
|
4
|
+
const base = '/_hozu/w';
|
|
5
|
+
export async function bundleWidgets(project, { minify = true } = {}) {
|
|
6
|
+
const entries = Object.entries(project.bindings.widgets);
|
|
7
|
+
const out = { urls: {}, files: {}, diagnostics: [] };
|
|
8
|
+
if (!entries.length)
|
|
9
|
+
return out;
|
|
10
|
+
const result = await build({
|
|
11
|
+
entryPoints: Object.fromEntries(entries.map(([ref, file]) => [ref.replace('.', '-'), file])),
|
|
12
|
+
bundle: true,
|
|
13
|
+
splitting: true,
|
|
14
|
+
format: 'esm',
|
|
15
|
+
platform: 'browser',
|
|
16
|
+
target: 'es2022',
|
|
17
|
+
minify,
|
|
18
|
+
outdir: base,
|
|
19
|
+
entryNames: '[name]-[hash]',
|
|
20
|
+
chunkNames: 'chunk-[hash]',
|
|
21
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
22
|
+
metafile: true,
|
|
23
|
+
write: false,
|
|
24
|
+
logLevel: 'silent',
|
|
25
|
+
});
|
|
26
|
+
for (const file of result.outputFiles)
|
|
27
|
+
out.files[file.path.slice(file.path.indexOf(base))] = file.text;
|
|
28
|
+
for (const [path, meta] of Object.entries(result.metafile.outputs)) {
|
|
29
|
+
if (!meta.entryPoint)
|
|
30
|
+
continue;
|
|
31
|
+
const ref = entries.find(([, file]) => relative(process.cwd(), file) === meta.entryPoint)?.[0];
|
|
32
|
+
if (!ref)
|
|
33
|
+
continue;
|
|
34
|
+
out.urls[ref] = path.slice(path.indexOf(base));
|
|
35
|
+
if (meta.exports.includes('default'))
|
|
36
|
+
continue;
|
|
37
|
+
const [feature, symbol] = ref.split('.');
|
|
38
|
+
out.diagnostics.push({
|
|
39
|
+
code: 'HZ029',
|
|
40
|
+
severity: codes.HZ029.severity,
|
|
41
|
+
message: `Widget module for ${ref} has no default export`,
|
|
42
|
+
location: {
|
|
43
|
+
feature,
|
|
44
|
+
pointer: join('', 'features', feature, 'widgets', symbol, 'client'),
|
|
45
|
+
source: null,
|
|
46
|
+
},
|
|
47
|
+
cause: 'The runtime mounts the default export of the widget module.',
|
|
48
|
+
fix: {
|
|
49
|
+
summary: 'Export the setup function',
|
|
50
|
+
snippet: `export default implement<typeof ${symbol}>(({ el, props, emit, signal }) => ({ update(next) {}, destroy() {} }))`,
|
|
51
|
+
patch: null,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAoB,KAAK,EAAmB,IAAI,EAAE,MAAM,eAAe,CAAA;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAQ/B,MAAM,IAAI,GAAG,UAAU,CAAA;AAEvB,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAoB,EACpB,EAAE,MAAM,GAAG,IAAI,EAAE,GAAyB,EAAE;IAE5C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACxD,MAAM,GAAG,GAAiB,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAA;IAClE,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,GAAG,CAAA;IAC/B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,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AO,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,SAAQ;QAC9C,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAA;QAC5D,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ;YAC9B,OAAO,EAAE,qBAAqB,GAAG,wBAAwB;YACzD,QAAQ,EAAE;gBACR,OAAO;gBACP,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;gBACnE,MAAM,EAAE,IAAI;aACb;YACD,KAAK,EAAE,6DAA6D;YACpE,GAAG,EAAE;gBACH,OAAO,EAAE,2BAA2B;gBACpC,OAAO,EAAE,mCAAmC,MAAM,yEAAyE;gBAC3H,KAAK,EAAE,IAAI;aACZ;SACF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hozu/bundle",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Bundles Hozu widget client modules with esbuild",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"hozu",
|
|
7
|
+
"framework",
|
|
8
|
+
"ai",
|
|
9
|
+
"agents",
|
|
10
|
+
"ssr",
|
|
11
|
+
"islands",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/olevatorr/Hozu/tree/main/packages/bundle#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/olevatorr/Hozu/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/olevatorr/Hozu.git",
|
|
21
|
+
"directory": "packages/bundle"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "olevatorr",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.18"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"esbuild": "0.28.2",
|
|
43
|
+
"@hozu/core": "0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"sideEffects": false
|
|
46
|
+
}
|