@taujs/server 0.4.4 → 0.4.5
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.d.ts +1 -1
- package/dist/index.js +41 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2020,7 +2020,7 @@ async function registerStaticAssets(app, baseClientRoot, reg, defaults, projectR
|
|
|
2020
2020
|
// src/SSRServer.ts
|
|
2021
2021
|
var SSRServer = (0, import_fastify_plugin3.default)(
|
|
2022
2022
|
async (app, opts) => {
|
|
2023
|
-
const { alias, configs, routes, serviceRegistry, clientRoot: baseClientRoot, security } = opts;
|
|
2023
|
+
const { alias, configs, routes, serviceRegistry = {}, clientRoot: baseClientRoot, security } = opts;
|
|
2024
2024
|
const logger = createLogger({
|
|
2025
2025
|
debug: opts.debug,
|
|
2026
2026
|
context: { component: "ssr-server" },
|
|
@@ -2339,6 +2339,37 @@ function mergeViteConfig(framework, userOverride, context) {
|
|
|
2339
2339
|
}
|
|
2340
2340
|
return merged;
|
|
2341
2341
|
}
|
|
2342
|
+
function resolveAppFilter(argv, env) {
|
|
2343
|
+
const read = (keys) => {
|
|
2344
|
+
const end = argv.indexOf("--");
|
|
2345
|
+
const limit = end === -1 ? argv.length : end;
|
|
2346
|
+
for (let i = 0; i < limit; i++) {
|
|
2347
|
+
const arg = argv[i];
|
|
2348
|
+
if (!arg) continue;
|
|
2349
|
+
for (const key of keys) {
|
|
2350
|
+
if (arg === key) {
|
|
2351
|
+
const next = argv[i + 1];
|
|
2352
|
+
if (!next || next.startsWith("-")) return "";
|
|
2353
|
+
return next.trim();
|
|
2354
|
+
}
|
|
2355
|
+
const pref = `${key}=`;
|
|
2356
|
+
if (arg.startsWith(pref)) {
|
|
2357
|
+
const v = arg.slice(pref.length).trim();
|
|
2358
|
+
return v;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
return void 0;
|
|
2363
|
+
};
|
|
2364
|
+
const envFilter = env.TAUJS_APP || env.TAUJS_APPS;
|
|
2365
|
+
const cliFilter = read(["--app", "--apps", "-a"]);
|
|
2366
|
+
const raw = (cliFilter ?? envFilter)?.trim() || void 0;
|
|
2367
|
+
if (!raw) return { selectedIds: null, raw: void 0 };
|
|
2368
|
+
const selectedIds = new Set(
|
|
2369
|
+
raw.split(",").map((s) => s.trim()).filter(Boolean)
|
|
2370
|
+
);
|
|
2371
|
+
return { selectedIds, raw };
|
|
2372
|
+
}
|
|
2342
2373
|
async function taujsBuild({
|
|
2343
2374
|
config,
|
|
2344
2375
|
projectRoot,
|
|
@@ -2359,8 +2390,16 @@ async function taujsBuild({
|
|
|
2359
2390
|
};
|
|
2360
2391
|
const extractedConfigs = extractBuildConfigs(config);
|
|
2361
2392
|
const processedConfigs = processConfigs(extractedConfigs, clientBaseDir, TEMPLATE);
|
|
2393
|
+
const { selectedIds, raw: appFilterRaw } = resolveAppFilter(process.argv.slice(2), process.env);
|
|
2394
|
+
const configsToBuild = selectedIds ? processedConfigs.filter(({ appId, entryPoint }) => selectedIds.has(appId) || selectedIds.has(entryPoint)) : processedConfigs;
|
|
2395
|
+
if (selectedIds && configsToBuild.length === 0) {
|
|
2396
|
+
console.error(
|
|
2397
|
+
`[taujs:build] No apps match filter "${appFilterRaw}". Known apps: ${processedConfigs.map((c) => `${c.appId}${c.entryPoint ? ` (entry: ${c.entryPoint})` : ""}`).join(", ")}`
|
|
2398
|
+
);
|
|
2399
|
+
process.exit(1);
|
|
2400
|
+
}
|
|
2362
2401
|
if (!isSSRBuild) await deleteDist();
|
|
2363
|
-
for (const appConfig of
|
|
2402
|
+
for (const appConfig of configsToBuild) {
|
|
2364
2403
|
const { appId, entryPoint, clientRoot, entryClient, entryServer, htmlTemplate, plugins = [] } = appConfig;
|
|
2365
2404
|
const outDir = path8.resolve(projectRoot, isSSRBuild ? `dist/ssr/${entryPoint}` : `dist/client/${entryPoint}`);
|
|
2366
2405
|
const root = entryPoint ? path8.resolve(clientBaseDir, entryPoint) : clientBaseDir;
|
|
@@ -2399,8 +2438,6 @@ async function taujsBuild({
|
|
|
2399
2438
|
},
|
|
2400
2439
|
plugins,
|
|
2401
2440
|
publicDir: isSSRBuild ? false : "public",
|
|
2402
|
-
// single shared public
|
|
2403
|
-
// publicDir: isSSRBuild ? false : path.join(root, 'public'), // per-app. no public dir for SSR builds
|
|
2404
2441
|
resolve: { alias: resolvedAlias },
|
|
2405
2442
|
root
|
|
2406
2443
|
};
|