@noverax/courier-build 0.4.0 → 0.5.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/README.md +10 -4
- package/lib/config/index.d.ts +413 -22
- package/lib/config/index.js +11 -2
- package/lib/{config-file-of-Zkwyi9zf.js → config-file-of-Clf_dWUQ.js} +1 -1
- package/lib/engine/worker.js +47 -50
- package/lib/esbuild/index.js +5 -5
- package/lib/index.js +1 -1
- package/lib/jest/routes-thread.js +2 -2
- package/lib/load-config-barNPfXN.js +2834 -0
- package/lib/metro/index.js +1 -1
- package/lib/read-limits-DUuUaEQM.js +41 -0
- package/lib/rollup/index.js +3 -3
- package/lib/{routes-file-DcpgxYb1.js → routes-file-DRoqUZ0S.js} +3 -3
- package/lib/{routes-module-code-DO3aII6v.js → routes-module-code-DYtP7uj1.js} +6 -3
- package/lib/{routes-rule-CjzX6NS5.js → routes-rule-Pu1Tz8Xm.js} +1 -1
- package/lib/rsbuild/index.js +1 -1
- package/lib/rspack/index.js +1 -1
- package/lib/{shared-engine-CCu7vP_0.js → shared-engine-D0j7uXg8.js} +1 -1
- package/lib/vite/index.js +19 -8
- package/lib/webpack/index.js +2 -2
- package/lib/webpack/run-routes-loader.js +2 -2
- package/lib/{webpack-B0v9i8lk.js → webpack-BPxhBYGV.js} +1 -1
- package/package.json +2 -2
- package/lib/load-config-BeedbpkN.js +0 -1419
package/lib/metro/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../routes-module-id-CnUjQjYF.js";
|
|
2
|
-
import { t as routesFile } from "../routes-file-
|
|
2
|
+
import { t as routesFile } from "../routes-file-DRoqUZ0S.js";
|
|
3
3
|
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import { realpathSync } from "node:fs";
|
|
5
5
|
// src/metro/routes-resolver.ts
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/config/definitions-phase.ts
|
|
2
|
+
/**
|
|
3
|
+
* The signal a project's code reads to tell that Courier is reading its
|
|
4
|
+
* definitions rather than serving requests: `COURIER_PHASE` holds
|
|
5
|
+
* `definitions` in every process Courier starts to read them — the
|
|
6
|
+
* `courier-cli routes` command, `courier-mcp --list`, Studio, the process a
|
|
7
|
+
* bundler plugin reads the routes in — after the fashion of `NEXT_PHASE`.
|
|
8
|
+
* Code that checks the environment as it is imported can skip the check
|
|
9
|
+
* then, as `@t3-oss/env-core` does with `skipValidation`; Courier guesses
|
|
10
|
+
* nothing for it. Where the application runs — `courier-server`,
|
|
11
|
+
* `courier-mcp` serving an agent, `attachRuntime()`, the app itself — the
|
|
12
|
+
* variable is not set.
|
|
13
|
+
*/
|
|
14
|
+
/** The variable a project's code reads the phase from. */
|
|
15
|
+
const COURIER_PHASE = "COURIER_PHASE";
|
|
16
|
+
/** Its value while Courier reads the project's definitions. */
|
|
17
|
+
const DEFINITIONS_PHASE = "definitions";
|
|
18
|
+
/**
|
|
19
|
+
* Mark the process as one that reads the project's definitions, before the
|
|
20
|
+
* project's code runs in it.
|
|
21
|
+
*
|
|
22
|
+
* @param env - The environment to mark (default: the process's)
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* enterDefinitionsPhase();
|
|
26
|
+
* process.env.COURIER_PHASE; // "definitions"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function enterDefinitionsPhase(env = process.env) {
|
|
30
|
+
env[COURIER_PHASE] = DEFINITIONS_PHASE;
|
|
31
|
+
}
|
|
32
|
+
// src/config/read-limits.ts
|
|
33
|
+
/**
|
|
34
|
+
* How long one reading of a project's config may take before it is given
|
|
35
|
+
* up, in milliseconds: a config that waits on the network, or on a timer,
|
|
36
|
+
* never ends. The routes plugin's process and `courier-cli routes` hold to
|
|
37
|
+
* it; Studio, which keeps running what it loaded last, has its own,
|
|
38
|
+
* `COURIER_CONFIG_LOAD_TIMEOUT_MS`.
|
|
39
|
+
*/
|
|
40
|
+
const CONFIG_READ_LIMIT_MS = 6e4;
|
|
41
|
+
export { enterDefinitionsPhase as i, COURIER_PHASE as n, DEFINITIONS_PHASE as r, CONFIG_READ_LIMIT_MS as t };
|
package/lib/rollup/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "../routes-read-error-DQhKIE2F.js";
|
|
2
|
-
import { n as routesModuleCode } from "../routes-module-code-
|
|
2
|
+
import { n as routesModuleCode } from "../routes-module-code-DYtP7uj1.js";
|
|
3
3
|
import { t as configInPageMessage } from "../config-in-page-message-DLd3f0Jd.js";
|
|
4
|
-
import { t as sharedEngine } from "../shared-engine-
|
|
5
|
-
import { t as configFileOf } from "../config-file-of-
|
|
4
|
+
import { t as sharedEngine } from "../shared-engine-D0j7uXg8.js";
|
|
5
|
+
import { t as configFileOf } from "../config-file-of-Clf_dWUQ.js";
|
|
6
6
|
import { t as ROUTES_MODULE_ID } from "../routes-module-id-CnUjQjYF.js";
|
|
7
7
|
// src/rollup/load-routes-module.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "./routes-read-error-DQhKIE2F.js";
|
|
2
|
-
import { n as routesModuleCode, r as unreadRoutesModuleCode } from "./routes-module-code-
|
|
2
|
+
import { n as routesModuleCode, r as unreadRoutesModuleCode } from "./routes-module-code-DYtP7uj1.js";
|
|
3
3
|
import { t as errnoCode } from "./errno-code-CNx_E80R.js";
|
|
4
|
-
import { t as sharedEngine } from "./shared-engine-
|
|
5
|
-
import { t as configFileOf } from "./config-file-of-
|
|
4
|
+
import { t as sharedEngine } from "./shared-engine-D0j7uXg8.js";
|
|
5
|
+
import { t as configFileOf } from "./config-file-of-Clf_dWUQ.js";
|
|
6
6
|
import { dirname, join, sep } from "node:path";
|
|
7
7
|
import { mkdirSync, readFileSync, renameSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
8
8
|
// src/routes-file/follow-routes-inputs.ts
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as COURIER_PHASE, r as DEFINITIONS_PHASE, t as CONFIG_READ_LIMIT_MS } from "./read-limits-DUuUaEQM.js";
|
|
1
2
|
import { t as packageFile } from "./package-file-CVAKY_Nu.js";
|
|
2
3
|
import { t as RoutesReadError } from "./routes-read-error-DQhKIE2F.js";
|
|
3
4
|
import { n as isRecord, t as errnoCode } from "./errno-code-CNx_E80R.js";
|
|
@@ -51,8 +52,6 @@ function isRunning(child) {
|
|
|
51
52
|
return child.exitCode === null && child.signalCode === null;
|
|
52
53
|
}
|
|
53
54
|
// src/engine/evaluate-in-child.ts
|
|
54
|
-
/** How long a reading may take before it is given up: a config that waits on the network never ends. */
|
|
55
|
-
const READ_LIMIT_MS = 6e4;
|
|
56
55
|
/** The package this module ships in, by the name its manifest gives. */
|
|
57
56
|
const PACKAGE_NAME = "@noverax/courier-build";
|
|
58
57
|
/**
|
|
@@ -70,7 +69,7 @@ const PACKAGE_NAME = "@noverax/courier-build";
|
|
|
70
69
|
* const snapshot = await evaluateInChild({ root: "/app", envFiles: [] });
|
|
71
70
|
* ```
|
|
72
71
|
*/
|
|
73
|
-
function evaluateInChild(request, limitMs =
|
|
72
|
+
function evaluateInChild(request, limitMs = CONFIG_READ_LIMIT_MS) {
|
|
74
73
|
return new Promise((resolve, reject) => {
|
|
75
74
|
const unread = (message) => new RoutesReadError("ROUTES_NOT_READ", message, {
|
|
76
75
|
root: request.root,
|
|
@@ -83,6 +82,10 @@ function evaluateInChild(request, limitMs = READ_LIMIT_MS) {
|
|
|
83
82
|
}
|
|
84
83
|
const child = fork(worker, [], {
|
|
85
84
|
execArgv: [],
|
|
85
|
+
env: {
|
|
86
|
+
...process.env,
|
|
87
|
+
[COURIER_PHASE]: DEFINITIONS_PHASE
|
|
88
|
+
},
|
|
86
89
|
stdio: [
|
|
87
90
|
"ignore",
|
|
88
91
|
"inherit",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as packageFile } from "./package-file-CVAKY_Nu.js";
|
|
2
2
|
import { t as RoutesReadError } from "./routes-read-error-DQhKIE2F.js";
|
|
3
|
-
import { t as configFileOf } from "./config-file-of-
|
|
3
|
+
import { t as configFileOf } from "./config-file-of-Clf_dWUQ.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { realpathSync } from "node:fs";
|
package/lib/rsbuild/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as routesProject, r as configInPageRule, t as routesRule } from "../routes-rule-
|
|
1
|
+
import { n as routesProject, r as configInPageRule, t as routesRule } from "../routes-rule-Pu1Tz8Xm.js";
|
|
2
2
|
// src/rsbuild/courier-routes.ts
|
|
3
3
|
/**
|
|
4
4
|
* The Rsbuild plugin that builds the routes a page's proxy client may call
|
package/lib/rspack/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as CourierRoutesPlugin } from "../webpack-
|
|
1
|
+
export { t as CourierRoutesPlugin } from "../webpack-BPxhBYGV.js";
|
package/lib/vite/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "../routes-read-error-DQhKIE2F.js";
|
|
2
|
-
import { n as routesModuleCode, r as unreadRoutesModuleCode } from "../routes-module-code-
|
|
2
|
+
import { n as routesModuleCode, r as unreadRoutesModuleCode } from "../routes-module-code-DYtP7uj1.js";
|
|
3
3
|
import { n as isRecord } from "../errno-code-CNx_E80R.js";
|
|
4
4
|
import { t as configInPageMessage } from "../config-in-page-message-DLd3f0Jd.js";
|
|
5
|
-
import {
|
|
6
|
-
import { t as sharedEngine } from "../shared-engine-
|
|
7
|
-
import { t as configFileOf } from "../config-file-of-
|
|
5
|
+
import { T as configCandidates, h as localPath } from "../load-config-barNPfXN.js";
|
|
6
|
+
import { t as sharedEngine } from "../shared-engine-D0j7uXg8.js";
|
|
7
|
+
import { t as configFileOf } from "../config-file-of-Clf_dWUQ.js";
|
|
8
8
|
import { n as ROUTES_PATTERN, r as ROUTES_SPECIFIER, t as ROUTES_MODULE_ID } from "../routes-module-id-CnUjQjYF.js";
|
|
9
|
-
import { dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
9
|
+
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
10
10
|
import { existsSync, statSync } from "node:fs";
|
|
11
11
|
import { loadEnv } from "vite";
|
|
12
12
|
// src/vite/config-in-page.ts
|
|
@@ -41,9 +41,14 @@ function withSlashes(path) {
|
|
|
41
41
|
// src/vite/watch-once.ts
|
|
42
42
|
const given = /* @__PURE__ */ new WeakMap();
|
|
43
43
|
/**
|
|
44
|
-
* Hand a dev server's watcher
|
|
44
|
+
* Hand a dev server's watcher each path it does not follow yet. The routes
|
|
45
45
|
* module is loaded again on every edit, and follows the same paths each
|
|
46
|
-
* time: each is given to each server once.
|
|
46
|
+
* time: each is given to each server once. A path the watcher follows
|
|
47
|
+
* already, as it follows Vite's root, is not given at all: chokidar reads a
|
|
48
|
+
* folder it is handed as one just added, and an entry made since the routes
|
|
49
|
+
* were read would pass for one that was there, with no notice of it. A
|
|
50
|
+
* watcher that stops at a depth lists the folders below it unread: it is
|
|
51
|
+
* handed every path.
|
|
47
52
|
*
|
|
48
53
|
* @param server - The dev server
|
|
49
54
|
* @param paths - The paths to watch, there or not
|
|
@@ -60,7 +65,13 @@ function watchOnce(server, paths) {
|
|
|
60
65
|
}
|
|
61
66
|
const fresh = [...paths].filter((path) => !seen.has(path));
|
|
62
67
|
for (const path of fresh) seen.add(path);
|
|
63
|
-
if (fresh.length
|
|
68
|
+
if (fresh.length === 0) return;
|
|
69
|
+
const watched = server.watcher.options.depth === void 0 ? server.watcher.getWatched() : {};
|
|
70
|
+
const unfollowed = fresh.filter((path) => {
|
|
71
|
+
const local = localPath(path);
|
|
72
|
+
return !watched[dirname(local)]?.includes(basename(local));
|
|
73
|
+
});
|
|
74
|
+
if (unfollowed.length > 0) server.watcher.add(unfollowed);
|
|
64
75
|
}
|
|
65
76
|
// src/vite/follow-routes-inputs.ts
|
|
66
77
|
/**
|
package/lib/webpack/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as routesLoaderFile, n as routesProject, r as configInPageRule, t as routesRule } from "../routes-rule-
|
|
2
|
-
import { t as CourierRoutesPlugin } from "../webpack-
|
|
1
|
+
import { i as routesLoaderFile, n as routesProject, r as configInPageRule, t as routesRule } from "../routes-rule-Pu1Tz8Xm.js";
|
|
2
|
+
import { t as CourierRoutesPlugin } from "../webpack-BPxhBYGV.js";
|
|
3
3
|
export { CourierRoutesPlugin, configInPageRule, routesLoaderFile, routesProject, routesRule };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "../routes-read-error-DQhKIE2F.js";
|
|
2
|
-
import { n as routesModuleCode } from "../routes-module-code-
|
|
2
|
+
import { n as routesModuleCode } from "../routes-module-code-DYtP7uj1.js";
|
|
3
3
|
import { n as isRecord } from "../errno-code-CNx_E80R.js";
|
|
4
4
|
import { t as configInPageMessage } from "../config-in-page-message-DLd3f0Jd.js";
|
|
5
|
-
import { t as sharedEngine } from "../shared-engine-
|
|
5
|
+
import { t as sharedEngine } from "../shared-engine-D0j7uXg8.js";
|
|
6
6
|
import { statSync } from "node:fs";
|
|
7
7
|
// src/webpack/follow-loader-inputs.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as routesProject, r as configInPageRule, t as routesRule } from "./routes-rule-
|
|
1
|
+
import { n as routesProject, r as configInPageRule, t as routesRule } from "./routes-rule-Pu1Tz8Xm.js";
|
|
2
2
|
// src/webpack/courier-routes-plugin.ts
|
|
3
3
|
const SERVER_TARGET = /^(async-)?node|^electron-(main|preload)|^nwjs/;
|
|
4
4
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noverax/courier-build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Courier at build time: loads courier.config the way every Courier tool does, and hands a page's bundle the routes its proxy client may call through a plugin for the app's bundler, with no routes file to generate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"courier",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"jiti": "^2.7.0"
|
|
155
155
|
},
|
|
156
156
|
"peerDependencies": {
|
|
157
|
-
"@noverax/courier": "^0.
|
|
157
|
+
"@noverax/courier": "^0.5.0",
|
|
158
158
|
"@rsbuild/core": ">=1.0.0",
|
|
159
159
|
"@rspack/core": ">=1.0.0",
|
|
160
160
|
"esbuild": ">=0.17.0",
|