@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/engine/worker.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "../routes-read-error-DQhKIE2F.js";
|
|
2
2
|
import { n as isRecord } from "../errno-code-CNx_E80R.js";
|
|
3
3
|
import { t as workerMessages } from "../worker-messages-BT2vvNQJ.js";
|
|
4
|
-
import { a as projectTransformCache, c as UntrustedConfigError,
|
|
4
|
+
import { T as configCandidates, a as projectTransformCache, c as UntrustedConfigError, d as configLoadError, h as localPath, i as loadCourierConfigFile, p as maskedError, t as findConfigFile } from "../load-config-barNPfXN.js";
|
|
5
5
|
import * as nodeModule from "node:module";
|
|
6
6
|
import { createRequire, syncBuiltinESMExports } from "node:module";
|
|
7
|
-
import { basename, dirname, isAbsolute,
|
|
7
|
+
import { basename, dirname, isAbsolute, sep } from "node:path";
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
10
|
import { parseEnv } from "node:util";
|
|
@@ -98,10 +98,12 @@ async function loadProjectConfig(configFile, request, options) {
|
|
|
98
98
|
transformCache
|
|
99
99
|
});
|
|
100
100
|
} catch (error) {
|
|
101
|
-
|
|
101
|
+
const failure = configLoadError(error, { entry: configFile });
|
|
102
|
+
const message = `${basename(configFile)} did not load, so the routes a page takes were not read: ${failure.message} ${failure.hint}`;
|
|
103
|
+
throw new RoutesReadError("CONFIG_NOT_LOADED", message, {
|
|
102
104
|
root: request.root,
|
|
103
105
|
configFile
|
|
104
|
-
}, { stack:
|
|
106
|
+
}, { stack: failure.cause instanceof Error ? failure.cause.stack : void 0 });
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
// src/engine/read-env-files.ts
|
|
@@ -132,27 +134,39 @@ function parsedFrom(files) {
|
|
|
132
134
|
for (const file of files) for (const [key, value] of Object.entries(parseEnv(readFileSync(file, "utf8")))) if (value !== void 0 && !(key in parsed)) parsed[key] = value;
|
|
133
135
|
return parsed;
|
|
134
136
|
}
|
|
135
|
-
// src/
|
|
136
|
-
const NAMESPACE = "\\\\?\\";
|
|
137
|
-
const SHARE_NAMESPACE = "\\\\?\\UNC\\";
|
|
137
|
+
// src/engine/reading-failure.ts
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
139
|
+
* Why a reading of the routes failed, as a `RoutesReadError` whatever it
|
|
140
|
+
* threw. The engine's own failure is kept as it is, its text the engine's
|
|
141
|
+
* words and what the loader quoted of the project, masked already. Anything
|
|
142
|
+
* else came from the project's code, a getter of its config or a source the
|
|
143
|
+
* core read, and is `CONFIG_NOT_LOADED`, its text and stack with no secret
|
|
144
|
+
* left in them: a bundler prints them, shows them on the page, and a CI
|
|
145
|
+
* log, which may be public, keeps them.
|
|
144
146
|
*
|
|
145
|
-
* @param
|
|
146
|
-
* @
|
|
147
|
+
* @param thrown - What the reading threw
|
|
148
|
+
* @param context - The project's root, and the config file once found
|
|
149
|
+
* @param inputs - What the reading had read, for a failure that names none yet
|
|
150
|
+
* @returns The failure
|
|
147
151
|
* @example
|
|
148
152
|
* ```ts
|
|
149
|
-
*
|
|
153
|
+
* readingFailure(new Error(`bad ${process.env.API_KEY}`), { root: "/app" }).message;
|
|
154
|
+
* // → "The routes a page takes were not read: bad [redacted]"
|
|
150
155
|
* ```
|
|
151
156
|
*/
|
|
152
|
-
function
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
function readingFailure(thrown, context, inputs) {
|
|
158
|
+
if (thrown instanceof RoutesReadError) {
|
|
159
|
+
if (thrown.inputs !== void 0 || inputs === void 0) return thrown;
|
|
160
|
+
return new RoutesReadError(thrown.code, thrown.message, thrown.context, {
|
|
161
|
+
stack: thrown.stack,
|
|
162
|
+
inputs
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const masked = maskedError(thrown);
|
|
166
|
+
return new RoutesReadError("CONFIG_NOT_LOADED", `The routes a page takes were not read: ${masked.message}`, context, {
|
|
167
|
+
stack: thrown instanceof Error ? masked.stack : void 0,
|
|
168
|
+
inputs
|
|
169
|
+
});
|
|
156
170
|
}
|
|
157
171
|
// src/engine/track-env-reads.ts
|
|
158
172
|
/**
|
|
@@ -468,7 +482,11 @@ async function readProjectRoutes(request) {
|
|
|
468
482
|
routes
|
|
469
483
|
};
|
|
470
484
|
} catch (error) {
|
|
471
|
-
|
|
485
|
+
const inputs = await reading.inputs();
|
|
486
|
+
throw readingFailure(error, {
|
|
487
|
+
root: request.root,
|
|
488
|
+
configFile: inputs.configFile
|
|
489
|
+
}, inputs);
|
|
472
490
|
}
|
|
473
491
|
}
|
|
474
492
|
async function routesOfSources(loaded, root) {
|
|
@@ -495,21 +513,6 @@ async function projectRoutesOf(configFile, root) {
|
|
|
495
513
|
configFile
|
|
496
514
|
});
|
|
497
515
|
}
|
|
498
|
-
function withInputs(error, inputs, request) {
|
|
499
|
-
const stack = error instanceof Error ? error.stack : void 0;
|
|
500
|
-
if (!(error instanceof RoutesReadError)) return new RoutesReadError("CONFIG_NOT_LOADED", `The routes a page takes were not read: ${error instanceof Error ? error.message : String(error)}`, {
|
|
501
|
-
root: request.root,
|
|
502
|
-
configFile: inputs.configFile
|
|
503
|
-
}, {
|
|
504
|
-
stack,
|
|
505
|
-
inputs
|
|
506
|
-
});
|
|
507
|
-
if (error.inputs !== void 0) return error;
|
|
508
|
-
return new RoutesReadError(error.code, error.message, error.context, {
|
|
509
|
-
stack,
|
|
510
|
-
inputs
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
516
|
function byCodeUnits(a, b) {
|
|
514
517
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
515
518
|
}
|
|
@@ -529,23 +532,17 @@ async function answer(request) {
|
|
|
529
532
|
process.send?.(workerMessages.reply(reply), () => process.exit(0));
|
|
530
533
|
}
|
|
531
534
|
function failure(error, request) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
context: error.context,
|
|
537
|
-
stack: error.stack,
|
|
538
|
-
inputs: error.inputs
|
|
539
|
-
};
|
|
535
|
+
const failed = readingFailure(error, {
|
|
536
|
+
root: request.root,
|
|
537
|
+
configFile: request.configFile
|
|
538
|
+
});
|
|
540
539
|
return {
|
|
541
540
|
ok: false,
|
|
542
|
-
code:
|
|
543
|
-
message:
|
|
544
|
-
context:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
},
|
|
548
|
-
stack: error instanceof Error ? error.stack : void 0
|
|
541
|
+
code: failed.code,
|
|
542
|
+
message: failed.message,
|
|
543
|
+
context: failed.context,
|
|
544
|
+
stack: failed.stack,
|
|
545
|
+
inputs: failed.inputs
|
|
549
546
|
};
|
|
550
547
|
}
|
|
551
548
|
export {};
|
package/lib/esbuild/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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 {
|
|
5
|
-
import { t as sharedEngine } from "../shared-engine-
|
|
6
|
-
import { t as configFileOf } from "../config-file-of-
|
|
4
|
+
import { w as CONFIG_BASENAMES } from "../load-config-barNPfXN.js";
|
|
5
|
+
import { t as sharedEngine } from "../shared-engine-D0j7uXg8.js";
|
|
6
|
+
import { t as configFileOf } from "../config-file-of-Clf_dWUQ.js";
|
|
7
7
|
import { n as ROUTES_PATTERN, r as ROUTES_SPECIFIER } from "../routes-module-id-CnUjQjYF.js";
|
|
8
|
-
import { t as routesFile } from "../routes-file-
|
|
8
|
+
import { t as routesFile } from "../routes-file-DRoqUZ0S.js";
|
|
9
9
|
import { basename, extname } from "node:path";
|
|
10
10
|
// src/esbuild/config-in-page.ts
|
|
11
11
|
const RESOLVING = "@noverax/courier-build:resolving-config";
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { t as RoutesReadError } from "./routes-read-error-DQhKIE2F.js";
|
|
2
|
-
import { i as createRoutesEngine, n as routesModuleCode, r as unreadRoutesModuleCode, t as routesCommonJsCode } from "./routes-module-code-
|
|
2
|
+
import { i as createRoutesEngine, n as routesModuleCode, r as unreadRoutesModuleCode, t as routesCommonJsCode } from "./routes-module-code-DYtP7uj1.js";
|
|
3
3
|
import { t as configInPageMessage } from "./config-in-page-message-DLd3f0Jd.js";
|
|
4
4
|
export { RoutesReadError, configInPageMessage, createRoutesEngine, routesCommonJsCode, routesModuleCode, unreadRoutesModuleCode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as routesModuleCode, t as routesCommonJsCode } from "../routes-module-code-
|
|
1
|
+
import { n as routesModuleCode, t as routesCommonJsCode } from "../routes-module-code-DYtP7uj1.js";
|
|
2
2
|
import { n as isRecord } from "../errno-code-CNx_E80R.js";
|
|
3
|
-
import { t as sharedEngine } from "../shared-engine-
|
|
3
|
+
import { t as sharedEngine } from "../shared-engine-D0j7uXg8.js";
|
|
4
4
|
import { parentPort } from "node:worker_threads";
|
|
5
5
|
// src/jest/routes-thread.ts
|
|
6
6
|
parentPort?.on("message", (message) => {
|