defuss-ssg 0.7.0 → 0.7.2

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 CHANGED
@@ -86,6 +86,31 @@ export default config;
86
86
 
87
87
  `containerRuntime` forces `docker` or `podman` for `docker-*` commands. `viteConfig` is merged into defuss-ssg's internal Vite config for both `dev` and `build`, so you can add aliases, plugins, server options, and similar Vite settings from `config.ts`.
88
88
 
89
+ If you need to extend the current defuss-ssg Vite config instead of only passing a patch object, import it from the virtual module and merge from there:
90
+
91
+ ```ts
92
+ import { mergeConfig } from "vite";
93
+ import { viteConfig as currentViteConfig } from "virtual:defuss-ssg/config";
94
+
95
+ const config: SsgConfig = {
96
+ viteConfig: mergeConfig(currentViteConfig, {
97
+ resolve: {
98
+ alias: {
99
+ "@app": new URL("./src", import.meta.url).pathname,
100
+ },
101
+ },
102
+ server: {
103
+ // your custom domain, headers etc.
104
+ allowedHosts: ["example-ssg.demo.defuss.tech"],
105
+ },
106
+ }),
107
+ };
108
+
109
+ export default config;
110
+ ```
111
+
112
+ The virtual module resolves to the current internal `defuss-ssg` Vite config, so you can also inspect or extend existing plugin arrays and nested Vite settings without re-creating them manually.
113
+
89
114
  Example page:
90
115
 
91
116
  ```mdx
@@ -138,14 +163,23 @@ defuss-ssg serve ./my-site
138
163
 
139
164
  `serve` expects existing build output in `dist/`, so run `build` first.
140
165
 
141
- ## Docker and Podman
166
+ For checked-out, unpublished, or locally linked package development use e.g.:
167
+
168
+ ```bash
169
+ node ./dist/cli.mjs dev ../../examples/with-dson/ --port 3010
170
+ ```
171
+
172
+
173
+ ## Production Deployment
174
+
175
+ `defuss-ssg` supports `podman` and `docker` for production deployment.
142
176
 
143
177
  The primary container workflow is built into the CLI:
144
178
 
145
179
  ```bash
146
- bunx defuss-ssg docker-dev ./my-site
147
- bunx defuss-ssg docker-build ./my-site
148
- bunx defuss-ssg docker-serve ./my-site --multicore
180
+ bunx defuss-ssg container-dev ./my-site
181
+ bunx defuss-ssg container-build ./my-site
182
+ bunx defuss-ssg container-serve ./my-site --multicore
149
183
  ```
150
184
 
151
185
  When you are working from this monorepo before the next npm publish, use the built local CLI instead of `bunx defuss-ssg`. `bunx defuss-ssg` resolves the last published package, so it will not see unreleased `docker-*` commands from this checkout:
@@ -153,12 +187,12 @@ When you are working from this monorepo before the next npm publish, use the bui
153
187
  ```bash
154
188
  cd packages/ssg
155
189
  bun run build
156
- node ./dist/cli.mjs docker-dev ../../example-ssg --port 3111 --docker-args --network host
190
+ node ./dist/cli.mjs container-dev ../../example-ssg --port 3111 --container-args --network host
157
191
  ```
158
192
 
159
193
  Each `docker-*` command writes a temporary Dockerfile, builds a local `defuss-ssg` image, mounts your project at `/workspace`, mounts a deterministic container-managed `/workspace/node_modules` volume, and then runs the matching inner `defuss-ssg` command. The mounted project still owns its dependency graph: the container reads that project's `package.json`, uses its declared package manager, installs the project's dependencies, and then starts `dev`, `build`, or `serve`.
160
194
 
161
- `docker-dev` and `docker-serve` automatically bind the inner service to `0.0.0.0` and publish the selected port. One published port is enough even with `--multicore`; `defuss-express` keeps worker ports internal and load-balances behind the public port.
195
+ `container-dev` and `container-serve` automatically bind the inner service to `0.0.0.0` and publish the selected port. One published port is enough even with `--multicore`; `defuss-express` keeps worker ports internal and load-balances behind the public port.
162
196
 
163
197
  Runtime selection:
164
198
 
@@ -172,11 +206,11 @@ export default {
172
206
  };
173
207
  ```
174
208
 
175
- Outer container runtime arguments can be forwarded with `--docker-args`. Everything after that marker is appended to the outer `docker run` or `podman run` call, while the arguments before it still go to the inner `defuss-ssg` command:
209
+ Outer container runtime arguments can be forwarded with `--container-args`. Everything after that marker is appended to the outer `docker run` or `podman run` call, while the arguments before it still go to the inner `defuss-ssg` command:
176
210
 
177
211
  ```bash
178
- bunx defuss-ssg docker-dev ./my-site --port 3000 --docker-args --network host
179
- bunx defuss-ssg docker-serve ./my-site --multicore --docker-args --env NODE_ENV=production
212
+ bunx defuss-ssg container-dev ./my-site --port 3000 --container-args --network host
213
+ bunx defuss-ssg container-serve ./my-site --multicore --container-args --env NODE_ENV=production
180
214
  ```
