@ecopages/core 0.2.0-beta.11 → 0.2.0-beta.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/core",
3
- "version": "0.2.0-beta.11",
3
+ "version": "0.2.0-beta.13",
4
4
  "description": "Core package for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -17,7 +17,7 @@
17
17
  "directory": "packages/core"
18
18
  },
19
19
  "dependencies": {
20
- "@ecopages/file-system": "0.2.0-beta.11",
20
+ "@ecopages/file-system": "0.2.0-beta.13",
21
21
  "@ecopages/logger": "^0.2.3",
22
22
  "@ecopages/scripts-injector": "^0.1.5",
23
23
  "@oxc-project/runtime": "0.134.0",
@@ -165,7 +165,7 @@ class BunServerAdapter extends SharedServerAdapter {
165
165
  staticSiteGenerator: this.staticSiteGenerator,
166
166
  serveOptions: this.serveOptions,
167
167
  runtimeOrigin: this.runtimeOrigin,
168
- apiHandlers: this.apiHandlers,
168
+ needsServerBundle: this.apiHandlers.length > 0 || this.websocketHandlers.size > 0,
169
169
  hmrManager: this.hmrManager,
170
170
  onRuntimePlugin: (plugin) => {
171
171
  this.registerBunRuntimePlugin(plugin);
@@ -131,7 +131,7 @@ class NodeServerAdapter extends SharedServerAdapter {
131
131
  staticSiteGenerator: this.staticSiteGenerator,
132
132
  serveOptions: this.serveOptions,
133
133
  runtimeOrigin: this.runtimeOrigin,
134
- apiHandlers: this.apiHandlers,
134
+ needsServerBundle: this.apiHandlers.length > 0 || this.websocketHandlers.size > 0,
135
135
  hmrManager: this.hmrManager ?? void 0
136
136
  });
137
137
  this.initialized = true;
@@ -1,6 +1,6 @@
1
1
  import type { EcoPagesAppConfig, IHmrManager } from '../../types/internal-types.js';
2
2
  import type { EcoBuildPlugin } from '../../build/build-types.js';
3
- import type { ApiHandler, StaticRoute } from '../../types/public-types.js';
3
+ import type { StaticRoute } from '../../types/public-types.js';
4
4
  import type { RouteRegistry } from '../../router/server/route-registry.js';
5
5
  import type { StaticSiteGenerator } from '../../static-site-generator/static-site-generator.js';
6
6
  import type { StaticGenerationRendererResolver } from '../../route-renderer/route-renderer.js';
@@ -17,7 +17,12 @@ export interface ServerStaticBuilderParams {
17
17
  staticSiteGenerator: StaticSiteGenerator;
18
18
  serveOptions: ServeOptions;
19
19
  runtimeOrigin: string;
20
- apiHandlers?: ApiHandler[];
20
+ /**
21
+ * Whether the app requires a server entry bundle for production use.
22
+ * When `true`, the build step bundles the server entry file for `ecopages start`.
23
+ * Defaults to `false` (static-only build, no server needed).
24
+ */
25
+ needsServerBundle?: boolean;
21
26
  logger?: ServerStaticBuilderLogger;
22
27
  entryFile?: string;
23
28
  hmrManager?: IHmrManager;
@@ -39,21 +44,22 @@ export declare class ServerStaticBuilder {
39
44
  private readonly staticSiteGenerator;
40
45
  private readonly serveOptions;
41
46
  private readonly runtimeOrigin;
42
- private readonly apiHandlers;
47
+ private readonly needsServerBundle;
43
48
  private readonly logger;
44
49
  private readonly entryFile;
45
50
  private readonly hmrManager?;
46
51
  private readonly onRuntimePlugin?;
47
- constructor({ appConfig, staticSiteGenerator, serveOptions, runtimeOrigin, apiHandlers, logger, entryFile, hmrManager, onRuntimePlugin, }: ServerStaticBuilderParams);
52
+ constructor({ appConfig, staticSiteGenerator, serveOptions, runtimeOrigin, needsServerBundle, logger, entryFile, hmrManager, onRuntimePlugin, }: ServerStaticBuilderParams);
48
53
  private prepareExportDirectory;
49
54
  private refreshRuntimeAssets;
50
55
  /**
51
56
  * Bundles the server entry file for production use.
52
57
  *
53
58
  * @remarks
54
- * Every production build emits a runnable server entry for `ecopages start`,
55
- * including static-only and websocket-only apps. Incremental builds may skip
56
- * Rolldown when the `.eco/.server-entry` cache is still valid.
59
+ * Only invoked when the app requires a runtime server (API handlers,
60
+ * websocket handlers, etc.). Static-only apps skip this step entirely.
61
+ * Incremental builds may skip Rolldown when the `.eco/.server-entry`
62
+ * cache is still valid.
57
63
  *
58
64
  * Package imports remain external so native addons and runtime-owned
59
65
  * dependencies continue to load through the app's installed
@@ -21,7 +21,7 @@ class ServerStaticBuilder {
21
21
  staticSiteGenerator;
22
22
  serveOptions;
23
23
  runtimeOrigin;
24
- apiHandlers;
24
+ needsServerBundle;
25
25
  logger;
26
26
  entryFile;
27
27
  hmrManager;
@@ -31,7 +31,7 @@ class ServerStaticBuilder {
31
31
  staticSiteGenerator,
32
32
  serveOptions,
33
33
  runtimeOrigin,
34
- apiHandlers,
34
+ needsServerBundle,
35
35
  logger,
36
36
  entryFile,
37
37
  hmrManager,
@@ -41,7 +41,7 @@ class ServerStaticBuilder {
41
41
  this.staticSiteGenerator = staticSiteGenerator;
42
42
  this.serveOptions = serveOptions;
43
43
  this.runtimeOrigin = runtimeOrigin;
44
- this.apiHandlers = apiHandlers ?? [];
44
+ this.needsServerBundle = needsServerBundle ?? false;
45
45
  this.logger = logger ?? appLogger;
46
46
  this.entryFile = resolveEntryFile({ entryFile });
47
47
  this.hmrManager = hmrManager;
@@ -87,9 +87,10 @@ class ServerStaticBuilder {
87
87
  * Bundles the server entry file for production use.
88
88
  *
89
89
  * @remarks
90
- * Every production build emits a runnable server entry for `ecopages start`,
91
- * including static-only and websocket-only apps. Incremental builds may skip
92
- * Rolldown when the `.eco/.server-entry` cache is still valid.
90
+ * Only invoked when the app requires a runtime server (API handlers,
91
+ * websocket handlers, etc.). Static-only apps skip this step entirely.
92
+ * Incremental builds may skip Rolldown when the `.eco/.server-entry`
93
+ * cache is still valid.
93
94
  *
94
95
  * Package imports remain external so native addons and runtime-owned
95
96
  * dependencies continue to load through the app's installed
@@ -166,7 +167,9 @@ ${errorMessages}`);
166
167
  const baseUrl = explicitBaseUrl ?? `http://${this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME}:${this.serveOptions.port || DEFAULT_ECOPAGES_PORT}`;
167
168
  const preserveExportDirectory = this.prepareExportDirectory(force);
168
169
  await this.refreshRuntimeAssets();
169
- await this.bundleServerEntry({ force });
170
+ if (this.needsServerBundle) {
171
+ await this.bundleServerEntry({ force });
172
+ }
170
173
  await this.staticSiteGenerator.run({
171
174
  router: dependencies.router,
172
175
  baseUrl,