@vercube/devkit 0.0.42 → 0.0.45
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/dist/index.mjs +33 -24
- package/package.json +10 -9
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { builtinModules } from "node:module";
|
|
2
2
|
import { loadVercubeConfig } from "@vercube/core";
|
|
3
3
|
import { createHooks } from "hookable";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import consola, { consola as consola$1 } from "consola";
|
|
6
|
+
import { colors } from "consola/utils";
|
|
4
7
|
import { rolldown, watch as watch$1 } from "rolldown";
|
|
5
|
-
import {
|
|
8
|
+
import { defu } from "defu";
|
|
9
|
+
import { resolve as resolve$1 } from "pathe";
|
|
6
10
|
import UnpluginIsolatedDecl from "unplugin-isolated-decl/rolldown";
|
|
7
11
|
import { watch as watch$2 } from "chokidar";
|
|
8
|
-
import consola from "consola";
|
|
9
12
|
import { fork } from "node:child_process";
|
|
10
|
-
import { resolve as resolve$1 } from "node:path";
|
|
11
|
-
|
|
12
13
|
//#region src/Common/App.ts
|
|
13
14
|
/**
|
|
14
15
|
* Creates a development server application.
|
|
@@ -24,18 +25,23 @@ async function createVercube(cfg) {
|
|
|
24
25
|
})
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/Bundlers/Rolldown/Config.ts
|
|
30
30
|
/**
|
|
31
31
|
* Generates a Rolldown configuration based on the provided build options.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* Builds a base config from `ctx` (entry, output, tsconfig, plugins, defines, etc.) and then
|
|
34
|
+
* deep-merges it with `ctx.rolldownConfig` using `defu`, so user-supplied options take precedence
|
|
35
|
+
* over the defaults. The `input`, `output`, and `onwarn` fields are always controlled internally
|
|
36
|
+
* and cannot be overridden via `rolldownConfig`.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx - Build configuration options. When omitted, sensible defaults are used
|
|
39
|
+
* (entry: `src/index.ts`, output: `dist`, tsconfig: `tsconfig.json`, dts: `true`).
|
|
40
|
+
* @returns A promise that resolves to the merged Rolldown configuration.
|
|
35
41
|
*/
|
|
36
42
|
async function getRolldownConfig(ctx) {
|
|
37
43
|
const root = ctx?.root ?? process.cwd();
|
|
38
|
-
const pkg = (await import(resolve(root, "package.json"), { with: { type: "json" } })).default;
|
|
44
|
+
const pkg = (await import(resolve$1(root, "package.json"), { with: { type: "json" } })).default;
|
|
39
45
|
const input = ctx?.entry ?? "src/index.ts";
|
|
40
46
|
const output = ctx?.output?.dir ?? "dist";
|
|
41
47
|
const tsconfig = ctx?.tsconfig ?? "tsconfig.json";
|
|
@@ -46,9 +52,9 @@ async function getRolldownConfig(ctx) {
|
|
|
46
52
|
transformer: "oxc",
|
|
47
53
|
patchCjsDefaultExport: true
|
|
48
54
|
}));
|
|
49
|
-
|
|
55
|
+
const baseOptions = {
|
|
50
56
|
input: typeof input === "string" ? { index: input } : input,
|
|
51
|
-
tsconfig: resolve(root, tsconfig),
|
|
57
|
+
tsconfig: resolve$1(root, tsconfig),
|
|
52
58
|
external: [
|
|
53
59
|
...builtinModules,
|
|
54
60
|
...builtinModules.map((m) => `node:${m}`),
|
|
@@ -57,7 +63,7 @@ async function getRolldownConfig(ctx) {
|
|
|
57
63
|
],
|
|
58
64
|
transform: { define: { ...ctx?.define } },
|
|
59
65
|
output: {
|
|
60
|
-
dir: resolve(root, output),
|
|
66
|
+
dir: resolve$1(root, output),
|
|
61
67
|
entryFileNames: "[name].mjs",
|
|
62
68
|
format: "esm",
|
|
63
69
|
exports: "auto",
|
|
@@ -69,8 +75,8 @@ async function getRolldownConfig(ctx) {
|
|
|
69
75
|
},
|
|
70
76
|
plugins: [...defaultPlugins, ...customPlugins]
|
|
71
77
|
};
|
|
78
|
+
return defu(ctx?.rolldownConfig ?? {}, baseOptions);
|
|
72
79
|
}
|
|
73
|
-
|
|
74
80
|
//#endregion
|
|
75
81
|
//#region src/Bundlers/Rolldown/Build.ts
|
|
76
82
|
/**
|
|
@@ -87,9 +93,17 @@ async function build$1(ctx) {
|
|
|
87
93
|
const bundlerConfig = await getRolldownConfig(ctx);
|
|
88
94
|
const build = await rolldown({ ...bundlerConfig });
|
|
89
95
|
const outputs = Array.isArray(bundlerConfig.output) ? bundlerConfig.output : [bundlerConfig.output];
|
|
90
|
-
|
|
96
|
+
consola$1.info(`📦 Building \`${ctx.entry || "<no name>"}\``);
|
|
97
|
+
let results = [];
|
|
98
|
+
for (const output of outputs) {
|
|
99
|
+
const { output: result } = await build.write(output);
|
|
100
|
+
results.push(...result);
|
|
101
|
+
}
|
|
102
|
+
for (const result of results.filter((o) => o.type === "chunk")) consola$1.success({
|
|
103
|
+
tag: "build",
|
|
104
|
+
message: colors.gray(`Built ${colors.cyan(join(ctx?.output?.dir ?? "", result?.fileName ?? ""))} - ${(Buffer.byteLength(result?.code ?? "") / 1024).toFixed(2)}kb`)
|
|
105
|
+
});
|
|
91
106
|
}
|
|
92
|
-
|
|
93
107
|
//#endregion
|
|
94
108
|
//#region src/Bundlers/Rolldown/Watch.ts
|
|
95
109
|
/**
|
|
@@ -104,9 +118,9 @@ async function watch$3(app) {
|
|
|
104
118
|
onwarn: () => {}
|
|
105
119
|
});
|
|
106
120
|
const extraWatcher = watch$2([
|
|
107
|
-
resolve(app.config.build?.root ?? process.cwd(), (app.config?.c12?.dotenv)?.fileName?.[0] ?? ".env"),
|
|
108
|
-
resolve(app.config.build?.root ?? process.cwd(), "vercube.config.ts"),
|
|
109
|
-
resolve(app.config.build?.root ?? process.cwd(), app.config.build?.tsconfig ?? "tsconfig.json")
|
|
121
|
+
resolve$1(app.config.build?.root ?? process.cwd(), (app.config?.c12?.dotenv)?.fileName?.[0] ?? ".env"),
|
|
122
|
+
resolve$1(app.config.build?.root ?? process.cwd(), "vercube.config.ts"),
|
|
123
|
+
resolve$1(app.config.build?.root ?? process.cwd(), app.config.build?.tsconfig ?? "tsconfig.json")
|
|
110
124
|
], { ignoreInitial: true });
|
|
111
125
|
extraWatcher.on("all", () => {
|
|
112
126
|
app.hooks.callHook("bundler-watch:restart");
|
|
@@ -131,7 +145,6 @@ async function watch$3(app) {
|
|
|
131
145
|
}
|
|
132
146
|
});
|
|
133
147
|
}
|
|
134
|
-
|
|
135
148
|
//#endregion
|
|
136
149
|
//#region src/Utils/Utils.ts
|
|
137
150
|
/**
|
|
@@ -150,7 +163,6 @@ function getBuildFunc(bundler) {
|
|
|
150
163
|
function getWatchFunc(bundler) {
|
|
151
164
|
return watch$3;
|
|
152
165
|
}
|
|
153
|
-
|
|
154
166
|
//#endregion
|
|
155
167
|
//#region src/Build/Build.ts
|
|
156
168
|
/**
|
|
@@ -161,7 +173,6 @@ function getWatchFunc(bundler) {
|
|
|
161
173
|
async function build(app) {
|
|
162
174
|
await getBuildFunc(app?.config?.build?.bundler ?? "rolldown")(app?.config?.build);
|
|
163
175
|
}
|
|
164
|
-
|
|
165
176
|
//#endregion
|
|
166
177
|
//#region src/Build/Watch.ts
|
|
167
178
|
/**
|
|
@@ -201,7 +212,6 @@ async function watch(app) {
|
|
|
201
212
|
});
|
|
202
213
|
await watcher(app);
|
|
203
214
|
}
|
|
204
|
-
|
|
205
215
|
//#endregion
|
|
206
216
|
//#region src/Server/DevServer.ts
|
|
207
217
|
/**
|
|
@@ -212,7 +222,7 @@ async function watch(app) {
|
|
|
212
222
|
* @see https://github.com/nitrojs/nitro/blob/v2/src/core/dev-server/server.ts
|
|
213
223
|
*/
|
|
214
224
|
function createDevServer(app) {
|
|
215
|
-
const forkEntry = resolve
|
|
225
|
+
const forkEntry = resolve(process.cwd(), app.config.build?.output?.dir ?? "dist", "index.mjs");
|
|
216
226
|
let reloadPromise;
|
|
217
227
|
let currentFork;
|
|
218
228
|
/**
|
|
@@ -253,6 +263,5 @@ function createDevServer(app) {
|
|
|
253
263
|
reload
|
|
254
264
|
};
|
|
255
265
|
}
|
|
256
|
-
|
|
257
266
|
//#endregion
|
|
258
|
-
export { build, createDevServer, createVercube, watch };
|
|
267
|
+
export { build, createDevServer, createVercube, watch };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/devkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"description": "Devkit module for Vercube framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,19 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@oxc-project/runtime": "0.
|
|
26
|
-
"c12": "
|
|
25
|
+
"@oxc-project/runtime": "0.120.0",
|
|
26
|
+
"c12": "4.0.0-beta.4",
|
|
27
27
|
"chokidar": "5.0.0",
|
|
28
28
|
"consola": "3.4.2",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"oxc-
|
|
29
|
+
"defu": "6.1.4",
|
|
30
|
+
"dotenv": "17.3.1",
|
|
31
|
+
"hookable": "6.1.0",
|
|
32
|
+
"oxc-parser": "0.120.0",
|
|
33
|
+
"oxc-transform": "0.120.0",
|
|
33
34
|
"pathe": "2.0.3",
|
|
34
|
-
"rolldown": "1.0.0-rc.
|
|
35
|
+
"rolldown": "1.0.0-rc.9",
|
|
35
36
|
"unplugin-isolated-decl": "0.15.7",
|
|
36
|
-
"@vercube/core": "0.0.
|
|
37
|
+
"@vercube/core": "0.0.45"
|
|
37
38
|
},
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|