@noverax/courier-build 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +295 -2
- package/lib/config/index.d.ts +811 -0
- package/lib/config/index.js +75 -0
- package/lib/config-file-of-Clf_dWUQ.js +28 -0
- package/lib/config-in-page-message-DLd3f0Jd.js +20 -0
- package/lib/courier-routes-options-BYF7Sfdf.d.cts +13 -0
- package/lib/courier-routes-options-BYF7Sfdf.d.ts +13 -0
- package/lib/engine/worker.d.ts +1 -0
- package/lib/engine/worker.js +548 -0
- package/lib/errno-code-CNx_E80R.js +32 -0
- package/lib/esbuild/index.d.ts +58 -0
- package/lib/esbuild/index.js +191 -0
- package/lib/index-_VUU5N5v.d.ts +134 -0
- package/lib/index.d.ts +101 -0
- package/lib/index.js +4 -0
- package/lib/jest/routes-thread.d.ts +1 -0
- package/lib/jest/routes-thread.js +46 -0
- package/lib/jest/transformer.cjs +121 -0
- package/lib/jest/transformer.d.cts +39 -0
- package/lib/load-config-barNPfXN.js +2834 -0
- package/lib/metro/index.cjs +25 -0
- package/lib/metro/index.d.cts +55 -0
- package/lib/metro/index.d.ts +67 -0
- package/lib/metro/index.js +105 -0
- package/lib/package-file-CVAKY_Nu.js +39 -0
- package/lib/read-limits-DUuUaEQM.js +41 -0
- package/lib/rollup/index.d.ts +51 -0
- package/lib/rollup/index.js +95 -0
- package/lib/routes-engine-BfwrCuNL.d.ts +117 -0
- package/lib/routes-file-DRoqUZ0S.js +206 -0
- package/lib/routes-loader-context-40OKDrQp.d.ts +26 -0
- package/lib/routes-module-code-DYtP7uj1.js +405 -0
- package/lib/routes-module-id-CnUjQjYF.js +12 -0
- package/lib/routes-read-error-DQhKIE2F.js +30 -0
- package/lib/routes-rule-Pu1Tz8Xm.js +108 -0
- package/lib/rsbuild/index.d.ts +41 -0
- package/lib/rsbuild/index.js +37 -0
- package/lib/rspack/index.d.ts +3 -0
- package/lib/rspack/index.js +1 -0
- package/lib/shared-engine-D0j7uXg8.js +28 -0
- package/lib/vite/index.d.ts +33 -0
- package/lib/vite/index.js +357 -0
- package/lib/webpack/index.d.ts +4 -0
- package/lib/webpack/index.js +3 -0
- package/lib/webpack/loader.cjs +31 -0
- package/lib/webpack/loader.d.cts +40 -0
- package/lib/webpack/run-routes-loader.d.ts +22 -0
- package/lib/webpack/run-routes-loader.js +103 -0
- package/lib/webpack-BPxhBYGV.js +42 -0
- package/lib/worker-messages-BT2vvNQJ.js +35 -0
- package/package.json +209 -4
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { i as enterDefinitionsPhase, n as COURIER_PHASE, r as DEFINITIONS_PHASE, t as CONFIG_READ_LIMIT_MS } from "../read-limits-DUuUaEQM.js";
|
|
2
|
+
import { n as isRecord } from "../errno-code-CNx_E80R.js";
|
|
3
|
+
import { C as projectFramework, S as detectFramework, T as configCandidates, _ as createConfigJiti, a as projectTransformCache, b as readPathAliases, c as UntrustedConfigError, d as configLoadError, f as loadTimedOut, g as ConfigLoadError, i as loadCourierConfigFile, l as importProjectFile, m as withoutSecrets, n as findConfigFileAt, o as findTransformCacheDirectory, p as maskedError, r as loadCourierConfig, s as createTransformCache, t as findConfigFile, u as settledDefault, v as profileOf, w as CONFIG_BASENAMES, x as FRAMEWORK_MARKERS, y as RefusedModuleError } from "../load-config-barNPfXN.js";
|
|
4
|
+
// src/config/unknown-config-keys.ts
|
|
5
|
+
const TOP_LEVEL = {
|
|
6
|
+
sources: true,
|
|
7
|
+
imports: true,
|
|
8
|
+
studio: true,
|
|
9
|
+
server: true,
|
|
10
|
+
runtime: true,
|
|
11
|
+
agents: true
|
|
12
|
+
};
|
|
13
|
+
const BLOCKS = /* @__PURE__ */ new Map([
|
|
14
|
+
["studio", {
|
|
15
|
+
port: true,
|
|
16
|
+
host: true,
|
|
17
|
+
mockBasePort: true,
|
|
18
|
+
open: true,
|
|
19
|
+
allowedSpecHosts: true,
|
|
20
|
+
routes: true
|
|
21
|
+
}],
|
|
22
|
+
["server", {
|
|
23
|
+
port: true,
|
|
24
|
+
host: true,
|
|
25
|
+
allowedOrigins: true,
|
|
26
|
+
allowedHosts: true,
|
|
27
|
+
maxBodyBytes: true,
|
|
28
|
+
maxUploadBytes: true,
|
|
29
|
+
uploadMode: true,
|
|
30
|
+
uploadMemoryBytes: true,
|
|
31
|
+
totalUploadMemoryBytes: true,
|
|
32
|
+
totalUploadDiskBytes: true,
|
|
33
|
+
uploadDirectory: true,
|
|
34
|
+
maxUploadParts: true,
|
|
35
|
+
bodyIdleTimeoutMs: true,
|
|
36
|
+
bodyTimeoutMs: true,
|
|
37
|
+
rateLimit: true,
|
|
38
|
+
browsersOnly: true
|
|
39
|
+
}],
|
|
40
|
+
["runtime", { appOrigin: true }],
|
|
41
|
+
["agents", {
|
|
42
|
+
offer: true,
|
|
43
|
+
allow: true,
|
|
44
|
+
deny: true,
|
|
45
|
+
access: true,
|
|
46
|
+
confirm: true
|
|
47
|
+
}]
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* The keys of a courier.config that Courier does not read, at the top and
|
|
51
|
+
* in its `studio`, `server`, `runtime` and `agents` blocks — a misspelt `studo:` say
|
|
52
|
+
* — so a load can name them rather than ignore them in silence.
|
|
53
|
+
*
|
|
54
|
+
* @param config - The config, as its module exported it
|
|
55
|
+
* @returns Each such key, dotted under its block
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* unknownConfigKeys({ sources: {}, studo: {}, server: { prot: 3001 } }); // → ["studo", "server.prot"]
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
function unknownConfigKeys(config) {
|
|
62
|
+
if (!isRecord(config)) return [];
|
|
63
|
+
const unknown = [];
|
|
64
|
+
for (const [key, value] of Object.entries(config)) {
|
|
65
|
+
if (!Object.hasOwn(TOP_LEVEL, key)) {
|
|
66
|
+
unknown.push(key);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const known = BLOCKS.get(key);
|
|
70
|
+
if (!known || !isRecord(value)) continue;
|
|
71
|
+
for (const inner of Object.keys(value)) if (!Object.hasOwn(known, inner)) unknown.push(`${key}.${inner}`);
|
|
72
|
+
}
|
|
73
|
+
return unknown;
|
|
74
|
+
}
|
|
75
|
+
export { CONFIG_BASENAMES, CONFIG_READ_LIMIT_MS, COURIER_PHASE, ConfigLoadError, DEFINITIONS_PHASE, FRAMEWORK_MARKERS, RefusedModuleError, UntrustedConfigError, configCandidates, configLoadError, createConfigJiti, createTransformCache, detectFramework, enterDefinitionsPhase, findConfigFile, findConfigFileAt, findTransformCacheDirectory, importProjectFile, loadCourierConfig, loadCourierConfigFile, loadTimedOut, maskedError, profileOf, projectFramework, projectTransformCache, readPathAliases, settledDefault, unknownConfigKeys, withoutSecrets };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { t as errnoCode } from "./errno-code-CNx_E80R.js";
|
|
2
|
+
import { c as UntrustedConfigError, t as findConfigFile } from "./load-config-barNPfXN.js";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
|
+
// src/util/config-file-of.ts
|
|
6
|
+
/**
|
|
7
|
+
* The config file the routes are read from, as a bundler names a module:
|
|
8
|
+
* its real path. One that is not there yet, or that is not run, gives none
|
|
9
|
+
* here; the engine reports why when the routes are read.
|
|
10
|
+
*
|
|
11
|
+
* @param root - The project's root, where the config is looked for and above
|
|
12
|
+
* @param named - The config, from the root or absolute, when it is not the one found
|
|
13
|
+
* @returns The config file, absolute and real; none when there is no config to read
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* configFileOf("/app"); // "/app/courier.config.ts"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function configFileOf(root, named) {
|
|
20
|
+
try {
|
|
21
|
+
const file = named === void 0 ? findConfigFile(root) : resolve(root, named);
|
|
22
|
+
return file === null ? void 0 : realpathSync(file);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof UntrustedConfigError || errnoCode(error) === "ENOENT") return void 0;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export { configFileOf as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
// src/util/config-in-page-message.ts
|
|
3
|
+
/**
|
|
4
|
+
* Why the project's config cannot be a module of a page, and what to write
|
|
5
|
+
* instead. It holds the server's settings and the definition of every API —
|
|
6
|
+
* their addresses, their middleware, what reads their secrets — and imported
|
|
7
|
+
* as a value it ships all of them to the browser. A page needs its type
|
|
8
|
+
* alone, which an `import type` gives without a byte of it.
|
|
9
|
+
*
|
|
10
|
+
* @param configFile - The project's config
|
|
11
|
+
* @returns The message a build fails with
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* configInPageMessage("/app/courier.config.ts"); // "[courier] courier.config.ts is imported into a page as a value, …"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function configInPageMessage(configFile) {
|
|
18
|
+
return `[courier] ${basename(configFile)} is imported into a page as a value, which would ship the server's settings and every API's definition to the browser. Import its type alone: write \`import type config from\` where the page writes \`import config from\`.`;
|
|
19
|
+
}
|
|
20
|
+
export { configInPageMessage as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options of the routes plugins that need to know only where the config is:
|
|
3
|
+
* those of webpack, Rspack, Rsbuild, esbuild, Rollup and Jest, and of the
|
|
4
|
+
* frameworks built on them.
|
|
5
|
+
*/
|
|
6
|
+
interface CourierRoutesOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The config file, from the project's root or absolute, when it is not
|
|
9
|
+
* the `courier.config.*` in the root or the nearest folder above it.
|
|
10
|
+
*/
|
|
11
|
+
config?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export { CourierRoutesOptions as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options of the routes plugins that need to know only where the config is:
|
|
3
|
+
* those of webpack, Rspack, Rsbuild, esbuild, Rollup and Jest, and of the
|
|
4
|
+
* frameworks built on them.
|
|
5
|
+
*/
|
|
6
|
+
interface CourierRoutesOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The config file, from the project's root or absolute, when it is not
|
|
9
|
+
* the `courier.config.*` in the root or the nearest folder above it.
|
|
10
|
+
*/
|
|
11
|
+
config?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export { CourierRoutesOptions as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|