@vercube/vite 1.2.1 → 1.3.1
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
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { i as setupContext, n as createContext, t as CLIENT_OUT_DIR } from "./context-
|
|
1
|
+
import { i as setupContext, n as createContext, t as CLIENT_OUT_DIR } from "./context-D4q0XCl9.mjs";
|
|
2
2
|
import { t as VERCUBE_ENV } from "./types-Cpd32Lkt.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { defu } from "defu";
|
|
5
5
|
import { dirname, isAbsolute, resolve } from "pathe";
|
|
6
6
|
import { RunnerManager, loadRunner } from "env-runner";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
//#region src/meta.ts
|
|
9
|
+
/**
|
|
10
|
+
* Absolute path to the directory holding the shipped runtime entries
|
|
11
|
+
* (`dev-worker.mjs`). Resolved relative to the built plugin module, so it
|
|
12
|
+
* points at `dist/runtime` at runtime.
|
|
13
|
+
*/
|
|
14
|
+
const runtimeDir = resolve(dirname(fileURLToPath(import.meta.url)), "runtime");
|
|
8
15
|
/**
|
|
9
16
|
* Absolute path to the worker bootstrap loaded by env-runner.
|
|
10
17
|
*/
|
|
11
|
-
const devWorker = resolve(
|
|
18
|
+
const devWorker = resolve(runtimeDir, "dev-worker.mjs");
|
|
12
19
|
/**
|
|
13
20
|
* Default `resolve.noExternal` / production bundle patterns. `@vercube/*` must stay in
|
|
14
21
|
* a single module graph so class-reference DI tokens (e.g. `RequestContext`) are not
|
|
@@ -22,7 +29,8 @@ const DEFAULT_NO_EXTERNAL = [/^@vercube\//, ...[
|
|
|
22
29
|
"pathe",
|
|
23
30
|
"evlog",
|
|
24
31
|
/^evlog\//,
|
|
25
|
-
"@standard-schema/spec"
|
|
32
|
+
"@standard-schema/spec",
|
|
33
|
+
/^@opentelemetry\//
|
|
26
34
|
]];
|
|
27
35
|
/** Vercube packages that must resolve to a single module id (class-reference DI tokens). */
|
|
28
36
|
const VERCUBE_PACKAGES = [
|
|
@@ -30,7 +38,8 @@ const VERCUBE_PACKAGES = [
|
|
|
30
38
|
"@vercube/di",
|
|
31
39
|
"@vercube/auth",
|
|
32
40
|
"@vercube/logger",
|
|
33
|
-
"@vercube/schema"
|
|
41
|
+
"@vercube/schema",
|
|
42
|
+
"@vercube/telemetry"
|
|
34
43
|
];
|
|
35
44
|
/**
|
|
36
45
|
* Canonical entry paths for `@vercube/*` packages from the consuming app's root.
|
|
@@ -46,6 +55,41 @@ function createVercubeResolveAliases(root) {
|
|
|
46
55
|
return aliases;
|
|
47
56
|
}
|
|
48
57
|
/**
|
|
58
|
+
* The same canonical entries in the form `resolve.alias` needs.
|
|
59
|
+
*
|
|
60
|
+
* A string `find` in Vite's alias config is a **prefix** match: it matches the
|
|
61
|
+
* bare specifier and anything under it, and the replacement is a plain
|
|
62
|
+
* `String.replace`. Mapping `'@vercube/telemetry'` to `.../dist/index.mjs`
|
|
63
|
+
* would therefore rewrite `@vercube/telemetry/instrument` into
|
|
64
|
+
* `.../dist/index.mjs/instrument`, which resolves to nothing. Every subpath
|
|
65
|
+
* export in the workspace is affected: `@vercube/telemetry/instrument` is what
|
|
66
|
+
* six instrumented packages import, and `@vercube/logger/toolkit` is what core
|
|
67
|
+
* imports.
|
|
68
|
+
*
|
|
69
|
+
* An anchored `RegExp` matches the package root and nothing below it, so a
|
|
70
|
+
* subpath falls through to normal resolution. `$` in the *replacement* is
|
|
71
|
+
* escaped separately, because `String.replace` reads `$&` and friends as
|
|
72
|
+
* capture references there.
|
|
73
|
+
*
|
|
74
|
+
* @param root - The consuming app's root
|
|
75
|
+
* @returns Alias entries safe to hand to `resolve.alias`
|
|
76
|
+
*/
|
|
77
|
+
function createVercubeAliasEntries(root) {
|
|
78
|
+
return Object.entries(createVercubeResolveAliases(root)).map(([name, entry]) => ({
|
|
79
|
+
find: new RegExp(`^${escapeRegExp(name)}$`),
|
|
80
|
+
replacement: entry.replaceAll("$", "$$$$")
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Escapes the characters that would otherwise be read as pattern syntax.
|
|
85
|
+
*
|
|
86
|
+
* @param value - The literal to match
|
|
87
|
+
* @returns The escaped literal
|
|
88
|
+
*/
|
|
89
|
+
function escapeRegExp(value) {
|
|
90
|
+
return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
49
93
|
* Merges built-in {@link DEFAULT_NO_EXTERNAL} with optional plugin patterns.
|
|
50
94
|
*
|
|
51
95
|
* @param extra - Additional patterns from {@link VercubePluginConfig.noExternal}.
|
|
@@ -89,7 +133,7 @@ function createVercubeEnvironment(ctx) {
|
|
|
89
133
|
}
|
|
90
134
|
},
|
|
91
135
|
dev: { createEnvironment: async (envName, envConfig) => {
|
|
92
|
-
const { createFetchableDevEnvironment } = await import("./dev-
|
|
136
|
+
const { createFetchableDevEnvironment } = await import("./dev-D4kFrI6U.mjs");
|
|
93
137
|
const env = createFetchableDevEnvironment(envName, envConfig, getEnvRunner(ctx), ctx.serverEntry);
|
|
94
138
|
(ctx._viteEnvs ??= /* @__PURE__ */ new Map()).set(envName, ctx.serverEntry);
|
|
95
139
|
return env;
|
|
@@ -160,7 +204,8 @@ function isBareSpecifier(id) {
|
|
|
160
204
|
* Loads (or reloads) the configured runner into the manager.
|
|
161
205
|
*/
|
|
162
206
|
async function loadRunnerInto(ctx, manager) {
|
|
163
|
-
const
|
|
207
|
+
const runnerName = ctx.pluginConfig.runner || process.env.VERCUBE_DEV_RUNNER || "node-worker";
|
|
208
|
+
const runner = await loadRunner(runnerName, {
|
|
164
209
|
name: VERCUBE_ENV,
|
|
165
210
|
data: { entry: devWorker }
|
|
166
211
|
});
|
|
@@ -205,7 +250,7 @@ function vercubeMain(ctx) {
|
|
|
205
250
|
}
|
|
206
251
|
return {
|
|
207
252
|
builder: { sharedConfigBuild: true },
|
|
208
|
-
resolve: { alias:
|
|
253
|
+
resolve: { alias: createVercubeAliasEntries(ctx.root) },
|
|
209
254
|
environments: {
|
|
210
255
|
client: { build: { outDir: resolve(ctx.root, CLIENT_OUT_DIR) } },
|
|
211
256
|
[VERCUBE_ENV]: createVercubeEnvironment(ctx)
|
|
@@ -220,7 +265,7 @@ function vercubeMain(ctx) {
|
|
|
220
265
|
}
|
|
221
266
|
},
|
|
222
267
|
configureServer: async (server) => {
|
|
223
|
-
const { configureViteDevServer } = await import("./dev-
|
|
268
|
+
const { configureViteDevServer } = await import("./dev-D4kFrI6U.mjs");
|
|
224
269
|
await configureViteDevServer(ctx, server);
|
|
225
270
|
},
|
|
226
271
|
hotUpdate() {
|
|
@@ -7,19 +7,18 @@ interface IpcContext {
|
|
|
7
7
|
* env-runner AppEntry: routes an incoming request to the named environment
|
|
8
8
|
* (defaulting to the Vercube server environment).
|
|
9
9
|
*/
|
|
10
|
-
declare function fetch(req: Request): Promise<Response>;
|
|
10
|
+
export declare function fetch(req: Request): Promise<Response>;
|
|
11
11
|
/**
|
|
12
12
|
* env-runner AppEntry: forwards a WebSocket upgrade to the Vercube environment.
|
|
13
13
|
*/
|
|
14
|
-
declare function upgrade(context: UpgradeContext): void;
|
|
14
|
+
export declare function upgrade(context: UpgradeContext): void;
|
|
15
15
|
/**
|
|
16
16
|
* env-runner IPC hooks: opens the message channel, registers environments, and
|
|
17
17
|
* relays module-runner transport messages.
|
|
18
18
|
*/
|
|
19
|
-
declare const ipc: {
|
|
19
|
+
export declare const ipc: {
|
|
20
20
|
onOpen(ctx: IpcContext): void;
|
|
21
21
|
onMessage(message: any): void;
|
|
22
22
|
onClose(): void;
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { fetch, ipc, upgrade };
|
|
24
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Vite plugin integrating Vercube with the Vite Environment API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,18 +30,19 @@
|
|
|
30
30
|
"framework"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@vercube/scan": "1.3.1",
|
|
33
34
|
"chokidar": "5.0.0",
|
|
34
35
|
"defu": "6.1.7",
|
|
35
|
-
"env-runner": "0.
|
|
36
|
+
"env-runner": "0.3.3",
|
|
36
37
|
"pathe": "2.0.3",
|
|
37
|
-
"rou3": "0.
|
|
38
|
-
"srvx": "0.
|
|
39
|
-
"@vercube/scan": "1.2.1"
|
|
38
|
+
"rou3": "1.0.0",
|
|
39
|
+
"srvx": "1.0.5"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vite": "^8.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@vercube/core": "1.3.1",
|
|
45
46
|
"vite": "^8.2.1"
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|