181
215
 
182
216
  Good to know:
@@ -237,7 +271,7 @@ Notes:
237
271
  - `cwd` defaults to the current working directory for the direct helper.
238
272
  - The virtual module binds `cwd` and `pages` to the active SSG project automatically.
239
273
  - `route` is only derived for files inside the configured `pages` directory.
240
- - v1 returns metadata records only; it does not eagerly execute every matched MDX module.
274
+ - Returns metadata records only; it does not eagerly execute every matched MDX module.
241
275
 
242
276
  ## Endpoints
243
277
 
@@ -387,7 +421,7 @@ Most projects only need the main package export.
387
421
  ## CLI Reference
388
422
 
389
423
  ```bash
390
- defuss-ssg [dev|build|serve|docker-dev|docker-build|docker-serve] [folder] [options]
424
+ defuss-ssg [dev|build|serve|container-dev|container-build|container-serve] [folder] [options]
391
425
 
392
426
  No args -> dev .
393
427
  Single path -> dev <path>
@@ -402,9 +436,9 @@ Commands:
402
436
  - `dev`: starts the Vite dev server on port `3000` by default
403
437
  - `build`: generates the static site into `dist/`
404
438
  - `serve`: serves the built output from `dist/`
405
- - `docker-dev`: builds the generated image, mounts the project, and starts `dev` inside Docker or Podman
406
- - `docker-build`: builds the generated image, mounts the project, and runs `build` inside Docker or Podman
407
- - `docker-serve`: builds the generated image, mounts the project, and runs `serve` inside Docker or Podman
439
+ - `container-dev`: builds the generated image, mounts the project, and starts `dev` inside Docker or Podman
440
+ - `container-build`: builds the generated image, mounts the project, and runs `build` inside Docker or Podman
441
+ - `container-serve`: builds the generated image, mounts the project, and runs `serve` inside Docker or Podman
408
442
 
409
443
  Flags:
410
444
 
@@ -413,7 +447,7 @@ Flags:
413
447
  - `--host` or `-H <host>`: override the dev or serve bind host
414
448
  - `--port` or `-p <port>`: override the dev or serve port
415
449
  - `--skip-setup` or `--no-setup`: skip project dependency installation for prepared environments and containers
416
- - `--docker-args <args...>`: forward everything after the marker to the outer `docker run` or `podman run` invocation used by `docker-*`
450
+ - `--container-args <args...>`: forward everything after the marker to the outer `docker run` or `podman run` invocation used by `docker-*`
417
451
 
418
452
  ## Local Package Development
419
453
 
package/dist/cli.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { r as readConfig, v as validateProjectDir, b as build } from './vite-CSOGjlHB.mjs';
2
+ import { B as readConfig, L as validateProjectDir, b as build } from './vite-bKsy4atm.mjs';
3
3
  import { spawnSync, spawn } from 'node:child_process';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { mkdtempSync, writeFileSync, rmSync, existsSync, readFileSync } from 'node:fs';
6
6
  import { tmpdir } from 'node:os';
7
7
  import { resolve, join, basename, dirname } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
- import { d as dev, s as serve } from './serve-BFMU8uCH.mjs';
9
+ import { d as dev, s as serve } from './serve-qxXVqJiL.mjs';
10
10
  import 'fast-glob';
11
11
  import 'node:fs/promises';
12
12
  import 'defuss/server';
@@ -23,7 +23,7 @@ import 'remark-gfm';
23
23
  import 'remark-parse';
24
24
  import 'remark-rehype';
25
25
  import 'remark-mdx-frontmatter';
26
- import './path-CjHWUK8o.mjs';
26
+ import './path-j0LJZE_u.mjs';
27
27
  import 'node:process';
28
28
  import 'defuss-express';
29
29
 
@@ -133,25 +133,25 @@ const runContainerRuntime = (runtime, args, label, cwd) => {
133
133
  );
134
134
  }
135
135
  };
136
- const hasPublishArgs = (dockerArgs) => {
137
- for (let index = 0; index < dockerArgs.length; index += 1) {
138
- const arg = dockerArgs[index];
136
+ const hasPublishArgs = (containerArgs) => {
137
+ for (let index = 0; index < containerArgs.length; index += 1) {
138
+ const arg = containerArgs[index];
139
139
  if (arg === "-p" || arg === "-P" || arg === "--publish" || arg === "--publish-all" || arg.startsWith("--publish=")) {
140
140
  return true;
141
141
  }
142
142
  }
143
143
  return false;
144
144
  };
145
- const extractHostNetworkArgs = (dockerArgs) => {
145
+ const extractHostNetworkArgs = (containerArgs) => {
146
146
  const remainingArgs = [];
147
147
  let hostNetworkRequested = false;
148
- for (let index = 0; index < dockerArgs.length; index += 1) {
149
- const arg = dockerArgs[index];
148
+ for (let index = 0; index < containerArgs.length; index += 1) {
149
+ const arg = containerArgs[index];
150
150
  if (arg === "--net=host" || arg === "--network=host") {
151
151
  hostNetworkRequested = true;
152
152
  continue;
153
153
  }
154
- if ((arg === "--net" || arg === "--network") && dockerArgs[index + 1] === "host") {
154
+ if ((arg === "--net" || arg === "--network") && containerArgs[index + 1] === "host") {
155
155
  hostNetworkRequested = true;
156
156
  index += 1;
157
157
  continue;
@@ -202,11 +202,11 @@ const runContainerCommand = async ({
202
202
  port,
203
203
  multicore = false,
204
204
  skipSetup = false,
205
- dockerArgs
205
+ containerArgs
206
206
  }) => {
207
207
  const resolvedProjectDir = resolve(projectDir);
208
208
  const runtime = await resolveContainerRuntime(resolvedProjectDir, debug);
209
- const { remainingArgs, hostNetworkRequested } = extractHostNetworkArgs(dockerArgs);
209
+ const { remainingArgs, hostNetworkRequested } = extractHostNetworkArgs(containerArgs);
210
210
  const useHostNetwork = hostNetworkRequested && process.platform === "linux";
211
211
  const tempDir = mkdtempSync(join(tmpdir(), "defuss-ssg-container-"));
212
212
  const volumeName = getNodeModulesVolumeName(resolvedProjectDir);
@@ -412,7 +412,7 @@ const setup = async (projectDir) => {
412
412
  }
413
413
  };
414
414
 
415
- const usage = `Usage: defuss-ssg [dev|build|serve|docker-dev|docker-build|docker-serve] [folder] [options]
415
+ const usage = `Usage: defuss-ssg [dev|build|serve|container-dev|container-build|container-serve] [folder] [options]
416
416
  No args => dev .
417
417
  Single path => dev <path>
418
418
  Single command => <command> .
@@ -423,7 +423,7 @@ const usage = `Usage: defuss-ssg [dev|build|serve|docker-dev|docker-build|docker
423
423
  --port, -p <number>
424
424
  --host, -H <host>
425
425
  --skip-setup
426
- --docker-args <args...>`;
426
+ --container-args <args...>`;
427
427
  const isTruthy = (value) => {
428
428
  if (!value) return false;
429
429
  return ["1", "true", "yes", "on"].includes(value.toLowerCase());
@@ -444,9 +444,9 @@ const parsePort = (value) => {
444
444
  return port;
445
445
  };
446
446
  const parseCliArgs = (args) => {
447
- const dockerArgsIndex = args.indexOf("--docker-args");
448
- const cliArgs = dockerArgsIndex === -1 ? args : args.slice(0, dockerArgsIndex);
449
- const dockerArgs = dockerArgsIndex === -1 ? [] : args.slice(dockerArgsIndex + 1);
447
+ const containerArgsIndex = args.indexOf("--container-args");
448
+ const cliArgs = containerArgsIndex === -1 ? args : args.slice(0, containerArgsIndex);
449
+ const containerArgs = containerArgsIndex === -1 ? [] : args.slice(containerArgsIndex + 1);
450
450
  let debug = false;
451
451
  let multicore = false;
452
452
  let skipSetup = isTruthy(process.env.DEFUSS_SSG_SKIP_SETUP) || isDefussWorkerProcess();
@@ -492,7 +492,7 @@ const parseCliArgs = (args) => {
492
492
  }
493
493
  return {
494
494
  debug,
495
- dockerArgs,
495
+ containerArgs,
496
496
  multicore,
497
497
  skipSetup,
498
498
  port,
@@ -506,24 +506,24 @@ const parseCliArgs = (args) => {
506
506
  "dev",
507
507
  "build",
508
508
  "serve",
509
- "docker-dev",
510
- "docker-build",
511
- "docker-serve"
509
+ "container-dev",
510
+ "container-build",
511
+ "container-serve"
512
512
  ]);
513
513
  const containerCommands = /* @__PURE__ */ new Set([
514
- "docker-dev",
515
- "docker-build",
516
- "docker-serve"
514
+ "container-dev",
515
+ "container-build",
516
+ "container-serve"
517
517
  ]);
518
518
  let debug;
519
- let dockerArgs;
519
+ let containerArgs;
520
520
  let multicore;
521
521
  let skipSetup;
522
522
  let port;
523
523
  let host;
524
524
  let positional;
525
525
  try {
526
- ({ debug, dockerArgs, multicore, skipSetup, port, host, positional } = parseCliArgs(args));
526
+ ({ debug, containerArgs, multicore, skipSetup, port, host, positional } = parseCliArgs(args));
527
527
  } catch (error) {
528
528
  console.error(
529
529
  `${error instanceof Error ? error.message : "Invalid CLI arguments"}
@@ -559,9 +559,9 @@ ${usage}`
559
559
  const projectDir = resolve(folder);
560
560
  const workerProcess = isDefussWorkerProcess();
561
561
  const isContainerCommand = containerCommands.has(command);
562
- if (!isContainerCommand && dockerArgs.length > 0) {
562
+ if (!isContainerCommand && containerArgs.length > 0) {
563
563
  console.error(
564
- `--docker-args can only be used with docker-dev, docker-build, or docker-serve.
564
+ `--container-args can only be used with container-dev, container-build, or container-serve.
565
565
  ${usage}`
566
566
  );
567
567
  process.exit(1);
@@ -575,7 +575,7 @@ ${usage}`
575
575
  port,
576
576
  multicore,
577
577
  skipSetup,
578
- dockerArgs
578
+ containerArgs
579
579
  });
580
580
  return;
581
581
  }
@@ -1,4 +1,4 @@
1
- import { f as ContentGlobOptions, e as ContentEntry } from './types-CZSWRdQS.cjs';
1
+ import { c as ContentGlobOptions, b as ContentEntry } from './types-Dh8AcW7C.cjs';
2
2
  import 'remark-rehype';
3
3
  import 'defuss/server';
4
4
  import 'vite';
@@ -1,4 +1,4 @@
1
- import { f as ContentGlobOptions, e as ContentEntry } from './types-CZSWRdQS.mjs';
1
+ import { c as ContentGlobOptions, b as ContentEntry } from './types-Dh8AcW7C.mjs';
2
2
  import 'remark-rehype';
3
3
  import 'defuss/server';
4
4
  import 'vite';
package/dist/content.mjs CHANGED
@@ -3,7 +3,7 @@ import { resolve, relative, extname } from 'node:path';
3
3
  import glob$1 from 'fast-glob';
4
4
  import toml from 'toml';
5
5
  import { parse } from 'yaml';
6
- import { f as filePathToRoute } from './path-CjHWUK8o.mjs';
6
+ import { f as filePathToRoute } from './path-j0LJZE_u.mjs';
7
7
  import 'node:fs';
8
8
 
9
9
  const PAGE_ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".html", ".md", ".mdx"]);
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var vite = require('./vite-BC7XxFTV.cjs');
3
+ var vite = require('./vite-CE8Q5aF_.cjs');
4
4
  var content = require('./content.cjs');
5
5
  var mdx = require('@mdx-js/rollup');
6
6
  var vite$1 = require('vite');
@@ -38,43 +38,44 @@ const dev = async ({
38
38
  }) => {
39
39
  const projectDirStatus = vite.validateProjectDir(projectDir);
40
40
  if (projectDirStatus.code !== "OK") return projectDirStatus;
41
- const config = await vite.readConfig(projectDir, debug);
42
- const server = await vite$1.createServer(
43
- vite$1.mergeConfig(
44
- {
45
- root: projectDir,
46
- configFile: false,
47
- appType: "custom",
48
- server: {
49
- host,
50
- port,
51
- watch: {
52
- ignored: [
53
- "**/node_modules/**",
54
- "**/dist/**",
55
- "**/.ssg-temp/**",
56
- "**/.endpoints/**",
57
- "**/.rpc/**"
58
- ]
59
- }
60
- },
61
- plugins: [
62
- defuss({ enableJsxDevMode: true }),
63
- mdx({
64
- jsxImportSource: "defuss",
65
- development: true,
66
- remarkPlugins: config.remarkPlugins,
67
- rehypePlugins: config.rehypePlugins
68
- }),
69
- ...vite.defussSsg({
70
- projectDir,
71
- debug,
72
- writeDevOutput
73
- })
41
+ const initialConfig = await vite.readConfig(projectDir, debug);
42
+ const currentViteConfig = {
43
+ root: projectDir,
44
+ configFile: false,
45
+ appType: "custom",
46
+ server: {
47
+ host,
48
+ port,
49
+ watch: {
50
+ ignored: [
51
+ "**/node_modules/**",
52
+ "**/dist/**",
53
+ "**/.ssg-temp/**",
54
+ "**/.endpoints/**",
55
+ "**/.rpc/**"
74
56
  ]
75
- },
76
- config.viteConfig ?? {}
77
- )
57
+ }
58
+ },
59
+ plugins: [
60
+ defuss({ enableJsxDevMode: true }),
61
+ mdx({
62
+ jsxImportSource: "defuss",
63
+ development: true,
64
+ remarkPlugins: initialConfig.remarkPlugins,
65
+ rehypePlugins: initialConfig.rehypePlugins
66
+ }),
67
+ ...vite.defussSsg({
68
+ projectDir,
69
+ debug,
70
+ writeDevOutput
71
+ })
72
+ ]
73
+ };
74
+ const config = await vite.readConfig(projectDir, debug, {
75
+ currentViteConfig
76
+ });
77
+ const server = await vite$1.createServer(
78
+ vite.mergeUserViteConfig(currentViteConfig, config.viteConfig)
78
79
  );
79
80
  await server.listen(port);
80
81
  server.printUrls();
@@ -195,11 +196,19 @@ const serve = async ({
195
196
  };
196
197
 
197
198
  exports.HTTP_METHODS = vite.HTTP_METHODS;
199
+ exports.SSG_CONFIG_MODULE_ID = vite.SSG_CONFIG_MODULE_ID;
200
+ exports.applyConfigDefaults = vite.applyConfigDefaults;
198
201
  exports.build = vite.build;
199
202
  exports.buildEndpoints = vite.buildEndpoints;
203
+ exports.clearVirtualConfigModuleState = vite.clearVirtualConfigModuleState;
204
+ exports.cloneConfigValue = vite.cloneConfigValue;
205
+ exports.compileConfigModule = vite.compileConfigModule;
200
206
  exports.compileEndpoints = vite.compileEndpoints;
201
207
  exports.compileRpcModule = vite.compileRpcModule;
202
208
  exports.configDefaults = vite.configDefaults;
209
+ exports.createConfigModulePlugin = vite.createConfigModulePlugin;
210
+ exports.createConfigModuleStateKey = vite.createConfigModuleStateKey;
211
+ exports.createTaggedBaseViteConfig = vite.createTaggedBaseViteConfig;
203
212
  exports.defussSsg = vite.defussSsg;
204
213
  exports.discoverEndpointSourceFiles = vite.discoverEndpointSourceFiles;
205
214
  exports.discoverRpcFile = vite.discoverRpcFile;
@@ -207,12 +216,20 @@ exports.endpointFileToRoute = vite.endpointFileToRoute;
207
216
  exports.handleEndpointRoute = vite.handleEndpointRoute;
208
217
  exports.handleRpcRequest = vite.handleRpcRequest;
209
218
  exports.initializeRpc = vite.initializeRpc;
219
+ exports.isBareModuleId = vite.isBareModuleId;
220
+ exports.isPlainObject = vite.isPlainObject;
221
+ exports.isTaggedBaseViteConfig = vite.isTaggedBaseViteConfig;
222
+ exports.loadCompiledConfigModule = vite.loadCompiledConfigModule;
210
223
  exports.loadEndpointModule = vite.loadEndpointModule;
211
224
  exports.matchRoutePattern = vite.matchRoutePattern;
225
+ exports.mergeUserViteConfig = vite.mergeUserViteConfig;
212
226
  exports.readConfig = vite.readConfig;
213
227
  exports.registerEndpoints = vite.registerEndpoints;
228
+ exports.resolveConfigPath = vite.resolveConfigPath;
214
229
  exports.resolveEndpoints = vite.resolveEndpoints;
215
230
  exports.routeToExpressPattern = vite.routeToExpressPattern;
231
+ exports.setVirtualConfigModuleState = vite.setVirtualConfigModuleState;
232
+ exports.stripBaseViteConfigMarker = vite.stripBaseViteConfigMarker;
216
233
  exports.glob = content.glob;
217
234
  exports.dev = dev;
218
235
  exports.serve = serve;
package/dist/index.d.cts CHANGED
@@ -1,18 +1,52 @@
1
- import { S as SsgConfig, B as BuildOptions, a as Status, D as DevOptions, b as ServeOptions, E as EndpointRouteContext, c as EndpointRouteRegistrar } from './types-CZSWRdQS.cjs';
2
- export { d as BuildMode, C as ContainerRuntime, e as ContentEntry, f as ContentGlobOptions, g as DefussSsgViteOptions, h as DevChangeKind, i as EndpointRouteMethod, j as EndpointRouteResponder, P as PluginFn, k as PluginFnPageDom, l as PluginFnPageHtml, m as PluginFnPageVdom, n as PluginFnPrePost, R as RehypePlugins, o as RemarkPlugins, p as SsgPlugin, q as StatusCode } from './types-CZSWRdQS.cjs';
1
+ import { n as SsgConfig, a as BuildOptions, p as Status, e as DevOptions, S as ServeOptions, E as EndpointRouteContext, g as EndpointRouteRegistrar } from './types-Dh8AcW7C.cjs';
2
+ export { B as BuildMode, C as ContainerRuntime, b as ContentEntry, c as ContentGlobOptions, D as DefussSsgViteOptions, d as DevChangeKind, f as EndpointRouteMethod, h as EndpointRouteResponder, P as PluginFn, i as PluginFnPageDom, j as PluginFnPageHtml, k as PluginFnPageVdom, l as PluginFnPrePost, R as RehypePlugins, m as RemarkPlugins, o as SsgPlugin, q as StatusCode } from './types-Dh8AcW7C.cjs';
3
+ import { Plugin } from 'rolldown';
4
+ import { InlineConfig } from 'vite';
3
5
  export { glob } from './content.cjs';
4
6
  export { defussSsg } from './vite.cjs';
5
7
  import 'remark-rehype';
6
8
  import 'defuss/server';
7
- import 'vite';
8
9
 
10
+ declare const SSG_CONFIG_MODULE_ID = "virtual:defuss-ssg/config";
11
+ interface ReadConfigOptions {
12
+ currentViteConfig?: InlineConfig;
13
+ }
14
+ type VirtualConfigModuleState = {
15
+ viteConfig: InlineConfig;
16
+ };
17
+ type CompiledConfigModule = {
18
+ entryFileName: string;
19
+ outputFiles: Array<{
20
+ fileName: string;
21
+ type: "asset" | "chunk";
22
+ content: string | Uint8Array;
23
+ isEntry?: boolean;
24
+ }>;
25
+ stateKey: string;
26
+ };
27
+ declare const resolveConfigPath: (projectDir: string) => string | null;
28
+ declare const applyConfigDefaults: (config: SsgConfig) => SsgConfig;
29
+ declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
30
+ declare const cloneConfigValue: <T>(value: T) => T;
31
+ declare const createTaggedBaseViteConfig: (viteConfig?: InlineConfig) => InlineConfig;
32
+ declare const isTaggedBaseViteConfig: (viteConfig: unknown) => viteConfig is InlineConfig & Record<string, unknown>;
33
+ declare const stripBaseViteConfigMarker: (viteConfig: InlineConfig) => InlineConfig;
34
+ declare const setVirtualConfigModuleState: (stateKey: string, state: VirtualConfigModuleState) => void;
35
+ declare const clearVirtualConfigModuleState: (stateKey: string) => void;
36
+ declare const createConfigModuleStateKey: () => string;
37
+ declare const createConfigModulePlugin: (stateKey: string) => Plugin;
38
+ declare const isBareModuleId: (id: string) => boolean;
39
+ declare const compileConfigModule: (configPath: string, projectDir: string) => Promise<CompiledConfigModule>;
40
+ declare const loadCompiledConfigModule: (compiledConfigModule: CompiledConfigModule, configPath: string, projectDir: string, currentViteConfig?: InlineConfig) => Promise<SsgConfig>;
41
+ declare const mergeUserViteConfig: (currentViteConfig: InlineConfig, userViteConfig?: InlineConfig) => InlineConfig;
9
42
  /**
10
43
  * Reads the SSG configuration from the project directory.
11
44
  * @param projectDir The path to the project directory.
12
45
  * @param debug Whether to enable debug logging.
46
+ * @param options Optional caller-specific loader options.
13
47
  * @returns The SSG configuration.
14
48
  */
15
- declare const readConfig: (projectDir: string, debug: boolean) => Promise<SsgConfig>;
49
+ declare const readConfig: (projectDir: string, debug: boolean, options?: ReadConfigOptions) => Promise<SsgConfig>;
16
50
  declare const configDefaults: SsgConfig;
17
51
 
18
52
  /**
@@ -228,5 +262,11 @@ declare const handleRpcRequest: (ctx: {
228
262
  request: Request;
229
263
  }) => Promise<Response>;
230
264
 
231
- export { BuildOptions, DevOptions, EndpointRouteContext, EndpointRouteRegistrar, HTTP_METHODS, ServeOptions, SsgConfig, Status, build, buildEndpoints, compileEndpoints, compileRpcModule, configDefaults, dev, discoverEndpointSourceFiles, discoverRpcFile, endpointFileToRoute, handleEndpointRoute, handleRpcRequest, initializeRpc, loadEndpointModule, matchRoutePattern, readConfig, registerEndpoints, resolveEndpoints, routeToExpressPattern, serve };
232
- export type { APIRoute, EndpointContext, EndpointHandler, EndpointModule, HttpMethod, ResolvedEndpoint };
265
+ export { BuildOptions, DevOptions, EndpointRouteContext, EndpointRouteRegistrar, HTTP_METHODS, SSG_CONFIG_MODULE_ID, ServeOptions, SsgConfig, Status, applyConfigDefaults, build, buildEndpoints, clearVirtualConfigModuleState, cloneConfigValue, compileConfigModule, compileEndpoints, compileRpcModule, configDefaults, createConfigModulePlugin, createConfigModuleStateKey, createTaggedBaseViteConfig, dev, discoverEndpointSourceFiles, discoverRpcFile, endpointFileToRoute, handleEndpointRoute, handleRpcRequest, initializeRpc, isBareModuleId, isPlainObject, isTaggedBaseViteConfig, loadCompiledConfigModule, loadEndpointModule, matchRoutePattern, mergeUserViteConfig, readConfig, registerEndpoints, resolveConfigPath, resolveEndpoints, routeToExpressPattern, serve, setVirtualConfigModuleState, stripBaseViteConfigMarker };
266
+ export type { APIRoute, CompiledConfigModule, EndpointContext, EndpointHandler, EndpointModule, HttpMethod, ReadConfigOptions, ResolvedEndpoint, VirtualConfigModuleState };
267
+
268
+
269
+ declare module "virtual:defuss-ssg/config" {
270
+ export const viteConfig: import("vite").InlineConfig;
271
+ export default viteConfig;
272
+ }
package/dist/index.d.mts CHANGED
@@ -1,18 +1,52 @@
1
- import { S as SsgConfig, B as BuildOptions, a as Status, D as DevOptions, b as ServeOptions, E as EndpointRouteContext, c as EndpointRouteRegistrar } from './types-CZSWRdQS.mjs';
2
- export { d as BuildMode, C as ContainerRuntime, e as ContentEntry, f as ContentGlobOptions, g as DefussSsgViteOptions, h as DevChangeKind, i as EndpointRouteMethod, j as EndpointRouteResponder, P as PluginFn, k as PluginFnPageDom, l as PluginFnPageHtml, m as PluginFnPageVdom, n as PluginFnPrePost, R as RehypePlugins, o as RemarkPlugins, p as SsgPlugin, q as StatusCode } from './types-CZSWRdQS.mjs';
1
+ import { n as SsgConfig, a as BuildOptions, p as Status, e as DevOptions, S as ServeOptions, E as EndpointRouteContext, g as EndpointRouteRegistrar } from './types-Dh8AcW7C.mjs';
2
+ export { B as BuildMode, C as ContainerRuntime, b as ContentEntry, c as ContentGlobOptions, D as DefussSsgViteOptions, d as DevChangeKind, f as EndpointRouteMethod, h as EndpointRouteResponder, P as PluginFn, i as PluginFnPageDom, j as PluginFnPageHtml, k as PluginFnPageVdom, l as PluginFnPrePost, R as RehypePlugins, m as RemarkPlugins, o as SsgPlugin, q as StatusCode } from './types-Dh8AcW7C.mjs';
3
+ import { Plugin } from 'rolldown';
4
+ import { InlineConfig } from 'vite';
3
5
  export { glob } from './content.mjs';
4
6
  export { defussSsg } from './vite.mjs';
5
7
  import 'remark-rehype';
6
8
  import 'defuss/server';
7
- import 'vite';
8
9
 
10
+ declare const SSG_CONFIG_MODULE_ID = "virtual:defuss-ssg/config";
11
+ interface ReadConfigOptions {
12
+ currentViteConfig?: InlineConfig;
13
+ }
14
+ type VirtualConfigModuleState = {
15
+ viteConfig: InlineConfig;
16
+ };
17
+ type CompiledConfigModule = {
18
+ entryFileName: string;
19
+ outputFiles: Array<{
20
+ fileName: string;
21
+ type: "asset" | "chunk";
22
+ content: string | Uint8Array;
23
+ isEntry?: boolean;
24
+ }>;
25
+ stateKey: string;
26
+ };
27
+ declare const resolveConfigPath: (projectDir: string) => string | null;
28
+ declare const applyConfigDefaults: (config: SsgConfig) => SsgConfig;
29
+ declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
30
+ declare const cloneConfigValue: <T>(value: T) => T;
31
+ declare const createTaggedBaseViteConfig: (viteConfig?: InlineConfig) => InlineConfig;
32
+ declare const isTaggedBaseViteConfig: (viteConfig: unknown) => viteConfig is InlineConfig & Record<string, unknown>;
33
+ declare const stripBaseViteConfigMarker: (viteConfig: InlineConfig) => InlineConfig;
34
+ declare const setVirtualConfigModuleState: (stateKey: string, state: VirtualConfigModuleState) => void;
35
+ declare const clearVirtualConfigModuleState: (stateKey: string) => void;
36
+ declare const createConfigModuleStateKey: () => string;
37
+ declare const createConfigModulePlugin: (stateKey: string) => Plugin;
38
+ declare const isBareModuleId: (id: string) => boolean;
39
+ declare const compileConfigModule: (configPath: string, projectDir: string) => Promise<CompiledConfigModule>;
40
+ declare const loadCompiledConfigModule: (compiledConfigModule: CompiledConfigModule, configPath: string, projectDir: string, currentViteConfig?: InlineConfig) => Promise<SsgConfig>;
41
+ declare const mergeUserViteConfig: (currentViteConfig: InlineConfig, userViteConfig?: InlineConfig) => InlineConfig;
9
42
  /**
10
43
  * Reads the SSG configuration from the project directory.
11
44
  * @param projectDir The path to the project directory.
12
45
  * @param debug Whether to enable debug logging.
46
+ * @param options Optional caller-specific loader options.
13
47
  * @returns The SSG configuration.
14
48
  */
15
- declare const readConfig: (projectDir: string, debug: boolean) => Promise<SsgConfig>;
49
+ declare const readConfig: (projectDir: string, debug: boolean, options?: ReadConfigOptions) => Promise<SsgConfig>;
16
50
  declare const configDefaults: SsgConfig;
17
51
 
18
52
  /**
@@ -228,5 +262,11 @@ declare const handleRpcRequest: (ctx: {
228
262
  request: Request;
229
263
  }) => Promise<Response>;
230
264
 
231
- export { BuildOptions, DevOptions, EndpointRouteContext, EndpointRouteRegistrar, HTTP_METHODS, ServeOptions, SsgConfig, Status, build, buildEndpoints, compileEndpoints, compileRpcModule, configDefaults, dev, discoverEndpointSourceFiles, discoverRpcFile, endpointFileToRoute, handleEndpointRoute, handleRpcRequest, initializeRpc, loadEndpointModule, matchRoutePattern, readConfig, registerEndpoints, resolveEndpoints, routeToExpressPattern, serve };
232
- export type { APIRoute, EndpointContext, EndpointHandler, EndpointModule, HttpMethod, ResolvedEndpoint };
265
+ export { BuildOptions, DevOptions, EndpointRouteContext, EndpointRouteRegistrar, HTTP_METHODS, SSG_CONFIG_MODULE_ID, ServeOptions, SsgConfig, Status, applyConfigDefaults, build, buildEndpoints, clearVirtualConfigModuleState, cloneConfigValue, compileConfigModule, compileEndpoints, compileRpcModule, configDefaults, createConfigModulePlugin, createConfigModuleStateKey, createTaggedBaseViteConfig, dev, discoverEndpointSourceFiles, discoverRpcFile, endpointFileToRoute, handleEndpointRoute, handleRpcRequest, initializeRpc, isBareModuleId, isPlainObject, isTaggedBaseViteConfig, loadCompiledConfigModule, loadEndpointModule, matchRoutePattern, mergeUserViteConfig, readConfig, registerEndpoints, resolveConfigPath, resolveEndpoints, routeToExpressPattern, serve, setVirtualConfigModuleState, stripBaseViteConfigMarker };
266
+ export type { APIRoute, CompiledConfigModule, EndpointContext, EndpointHandler, EndpointModule, HttpMethod, ReadConfigOptions, ResolvedEndpoint, VirtualConfigModuleState };
267
+
268
+
269
+ declare module "virtual:defuss-ssg/config" {
270
+ export const viteConfig: import("vite").InlineConfig;
271
+ export default viteConfig;
272
+ }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { H as HTTP_METHODS, b as build, a as buildEndpoints, c as compileEndpoints, d as compileRpcModule, e as configDefaults, f as defussSsg, g as discoverEndpointSourceFiles, h as discoverRpcFile, i as endpointFileToRoute, j as handleEndpointRoute, k as handleRpcRequest, l as initializeRpc, m as loadEndpointModule, n as matchRoutePattern, r as readConfig, o as registerEndpoints, p as resolveEndpoints, q as routeToExpressPattern } from './vite-CSOGjlHB.mjs';
1
+ export { H as HTTP_METHODS, S as SSG_CONFIG_MODULE_ID, a as applyConfigDefaults, b as build, c as buildEndpoints, d as clearVirtualConfigModuleState, e as cloneConfigValue, f as compileConfigModule, g as compileEndpoints, h as compileRpcModule, i as configDefaults, j as createConfigModulePlugin, k as createConfigModuleStateKey, l as createTaggedBaseViteConfig, n as defussSsg, o as discoverEndpointSourceFiles, p as discoverRpcFile, q as endpointFileToRoute, r as handleEndpointRoute, s as handleRpcRequest, t as initializeRpc, u as isBareModuleId, v as isPlainObject, w as isTaggedBaseViteConfig, x as loadCompiledConfigModule, y as loadEndpointModule, z as matchRoutePattern, A as mergeUserViteConfig, B as readConfig, D as registerEndpoints, E as resolveConfigPath, F as resolveEndpoints, G as routeToExpressPattern, J as setVirtualConfigModuleState, K as stripBaseViteConfigMarker } from './vite-bKsy4atm.mjs';
2
2
  export { glob } from './content.mjs';
3
- export { d as dev, s as serve } from './serve-BFMU8uCH.mjs';
3
+ export { d as dev, s as serve } from './serve-qxXVqJiL.mjs';
4
4
  import 'fast-glob';
5
5
  import 'node:fs';
6
6
  import 'node:fs/promises';
@@ -22,7 +22,7 @@ import 'remark-gfm';
22
22
  import 'remark-parse';
23
23
  import 'remark-rehype';
24
24
  import 'remark-mdx-frontmatter';
25
- import './path-CjHWUK8o.mjs';
25
+ import './path-j0LJZE_u.mjs';
26
26
  import 'toml';
27
27
  import 'yaml';
28
28
  import 'node:process';
@@ -168,4 +168,4 @@ const filePathToRoute = (filePath, config, cwd) => {
168
168
  return routePath;
169
169
  };
170
170
 
171
- export { resolvePreferredPageSourceForOutputPath as a, resolvePageSourceFileForPath as b, filePathToRoute as f, getPageSourceRootDir as g, pageSourceFileToOutputPath as p, resolveSsgPaths as r, selectPreferredPageSourceFiles as s };
171
+ export { resolvePreferredPageSourceForOutputPath as a, resolveSsgPaths as b, filePathToRoute as f, getPageSourceRootDir as g, pageSourceFileToOutputPath as p, resolvePageSourceFileForPath as r, selectPreferredPageSourceFiles as s };