@evjs/bundler-utoopack 0.0.23
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 +48 -0
- package/esm/adapter/create-config.d.ts +19 -0
- package/esm/adapter/create-config.d.ts.map +1 -0
- package/esm/adapter/create-config.js +94 -0
- package/esm/adapter/create-config.js.map +1 -0
- package/esm/adapter/index.d.ts +12 -0
- package/esm/adapter/index.d.ts.map +1 -0
- package/esm/adapter/index.js +108 -0
- package/esm/adapter/index.js.map +1 -0
- package/esm/index.d.ts +9 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +9 -0
- package/esm/index.js.map +1 -0
- package/esm/manifest-generator.d.ts +39 -0
- package/esm/manifest-generator.d.ts.map +1 -0
- package/esm/manifest-generator.js +232 -0
- package/esm/manifest-generator.js.map +1 -0
- package/esm/plugin-helper.d.ts +26 -0
- package/esm/plugin-helper.d.ts.map +1 -0
- package/esm/plugin-helper.js +30 -0
- package/esm/plugin-helper.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @evjs/bundler-utoopack
|
|
2
|
+
|
|
3
|
+
The default utoopack (`@utoo/pack`) bundler adapter for the evjs framework.
|
|
4
|
+
|
|
5
|
+
This package provides the internal `utoopackAdapter` that implements the `BundlerAdapter` interface for `ev build` and `ev dev`.
|
|
6
|
+
|
|
7
|
+
Unlike webpack, utoopack natively supports `"use server"` directives through its unified module graph without needing a custom child compiler. This adapter directly integrates with utoopack's programmatic API to emit client and server manifests.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
This adapter is enabled by default in evjs. You do not need to configure it manually unless you are overriding another bundler.
|
|
12
|
+
|
|
13
|
+
If you need to explicitly configure it:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { defineConfig } from "@evjs/ev";
|
|
17
|
+
import { utoopackAdapter } from "@evjs/bundler-utoopack";
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
bundler: utoopackAdapter,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Plugin Helper
|
|
25
|
+
|
|
26
|
+
The `utoopack()` helper wraps your plugin hooks for type-safe configuration mutation:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { defineConfig } from "@evjs/ev";
|
|
30
|
+
import { utoopack } from "@evjs/bundler-utoopack";
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
plugins: [
|
|
34
|
+
{
|
|
35
|
+
name: "my-utoopack-plugin",
|
|
36
|
+
setup() {
|
|
37
|
+
return {
|
|
38
|
+
bundlerConfig: utoopack((config) => {
|
|
39
|
+
// config is typed as ConfigComplete from @utoo/pack
|
|
40
|
+
config.env ??= {};
|
|
41
|
+
config.env.__MY_VAR__ = JSON.stringify("value");
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map ResolvedEvConfig to a utoopack configuration object.
|
|
3
|
+
*
|
|
4
|
+
* Utoopack uses a JSON-based config with `build()` / `dev()` programmatic API.
|
|
5
|
+
* Unlike webpack, it handles "use server" directives natively via the
|
|
6
|
+
* `server.functions.callServerModule` config field.
|
|
7
|
+
*/
|
|
8
|
+
import type { EvPluginHooks, ResolvedEvConfig } from "@evjs/ev";
|
|
9
|
+
import type { ConfigComplete } from "@utoo/pack";
|
|
10
|
+
/**
|
|
11
|
+
* Create a utoopack configuration object from EvConfig.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Resolved evjs config
|
|
14
|
+
* @param cwd - Project root directory
|
|
15
|
+
* @param hooks - Plugin lifecycle hooks
|
|
16
|
+
* @returns A config object suitable for `@utoo/pack`'s `build()` / `dev()` API
|
|
17
|
+
*/
|
|
18
|
+
export declare function createUtoopackConfig(config: ResolvedEvConfig<ConfigComplete>, cwd: string, hooks: EvPluginHooks<ConfigComplete>[]): ConfigComplete;
|
|
19
|
+
//# sourceMappingURL=create-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../src/adapter/create-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EAAgB,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,CAAC,cAAc,CAAC,EACxC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,GACrC,cAAc,CA+EhB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map ResolvedEvConfig to a utoopack configuration object.
|
|
3
|
+
*
|
|
4
|
+
* Utoopack uses a JSON-based config with `build()` / `dev()` programmatic API.
|
|
5
|
+
* Unlike webpack, it handles "use server" directives natively via the
|
|
6
|
+
* `server.functions.callServerModule` config field.
|
|
7
|
+
*/
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
const _require = createRequire(import.meta.url);
|
|
11
|
+
/**
|
|
12
|
+
* Create a utoopack configuration object from EvConfig.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Resolved evjs config
|
|
15
|
+
* @param cwd - Project root directory
|
|
16
|
+
* @param hooks - Plugin lifecycle hooks
|
|
17
|
+
* @returns A config object suitable for `@utoo/pack`'s `build()` / `dev()` API
|
|
18
|
+
*/
|
|
19
|
+
export function createUtoopackConfig(config, cwd, hooks) {
|
|
20
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
21
|
+
const serverEnabled = config.serverEnabled;
|
|
22
|
+
const utoopackConfig = {
|
|
23
|
+
mode: isProduction ? "production" : "development",
|
|
24
|
+
entry: [
|
|
25
|
+
{
|
|
26
|
+
import: config.entry,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
output: {
|
|
30
|
+
path: path.resolve(cwd, serverEnabled ? "dist/client" : "dist"),
|
|
31
|
+
filename: isProduction ? "[name].[contenthash:8].js" : "[name].js",
|
|
32
|
+
chunkFilename: isProduction ? "[name].[contenthash:8].js" : "[name].js",
|
|
33
|
+
publicPath: isProduction ? config.assetPrefix : "/",
|
|
34
|
+
clean: true,
|
|
35
|
+
},
|
|
36
|
+
resolve: {
|
|
37
|
+
extensions: [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"],
|
|
38
|
+
},
|
|
39
|
+
sourceMaps: !isProduction,
|
|
40
|
+
stats: true,
|
|
41
|
+
react: {
|
|
42
|
+
runtime: "automatic",
|
|
43
|
+
},
|
|
44
|
+
// Server functions config — utoopack handles "use server" natively
|
|
45
|
+
...(serverEnabled
|
|
46
|
+
? {
|
|
47
|
+
server: {
|
|
48
|
+
entry: config.server.entry ?? _require.resolve("@evjs/server"),
|
|
49
|
+
output: {
|
|
50
|
+
path: path.resolve(cwd, "dist/server"),
|
|
51
|
+
filename: isProduction
|
|
52
|
+
? "[name].[contenthash:8].js"
|
|
53
|
+
: "[name].js",
|
|
54
|
+
chunkFilename: isProduction
|
|
55
|
+
? "[name].[contenthash:8].js"
|
|
56
|
+
: "[name].js",
|
|
57
|
+
},
|
|
58
|
+
function: {
|
|
59
|
+
clientProxy: "@evjs/client/transport",
|
|
60
|
+
serverRegister: "@evjs/server/register",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
: {}),
|
|
65
|
+
// Dev server configuration
|
|
66
|
+
devServer: {
|
|
67
|
+
hot: true,
|
|
68
|
+
...(serverEnabled
|
|
69
|
+
? {
|
|
70
|
+
proxy: [
|
|
71
|
+
{
|
|
72
|
+
context: [config.server.endpoint],
|
|
73
|
+
target: `${config.server.dev.https ? "https" : "http"}://localhost:${config.server.dev.port}`,
|
|
74
|
+
changeOrigin: true,
|
|
75
|
+
secure: false,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
: {}),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
// Run plugin bundler hooks
|
|
83
|
+
const ctx = {
|
|
84
|
+
mode: isProduction ? "production" : "development",
|
|
85
|
+
config,
|
|
86
|
+
};
|
|
87
|
+
for (const h of hooks) {
|
|
88
|
+
if (h.bundlerConfig) {
|
|
89
|
+
h.bundlerConfig(utoopackConfig, ctx);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return utoopackConfig;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=create-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-config.js","sourceRoot":"","sources":["../../src/adapter/create-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAKhD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAwC,EACxC,GAAW,EACX,KAAsC;IAEtC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAC3D,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;IAE3C,MAAM,cAAc,GAAmB;QACrC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;QACjD,KAAK,EAAE;YACL;gBACE,MAAM,EAAE,MAAM,CAAC,KAAK;aACrB;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,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MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;4BACjC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,gBAAgB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;4BAC7F,YAAY,EAAE,IAAI;4BAClB,MAAM,EAAE,KAAK;yBACd;qBACF;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;IAEF,2BAA2B;IAC3B,MAAM,GAAG,GAAiC;QACxC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;QACjD,MAAM;KACP,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;YACpB,CAAC,CAAC,aAAa,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utoopack bundler adapter.
|
|
3
|
+
*
|
|
4
|
+
* Implements the BundlerAdapter interface using @utoo/pack's
|
|
5
|
+
* programmatic `build()` and `dev()` APIs. Unlike the webpack adapter,
|
|
6
|
+
* utoopack handles "use server" directives natively — no custom loader
|
|
7
|
+
* or child compiler is needed.
|
|
8
|
+
*/
|
|
9
|
+
import type { BundlerAdapter } from "@evjs/ev";
|
|
10
|
+
import type { ConfigComplete } from "@utoo/pack";
|
|
11
|
+
export declare const utoopackAdapter: BundlerAdapter<ConfigComplete>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAmC,MAAM,UAAU,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA0DjD,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,cAAc,CA0F1D,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utoopack bundler adapter.
|
|
3
|
+
*
|
|
4
|
+
* Implements the BundlerAdapter interface using @utoo/pack's
|
|
5
|
+
* programmatic `build()` and `dev()` APIs. Unlike the webpack adapter,
|
|
6
|
+
* utoopack handles "use server" directives natively — no custom loader
|
|
7
|
+
* or child compiler is needed.
|
|
8
|
+
*/
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { getLogger } from "@logtape/logtape";
|
|
12
|
+
import { UtoopackManifestGenerator } from "../manifest-generator.js";
|
|
13
|
+
const logger = getLogger(["evjs", "bundler-utoopack"]);
|
|
14
|
+
async function generateAndEmitHtml(config, cwd, hooks) {
|
|
15
|
+
const isServerEnabled = config.serverEnabled;
|
|
16
|
+
const clientManifestPath = path.resolve(cwd, isServerEnabled ? "dist/client/manifest.json" : "dist/manifest.json");
|
|
17
|
+
if (!fs.existsSync(clientManifestPath))
|
|
18
|
+
return;
|
|
19
|
+
const clientManifest = JSON.parse(await fs.promises.readFile(clientManifestPath, "utf-8"));
|
|
20
|
+
// biome-ignore lint/suspicious/noExplicitAny: match @evjs/manifest type
|
|
21
|
+
let serverManifest;
|
|
22
|
+
if (isServerEnabled) {
|
|
23
|
+
const serverManifestPath = path.resolve(cwd, "dist/server/manifest.json");
|
|
24
|
+
if (fs.existsSync(serverManifestPath)) {
|
|
25
|
+
serverManifest = JSON.parse(await fs.promises.readFile(serverManifestPath, "utf-8"));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const { generateHtml } = await import("@evjs/build-tools");
|
|
29
|
+
const doc = generateHtml({
|
|
30
|
+
template: path.resolve(cwd, config.html),
|
|
31
|
+
js: clientManifest.assets.js,
|
|
32
|
+
css: clientManifest.assets.css,
|
|
33
|
+
assetPrefix: config.assetPrefix,
|
|
34
|
+
});
|
|
35
|
+
const { buildHtml } = await import("@evjs/ev");
|
|
36
|
+
const finalHtml = await buildHtml({
|
|
37
|
+
// biome-ignore lint/suspicious/noExplicitAny: DOM interfaces
|
|
38
|
+
doc: doc,
|
|
39
|
+
assetPrefix: config.assetPrefix,
|
|
40
|
+
// biome-ignore lint/suspicious/noExplicitAny: Bundler-agnostic hook generic
|
|
41
|
+
hooks: hooks,
|
|
42
|
+
clientManifest,
|
|
43
|
+
serverManifest,
|
|
44
|
+
});
|
|
45
|
+
const outPath = path.resolve(cwd, isServerEnabled ? "dist/client/index.html" : "dist/index.html");
|
|
46
|
+
await fs.promises.mkdir(path.dirname(outPath), { recursive: true });
|
|
47
|
+
await fs.promises.writeFile(outPath, finalHtml, "utf-8");
|
|
48
|
+
}
|
|
49
|
+
export const utoopackAdapter = {
|
|
50
|
+
name: "utoopack",
|
|
51
|
+
async build(config, cwd, hooks) {
|
|
52
|
+
const { createUtoopackConfig } = await import("./create-config.js");
|
|
53
|
+
const utoopackConfig = createUtoopackConfig(config, cwd, hooks);
|
|
54
|
+
logger.info `Building for production with utoopack...`;
|
|
55
|
+
const { build } = await import("@utoo/pack");
|
|
56
|
+
await build({ config: utoopackConfig });
|
|
57
|
+
logger.info `Extracting routes and generating client manifest...`;
|
|
58
|
+
const generator = new UtoopackManifestGenerator(cwd, config.serverEnabled, config.assetPrefix);
|
|
59
|
+
await generator.build();
|
|
60
|
+
logger.info `Generating and emitting HTML...`;
|
|
61
|
+
await generateAndEmitHtml(config, cwd, hooks);
|
|
62
|
+
logger.info `Build complete!`;
|
|
63
|
+
},
|
|
64
|
+
async dev(config, cwd, callbacks, hooks) {
|
|
65
|
+
const { createUtoopackConfig } = await import("./create-config.js");
|
|
66
|
+
const utoopackConfig = createUtoopackConfig(config, cwd, hooks);
|
|
67
|
+
logger.info `Starting development server with utoopack...`;
|
|
68
|
+
const { serve } = await import("@utoo/pack");
|
|
69
|
+
await serve({ config: utoopackConfig });
|
|
70
|
+
logger.info `Starting route watcher for dev manifest...`;
|
|
71
|
+
const generator = new UtoopackManifestGenerator(cwd, config.serverEnabled, config.assetPrefix);
|
|
72
|
+
await generator.watch(async () => {
|
|
73
|
+
await generateAndEmitHtml(config, cwd, hooks);
|
|
74
|
+
});
|
|
75
|
+
// Watch for server bundle readiness (utoopack emits server output
|
|
76
|
+
// to dist/server/ when "use server" modules are discovered)
|
|
77
|
+
if (config.serverEnabled) {
|
|
78
|
+
const outDir = path.resolve(cwd, "dist/server");
|
|
79
|
+
if (!fs.existsSync(outDir)) {
|
|
80
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
let ready = false;
|
|
83
|
+
const checkReady = async (filename) => {
|
|
84
|
+
if (ready)
|
|
85
|
+
return;
|
|
86
|
+
const hasBundle = filename
|
|
87
|
+
? filename === "stats.json" || filename.endsWith(".js")
|
|
88
|
+
: (await fs.promises.readdir(outDir).catch(() => [])).some((f) => f === "stats.json" || f.endsWith(".js"));
|
|
89
|
+
if (hasBundle) {
|
|
90
|
+
ready = true;
|
|
91
|
+
// Re-generate manifests now that server stats are available
|
|
92
|
+
await generator.loadServerStats();
|
|
93
|
+
await generator.emit();
|
|
94
|
+
await generateAndEmitHtml(config, cwd, hooks);
|
|
95
|
+
callbacks.onServerBundleReady();
|
|
96
|
+
watcher?.close();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const watcher = fs.watch(outDir, (_eventType, filename) => {
|
|
100
|
+
if (filename)
|
|
101
|
+
checkReady(filename);
|
|
102
|
+
});
|
|
103
|
+
// Initial check in case it was written before the watcher attached
|
|
104
|
+
checkReady();
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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E,EAAE;gBACxD,IAAI,QAAQ;oBAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YAEH,mEAAmE;YACnE,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utoopack bundler adapter for the evjs framework.
|
|
3
|
+
*
|
|
4
|
+
* Leverages @utoo/pack's native "use server" directive support
|
|
5
|
+
* for zero-config server function handling.
|
|
6
|
+
*/
|
|
7
|
+
export { utoopackAdapter } from "./adapter/index.js";
|
|
8
|
+
export { utoopack } from "./plugin-helper.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utoopack bundler adapter for the evjs framework.
|
|
3
|
+
*
|
|
4
|
+
* Leverages @utoo/pack's native "use server" directive support
|
|
5
|
+
* for zero-config server function handling.
|
|
6
|
+
*/
|
|
7
|
+
export { utoopackAdapter } from "./adapter/index.js";
|
|
8
|
+
export { utoopack } from "./plugin-helper.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare class UtoopackManifestGenerator {
|
|
2
|
+
private collector;
|
|
3
|
+
private cwd;
|
|
4
|
+
private assetPrefix?;
|
|
5
|
+
private serverEnabled;
|
|
6
|
+
private watcher;
|
|
7
|
+
private currentRoutes;
|
|
8
|
+
constructor(cwd: string, serverEnabled: boolean, assetPrefix?: string);
|
|
9
|
+
/**
|
|
10
|
+
* Load client assets from the client `stats.json` emitted by Utoopack.
|
|
11
|
+
* In development, this file may not exist, which is expected since
|
|
12
|
+
* Utoopack handles HTML client injection natively.
|
|
13
|
+
*/
|
|
14
|
+
loadClientStats(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Load server entry and function registrations from the server `stats.json`.
|
|
17
|
+
*
|
|
18
|
+
* When Utoopack doesn't emit a server stats.json (e.g. older versions),
|
|
19
|
+
* falls back to scanning dist/server/ for a JS entry and creating a
|
|
20
|
+
* synthetic manifest.
|
|
21
|
+
*/
|
|
22
|
+
loadServerStats(): Promise<void>;
|
|
23
|
+
processFile(filepath: string): Promise<void>;
|
|
24
|
+
private rebuildRoutes;
|
|
25
|
+
/**
|
|
26
|
+
* Emit the client manifest (and server manifest if server is enabled).
|
|
27
|
+
*/
|
|
28
|
+
emit(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Run a full post-build manifest generation pass.
|
|
31
|
+
*/
|
|
32
|
+
build(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Run manifest generation continually by watching the filesystem in development.
|
|
35
|
+
*/
|
|
36
|
+
watch(onUpdate?: () => void | Promise<void>): Promise<void>;
|
|
37
|
+
close(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=manifest-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-generator.d.ts","sourceRoot":"","sources":["../src/manifest-generator.ts"],"names":[],"mappings":"AAqFA,qBAAa,yBAAyB;IACpC,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,aAAa,CAAuC;gBAEhD,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM;IAMrE;;;;OAIG;IACG,eAAe;IAoBrB;;;;;;OAMG;IACG,eAAe;IA8Bf,WAAW,CAAC,QAAQ,EAAE,MAAM;IAclC,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACG,IAAI;IAoCV;;OAEG;IACG,KAAK;IAWX;;OAEG;IACG,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC3C,KAAK;CAKZ"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { extractRoutes } from "@evjs/build-tools";
|
|
4
|
+
import { ManifestCollector, } from "@evjs/manifest";
|
|
5
|
+
import { getLogger } from "@logtape/logtape";
|
|
6
|
+
import chokidar from "chokidar";
|
|
7
|
+
import fastGlob from "fast-glob";
|
|
8
|
+
const logger = getLogger(["evjs", "bundler-utoopack", "manifest"]);
|
|
9
|
+
/**
|
|
10
|
+
* Parse a Utoopack stats.json file and extract asset filenames.
|
|
11
|
+
*
|
|
12
|
+
* @returns lists of JS and CSS asset filenames from the main entrypoint.
|
|
13
|
+
*/
|
|
14
|
+
function parseClientStats(stats) {
|
|
15
|
+
const jsFiles = [];
|
|
16
|
+
const cssFiles = [];
|
|
17
|
+
// Use first entrypoint — utoopack may name it by the output file rather than "main"
|
|
18
|
+
const entrypoints = stats.entrypoints;
|
|
19
|
+
const firstEntry = entrypoints ? Object.values(entrypoints)[0] : undefined;
|
|
20
|
+
if (firstEntry && Array.isArray(firstEntry.assets)) {
|
|
21
|
+
for (const asset of firstEntry.assets) {
|
|
22
|
+
const name = asset.name?.replace(/^\.\//, "");
|
|
23
|
+
if (name?.endsWith(".js")) {
|
|
24
|
+
jsFiles.push(name);
|
|
25
|
+
}
|
|
26
|
+
else if (name?.endsWith(".css")) {
|
|
27
|
+
cssFiles.push(name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { js: jsFiles, css: cssFiles };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parse a Utoopack server stats.json and extract entry filename and
|
|
35
|
+
* server function registrations.
|
|
36
|
+
*
|
|
37
|
+
* The server stats.json shape (emitted by @utoo/pack when server
|
|
38
|
+
* references are enabled):
|
|
39
|
+
*
|
|
40
|
+
* ```json
|
|
41
|
+
* {
|
|
42
|
+
* "entrypoints": {
|
|
43
|
+
* "main": { "assets": [{ "name": "index.js" }] }
|
|
44
|
+
* },
|
|
45
|
+
* "serverFunctions": {
|
|
46
|
+
* "<fnId>": { "moduleId": "<hash>", "export": "functionName" }
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
function parseServerStats(stats) {
|
|
52
|
+
let entry;
|
|
53
|
+
// Use first entrypoint — utoopack may name it by the output file rather than "main"
|
|
54
|
+
const entrypoints = stats.entrypoints;
|
|
55
|
+
const firstEntry = entrypoints ? Object.values(entrypoints)[0] : undefined;
|
|
56
|
+
if (firstEntry && Array.isArray(firstEntry.assets)) {
|
|
57
|
+
const jsAsset = firstEntry.assets.find((a) => a.name?.endsWith(".js"));
|
|
58
|
+
entry = jsAsset?.name?.replace(/^\.\//, "");
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
entry,
|
|
62
|
+
fns: stats.serverFunctions ?? {},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export class UtoopackManifestGenerator {
|
|
66
|
+
collector = new ManifestCollector();
|
|
67
|
+
cwd;
|
|
68
|
+
assetPrefix;
|
|
69
|
+
serverEnabled;
|
|
70
|
+
watcher = null;
|
|
71
|
+
currentRoutes = new Map();
|
|
72
|
+
constructor(cwd, serverEnabled, assetPrefix) {
|
|
73
|
+
this.cwd = cwd;
|
|
74
|
+
this.serverEnabled = serverEnabled;
|
|
75
|
+
this.assetPrefix = assetPrefix;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Load client assets from the client `stats.json` emitted by Utoopack.
|
|
79
|
+
* In development, this file may not exist, which is expected since
|
|
80
|
+
* Utoopack handles HTML client injection natively.
|
|
81
|
+
*/
|
|
82
|
+
async loadClientStats() {
|
|
83
|
+
const statsPath = path.resolve(this.cwd, this.serverEnabled ? "dist/client/stats.json" : "dist/stats.json");
|
|
84
|
+
if (!fs.existsSync(statsPath)) {
|
|
85
|
+
this.collector.setAssets([], []);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const statsStr = await fs.promises.readFile(statsPath, "utf-8");
|
|
90
|
+
const stats = JSON.parse(statsStr);
|
|
91
|
+
const { js, css } = parseClientStats(stats);
|
|
92
|
+
this.collector.setAssets(js, css);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
logger.warn `Failed to parse client stats.json: ${err}`;
|
|
96
|
+
this.collector.setAssets([], []);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Load server entry and function registrations from the server `stats.json`.
|
|
101
|
+
*
|
|
102
|
+
* When Utoopack doesn't emit a server stats.json (e.g. older versions),
|
|
103
|
+
* falls back to scanning dist/server/ for a JS entry and creating a
|
|
104
|
+
* synthetic manifest.
|
|
105
|
+
*/
|
|
106
|
+
async loadServerStats() {
|
|
107
|
+
if (!this.serverEnabled)
|
|
108
|
+
return;
|
|
109
|
+
const statsPath = path.resolve(this.cwd, "dist/server/stats.json");
|
|
110
|
+
if (fs.existsSync(statsPath)) {
|
|
111
|
+
try {
|
|
112
|
+
const statsStr = await fs.promises.readFile(statsPath, "utf-8");
|
|
113
|
+
const stats = JSON.parse(statsStr);
|
|
114
|
+
const { entry, fns } = parseServerStats(stats);
|
|
115
|
+
this.collector.entry = entry;
|
|
116
|
+
for (const [id, meta] of Object.entries(fns)) {
|
|
117
|
+
this.collector.addServerFn(id, meta);
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
logger.warn `Failed to parse server stats.json: ${err}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Fallback: scan for JS entry in dist/server/
|
|
126
|
+
const serverDir = path.resolve(this.cwd, "dist/server");
|
|
127
|
+
if (fs.existsSync(serverDir)) {
|
|
128
|
+
const files = await fs.promises.readdir(serverDir);
|
|
129
|
+
const jsEntry = files.find((f) => f.endsWith(".js"));
|
|
130
|
+
if (jsEntry) {
|
|
131
|
+
this.collector.entry = jsEntry;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async processFile(filepath) {
|
|
136
|
+
try {
|
|
137
|
+
const content = await fs.promises.readFile(filepath, "utf-8");
|
|
138
|
+
const routes = extractRoutes(content);
|
|
139
|
+
if (routes.length > 0) {
|
|
140
|
+
this.currentRoutes.set(filepath, routes);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.currentRoutes.delete(filepath);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (_err) {
|
|
147
|
+
this.currentRoutes.delete(filepath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
rebuildRoutes() {
|
|
151
|
+
this.collector.routes = [];
|
|
152
|
+
for (const routes of this.currentRoutes.values()) {
|
|
153
|
+
this.collector.addRoutes(routes);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Emit the client manifest (and server manifest if server is enabled).
|
|
158
|
+
*/
|
|
159
|
+
async emit() {
|
|
160
|
+
this.rebuildRoutes();
|
|
161
|
+
// Client manifest — matches ClientManifest from @evjs/manifest
|
|
162
|
+
const clientManifest = this.collector.getClientManifest(this.assetPrefix);
|
|
163
|
+
const clientOutPath = path.resolve(this.cwd, this.serverEnabled ? "dist/client/manifest.json" : "dist/manifest.json");
|
|
164
|
+
const clientOutDir = path.dirname(clientOutPath);
|
|
165
|
+
if (!fs.existsSync(clientOutDir)) {
|
|
166
|
+
await fs.promises.mkdir(clientOutDir, { recursive: true });
|
|
167
|
+
}
|
|
168
|
+
await fs.promises.writeFile(clientOutPath, JSON.stringify(clientManifest, null, 2));
|
|
169
|
+
// Server manifest
|
|
170
|
+
if (this.serverEnabled) {
|
|
171
|
+
// Server manifest — matches ServerManifest from @evjs/manifest
|
|
172
|
+
const serverManifest = this.collector.getServerManifest();
|
|
173
|
+
const serverOutDir = path.resolve(this.cwd, "dist/server");
|
|
174
|
+
if (!fs.existsSync(serverOutDir)) {
|
|
175
|
+
await fs.promises.mkdir(serverOutDir, { recursive: true });
|
|
176
|
+
}
|
|
177
|
+
await fs.promises.writeFile(path.join(serverOutDir, "manifest.json"), JSON.stringify(serverManifest, null, 2));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Run a full post-build manifest generation pass.
|
|
182
|
+
*/
|
|
183
|
+
async build() {
|
|
184
|
+
await this.loadClientStats();
|
|
185
|
+
await this.loadServerStats();
|
|
186
|
+
const files = await fastGlob("src/**/*.{ts,tsx,js,jsx}", {
|
|
187
|
+
cwd: this.cwd,
|
|
188
|
+
absolute: true,
|
|
189
|
+
});
|
|
190
|
+
await Promise.all(files.map((f) => this.processFile(f)));
|
|
191
|
+
await this.emit();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Run manifest generation continually by watching the filesystem in development.
|
|
195
|
+
*/
|
|
196
|
+
async watch(onUpdate) {
|
|
197
|
+
await this.loadClientStats();
|
|
198
|
+
await this.loadServerStats();
|
|
199
|
+
const files = await fastGlob("src/**/*.{ts,tsx,js,jsx}", {
|
|
200
|
+
cwd: this.cwd,
|
|
201
|
+
absolute: true,
|
|
202
|
+
});
|
|
203
|
+
await Promise.all(files.map((f) => this.processFile(f)));
|
|
204
|
+
await this.emit();
|
|
205
|
+
await onUpdate?.();
|
|
206
|
+
this.watcher = chokidar.watch("src/**/*.{ts,tsx,js,jsx}", {
|
|
207
|
+
cwd: this.cwd,
|
|
208
|
+
ignoreInitial: true,
|
|
209
|
+
});
|
|
210
|
+
const handleChange = async (filepath) => {
|
|
211
|
+
const fullPath = path.resolve(this.cwd, filepath);
|
|
212
|
+
await this.processFile(fullPath);
|
|
213
|
+
await this.emit();
|
|
214
|
+
await onUpdate?.();
|
|
215
|
+
};
|
|
216
|
+
const handleUnlink = async (filepath) => {
|
|
217
|
+
const fullPath = path.resolve(this.cwd, filepath);
|
|
218
|
+
this.currentRoutes.delete(fullPath);
|
|
219
|
+
await this.emit();
|
|
220
|
+
await onUpdate?.();
|
|
221
|
+
};
|
|
222
|
+
this.watcher.on("add", handleChange);
|
|
223
|
+
this.watcher.on("change", handleChange);
|
|
224
|
+
this.watcher.on("unlink", handleUnlink);
|
|
225
|
+
}
|
|
226
|
+
async close() {
|
|
227
|
+
if (this.watcher) {
|
|
228
|
+
await this.watcher.close();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=manifest-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-generator.js","sourceRoot":"","sources":["../src/manifest-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAuB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAEL,iBAAiB,GAGlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAA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
|
|
1
|
+
import type { EvBundlerCtx } from "@evjs/ev";
|
|
2
|
+
import type { ConfigComplete } from "@utoo/pack";
|
|
3
|
+
/**
|
|
4
|
+
* Typed wrapper for utoopack configuration in plugin bundler hooks.
|
|
5
|
+
*
|
|
6
|
+
* Use this in your plugin's `bundlerConfig` hook to get full `ConfigComplete`
|
|
7
|
+
* type safety instead of `unknown`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { utoopack } from "@evjs/bundler-utoopack";
|
|
12
|
+
*
|
|
13
|
+
* const myPlugin: EvPlugin = {
|
|
14
|
+
* name: "my-plugin",
|
|
15
|
+
* setup(ctx) {
|
|
16
|
+
* return {
|
|
17
|
+
* bundlerConfig: utoopack((config) => {
|
|
18
|
+
* // config is typed as ConfigComplete from @utoo/pack
|
|
19
|
+
* }),
|
|
20
|
+
* };
|
|
21
|
+
* },
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function utoopack<T = unknown>(fn: (config: ConfigComplete, ctx: EvBundlerCtx<ConfigComplete>) => void): (config: T, ctx: EvBundlerCtx<T>) => void;
|
|
26
|
+
//# sourceMappingURL=plugin-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-helper.d.ts","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,EAAE,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,KAAK,IAAI,GACtE,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAS3C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrapper for utoopack configuration in plugin bundler hooks.
|
|
3
|
+
*
|
|
4
|
+
* Use this in your plugin's `bundlerConfig` hook to get full `ConfigComplete`
|
|
5
|
+
* type safety instead of `unknown`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { utoopack } from "@evjs/bundler-utoopack";
|
|
10
|
+
*
|
|
11
|
+
* const myPlugin: EvPlugin = {
|
|
12
|
+
* name: "my-plugin",
|
|
13
|
+
* setup(ctx) {
|
|
14
|
+
* return {
|
|
15
|
+
* bundlerConfig: utoopack((config) => {
|
|
16
|
+
* // config is typed as ConfigComplete from @utoo/pack
|
|
17
|
+
* }),
|
|
18
|
+
* };
|
|
19
|
+
* },
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function utoopack(fn) {
|
|
24
|
+
return (config, ctx) => {
|
|
25
|
+
if (ctx.config.bundler?.name === "utoopack") {
|
|
26
|
+
fn(config, ctx);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=plugin-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-helper.js","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,QAAQ,CACtB,EAAuE;IAEvE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACrB,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5C,EAAE,CACA,MAAmC,EACnC,GAA8C,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@evjs/bundler-utoopack",
|
|
3
|
+
"version": "0.0.23",
|
|
4
|
+
"description": "Utoopack bundler adapter for the evjs framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"main": "./esm/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./esm/index.d.ts",
|
|
13
|
+
"import": "./esm/index.js",
|
|
14
|
+
"default": "./esm/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"check-types": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"esm"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"evjs",
|
|
26
|
+
"utoopack",
|
|
27
|
+
"turbopack",
|
|
28
|
+
"bundler"
|
|
29
|
+
],
|
|
30
|
+
"author": "xusd320",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@evjs/build-tools": "*",
|
|
34
|
+
"@evjs/ev": "*",
|
|
35
|
+
"@evjs/manifest": "*",
|
|
36
|
+
"@logtape/logtape": "^2.0.4",
|
|
37
|
+
"@utoo/pack": "^1.4.0",
|
|
38
|
+
"chokidar": "^3.6.0",
|
|
39
|
+
"fast-glob": "^3.3.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^22.19.15",
|
|
43
|
+
"typescript": "^6.0.2"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/evaijs/evjs#readme",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/evaijs/evjs/issues"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/evaijs/evjs.git"
|
|
52
|
+
}
|
|
53
|
+
}
|