@ecopages/core 0.3.0 → 0.3.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 +2 -2
- package/package.json +3 -3
- package/src/adapters/node/create-app.d.ts +40 -11
- package/src/adapters/node/create-app.js +95 -69
- package/src/adapters/node/dev-session.js +0 -1
- package/src/adapters/node/http-request-bridge.d.ts +4 -0
- package/src/adapters/node/http-request-bridge.js +9 -1
- package/src/adapters/node/runtime-host.d.ts +28 -6
- package/src/adapters/node/runtime-host.js +35 -9
- package/src/adapters/node/server-adapter.d.ts +10 -35
- package/src/adapters/node/server-adapter.js +21 -58
- package/src/adapters/shared/hmr/hmr-manager.d.ts +21 -7
- package/src/adapters/shared/hmr/hmr-manager.js +58 -70
- package/src/adapters/shared/http/api-request-pipeline.d.ts +3 -12
- package/src/adapters/shared/http/api-request-pipeline.js +7 -7
- package/src/adapters/shared/http/dist-file-handler.d.ts +16 -0
- package/src/adapters/shared/http/dist-file-handler.js +172 -0
- package/src/adapters/shared/http/explicit-static-route-matcher.js +2 -1
- package/src/adapters/shared/http/fs-server-response-matcher.js +3 -2
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +5 -7
- package/src/adapters/shared/runtime/bind-runtime-server.js +8 -12
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +10 -9
- package/src/adapters/shared/runtime/port-manager.d.ts +8 -11
- package/src/adapters/shared/runtime/port-manager.js +19 -30
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +6 -9
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +2 -5
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +1 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +1 -5
- package/src/adapters/shared/runtime/server-static-builder.d.ts +3 -3
- package/src/adapters/shared/runtime/server-static-builder.js +3 -3
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +2 -1
- package/src/adapters/shared/ws/websocket-lifecycle.d.ts +5 -6
- package/src/adapters/shared/ws/websocket-lifecycle.js +1 -2
- package/src/assets/app-browser-client-build.js +1 -2
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +8 -8
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +4 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +12 -8
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +36 -16
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +11 -6
- package/src/assets/browser-asset-output.d.ts +19 -0
- package/src/assets/browser-asset-output.js +30 -0
- package/src/assets/hashed-browser-asset.d.ts +8 -6
- package/src/assets/hashed-browser-asset.js +8 -6
- package/src/build/build-adapter.d.ts +2 -19
- package/src/build/build-adapter.js +0 -21
- package/src/build/build-graph.js +2 -2
- package/src/build/cache/cache-keys.d.ts +0 -3
- package/src/build/cache/cache-keys.js +0 -14
- package/src/build/cache/pages-unified-graph-build.js +2 -17
- package/src/build/contracts/build-contracts.d.ts +0 -3
- package/src/build/preserve-import-meta-transform.js +2 -2
- package/src/build/rolldown/app-package-declarations.js +3 -3
- package/src/build/rolldown/rolldown-adapter-helpers.js +3 -3
- package/src/build/rolldown/rolldown-build-adapter.d.ts +0 -1
- package/src/build/rolldown/rolldown-build-adapter.js +1 -2
- package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +1 -2
- package/src/build/rolldown/rolldown-build-invocation-metrics.js +5 -12
- package/src/build/rolldown/server-side-css-shim-plugin.js +3 -3
- package/src/build/runtime/build-queue.d.ts +8 -13
- package/src/build/runtime/build-queue.js +6 -17
- package/src/build/server/app-module-loader.service.d.ts +1 -1
- package/src/build/server/app-module-loader.service.js +0 -2
- package/src/build/server/page-module-import.service.d.ts +2 -3
- package/src/build/server/page-module-import.service.js +3 -4
- package/src/build/server-bundle-deploy-manifest.d.ts +5 -0
- package/src/build/server-bundle-deploy-manifest.js +15 -1
- package/src/build/server-bundle-publication.js +4 -5
- package/src/build.d.ts +2 -2
- package/src/build.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +2 -2
- package/src/config/assembly/app-runtime.js +2 -2
- package/src/config/assembly/finalize-config.d.ts +4 -4
- package/src/config/assembly/finalize-config.js +4 -5
- package/src/config/config-module-files.js +2 -3
- package/src/config/internal-types.d.ts +0 -7
- package/src/config/user-config-types.d.ts +0 -4
- package/src/diagnostics/request-pipeline-metrics.d.ts +3 -3
- package/src/diagnostics/request-pipeline-metrics.js +4 -4
- package/src/diagnostics/startup-trace.js +2 -5
- package/src/errors/http-error.d.ts +2 -2
- package/src/errors/http-error.js +4 -4
- package/src/hmr/client/hmr-runtime.js +16 -7
- package/src/hmr/client/module-update.d.ts +7 -0
- package/src/hmr/client/module-update.js +21 -4
- package/src/hmr/hmr-strategy.d.ts +0 -3
- package/src/hmr/hmr-strategy.js +0 -3
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -3
- package/src/hmr/strategies/js-hmr-strategy.js +3 -6
- package/src/html-pages/html-page-module-scripts.js +4 -3
- package/src/html-pages/html-page-renderer.js +2 -3
- package/src/plugins/alias-resolver-cache.d.ts +4 -3
- package/src/plugins/alias-resolver-cache.js +4 -3
- package/src/plugins/component-import-discovery.js +4 -4
- package/src/plugins/eco-component-meta-plugin.d.ts +10 -1
- package/src/plugins/eco-component-meta-plugin.js +66 -10
- package/src/plugins/foreign-jsx-override-plugin.js +4 -3
- package/src/plugins/tsconfig-import-resolver.js +12 -12
- package/src/route-renderer/error-pages/default-error-pages.js +2 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -1
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +0 -1
- package/src/route-renderer/orchestration/integration-renderer.d.ts +10 -5
- package/src/route-renderer/orchestration/integration-renderer.js +13 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -23
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +0 -29
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +10 -32
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +2 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +5 -5
- package/src/route-renderer/page-loading/page-module-loader.js +1 -1
- package/src/route-renderer/route-renderer.d.ts +2 -5
- package/src/route-renderer/route-renderer.js +2 -4
- package/src/router/client/link-navigation-policy.d.ts +4 -1
- package/src/router/client/link-navigation-policy.js +20 -6
- package/src/router/server/route-registry.d.ts +0 -1
- package/src/router/server/route-registry.js +3 -13
- package/src/router/server/segment-path-matcher.d.ts +12 -0
- package/src/router/server/segment-path-matcher.js +30 -0
- package/src/static-site-generator/static-site-generator.d.ts +0 -5
- package/src/static-site-generator/static-site-generator.js +2 -15
- package/src/types/contracts.d.ts +17 -27
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/format-error-chain.d.ts +9 -0
- package/src/utils/format-error-chain.js +20 -0
- package/src/utils/invariant.d.ts +6 -1
- package/src/utils/invariant.js +7 -2
- package/src/watchers/project-watcher.d.ts +20 -1
- package/src/watchers/project-watcher.js +40 -9
- package/src/watchers/workspace-package-watch-roots.js +5 -5
- package/src/adapters/README.md +0 -58
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +0 -28
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +0 -53
- package/src/adapters/shared/runtime/runtime-host.d.ts +0 -15
- package/src/adapters/shared/runtime/runtime-host.js +0 -1
- package/src/assets/README.md +0 -35
- package/src/build/README.md +0 -298
- package/src/build/server/README.md +0 -50
- package/src/cache/README.md +0 -5
- package/src/client/README.md +0 -5
- package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +0 -1
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +0 -111
- package/src/client/scroll.test.browser.d.ts +0 -1
- package/src/client/scroll.test.browser.js +0 -31
- package/src/client/view-transitions.test.browser.d.ts +0 -1
- package/src/client/view-transitions.test.browser.js +0 -53
- package/src/config/README.md +0 -58
- package/src/config/constants.d.ts +0 -1
- package/src/config/constants.js +0 -1
- package/src/dev/README.md +0 -61
- package/src/dev/invalidation/README.md +0 -11
- package/src/dev-toolbar/README.md +0 -66
- package/src/diagnostics/README.md +0 -11
- package/src/eco/README.md +0 -776
- package/src/errors/README.md +0 -5
- package/src/global/README.md +0 -5
- package/src/hmr/README.md +0 -64
- package/src/hmr/client/build-error-overlay.test.browser.d.ts +0 -1
- package/src/hmr/client/build-error-overlay.test.browser.js +0 -48
- package/src/hmr/client/hmr-runtime.test.browser.d.ts +0 -1
- package/src/hmr/client/hmr-runtime.test.browser.js +0 -32
- package/src/hmr/entrypoint-dependency-graph.d.ts +0 -12
- package/src/hmr/entrypoint-dependency-graph.js +0 -27
- package/src/hmr/hmr-file-change-prep.d.ts +0 -9
- package/src/hmr/hmr-file-change-prep.js +0 -11
- package/src/html/README.md +0 -15
- package/src/html-pages/README.md +0 -104
- package/src/islands/README.md +0 -44
- package/src/page-cache/README.md +0 -17
- package/src/plugins/README.md +0 -53
- package/src/route-renderer/GRAPH.md +0 -142
- package/src/route-renderer/README.md +0 -160
- package/src/route-renderer/error-pages/README.md +0 -11
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +0 -15
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +0 -39
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +0 -94
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +0 -35
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +0 -69
- package/src/router/README.md +0 -160
- package/src/router/client/link-intent.test.browser.d.ts +0 -1
- package/src/router/client/link-intent.test.browser.js +0 -33
- package/src/router/client/link-navigation-policy.test.browser.d.ts +0 -1
- package/src/router/client/link-navigation-policy.test.browser.js +0 -142
- package/src/router/client/navigation-commit.test.browser.d.ts +0 -1
- package/src/router/client/navigation-commit.test.browser.js +0 -116
- package/src/router/client/navigation-document.test.browser.d.ts +0 -1
- package/src/router/client/navigation-document.test.browser.js +0 -77
- package/src/router/client/navigation-head.test.browser.d.ts +0 -1
- package/src/router/client/navigation-head.test.browser.js +0 -101
- package/src/router/client/navigation-lifecycle.test.browser.d.ts +0 -1
- package/src/router/client/navigation-lifecycle.test.browser.js +0 -97
- package/src/router/client/navigation-view-transition.test.browser.d.ts +0 -1
- package/src/router/client/navigation-view-transition.test.browser.js +0 -189
- package/src/router/client/staged-stylesheets.test-fixtures.d.ts +0 -18
- package/src/router/client/staged-stylesheets.test-fixtures.js +0 -31
- package/src/static-site-generator/README.md +0 -67
- package/src/static-site-generator/static-site-generator.test-utils.d.ts +0 -2
- package/src/static-site-generator/static-site-generator.test-utils.js +0 -41
- package/src/types/README.md +0 -5
- package/src/utils/README.md +0 -7
- package/src/validation/README.md +0 -9
- package/src/watchers/README.md +0 -15
- package/src/watchers/project-watcher.test-helpers.d.ts +0 -60
- package/src/watchers/project-watcher.test-helpers.js +0 -108
|
@@ -17,7 +17,7 @@ import { buildOrThrow } from '../runtime/build-queue.js';
|
|
|
17
17
|
import { createServerBuildRequest, resolveAppBuildPlugins } from '../runtime/build-request-policy.js';
|
|
18
18
|
import { hashAppConfigFile } from './app-config-hash.js';
|
|
19
19
|
import { collectBuildOutputImports, getBuildEntryOutput } from '../build-graph.js';
|
|
20
|
-
import { getServerModuleBuildCacheOutdir
|
|
20
|
+
import { getServerModuleBuildCacheOutdir } from '../server/route-module-build-cache-registry.js';
|
|
21
21
|
import { RouteModuleDependencyHasher, resolveRouteModuleDependencyPaths, } from '../server/route-module-dependency-hasher.js';
|
|
22
22
|
/**
|
|
23
23
|
* True when the unified graph should build or serve prebuilt page modules.
|
|
@@ -128,7 +128,6 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
128
128
|
appLogger.debug('Reusing pages unified graph built in this process');
|
|
129
129
|
return existingManifest;
|
|
130
130
|
}
|
|
131
|
-
const routeModuleBuildCache = getSharedRouteModuleBuildCache(outdir, options.appConfig);
|
|
132
131
|
const entryRecord = {};
|
|
133
132
|
for (const entryPath of eligibleEntryPaths) {
|
|
134
133
|
const entryKey = createSafeGraphEntryKey(entryPath, options.appConfig.rootDir);
|
|
@@ -141,7 +140,6 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
141
140
|
splitting: true,
|
|
142
141
|
naming: '[name]-[hash].[ext]',
|
|
143
142
|
});
|
|
144
|
-
const plugins = buildOptions.plugins ?? [];
|
|
145
143
|
const buildResult = await buildOrThrow(options.appConfig, buildOptions, 'Pages unified graph build failed').finally(() => appLogger.debugTimeEnd('pagesUnifiedGraphBuild'));
|
|
146
144
|
const outputs = {};
|
|
147
145
|
const outputImports = new Set();
|
|
@@ -154,24 +152,11 @@ export async function ensurePagesUnifiedGraphBuilt(options) {
|
|
|
154
152
|
throw new Error(`Pages unified graph build produced no output for ${entryPath}`);
|
|
155
153
|
}
|
|
156
154
|
outputs[entryPath] = compiledOutput;
|
|
157
|
-
const
|
|
158
|
-
for (const importPath of compiledOutputImports)
|
|
155
|
+
for (const importPath of collectBuildOutputImports(buildResult, compiledOutput))
|
|
159
156
|
outputImports.add(importPath);
|
|
160
157
|
const dependencyModulePaths = resolveRouteModuleDependencyPaths(buildResult, entryPath, options.appConfig.rootDir);
|
|
161
158
|
Object.assign(dependencyHashes, dependencyHasher.createDependencyHashes(dependencyModulePaths));
|
|
162
159
|
dependencyHashes[path.normalize(entryPath)] = fileHash;
|
|
163
|
-
routeModuleBuildCache.recordBuild({
|
|
164
|
-
filePath: entryPath,
|
|
165
|
-
rootDir: options.appConfig.rootDir,
|
|
166
|
-
outdir,
|
|
167
|
-
buildOptions,
|
|
168
|
-
fileHash,
|
|
169
|
-
outputPath: compiledOutput,
|
|
170
|
-
dependencyModulePaths,
|
|
171
|
-
externalPackages: true,
|
|
172
|
-
plugins,
|
|
173
|
-
outputImports: compiledOutputImports,
|
|
174
|
-
});
|
|
175
160
|
}
|
|
176
161
|
const manifest = {
|
|
177
162
|
buildKey: createPagesUnifiedGraphBuildKey(options.appConfig, outdir),
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
|
-
/** The bundler that owns the app's build pipeline. */
|
|
3
|
-
export type BuildOwnership = 'rolldown';
|
|
4
2
|
/** A single artifact emitted by the build backend. */
|
|
5
3
|
export interface BuildOutput {
|
|
6
4
|
path: string;
|
|
@@ -147,7 +145,6 @@ export interface BuildTranspileOptions {
|
|
|
147
145
|
}
|
|
148
146
|
/** Low-level build backend contract. */
|
|
149
147
|
export interface BuildAdapter {
|
|
150
|
-
readonly ownership?: BuildOwnership;
|
|
151
148
|
build(options: BuildOptions): Promise<BuildResult>;
|
|
152
149
|
resolve(importPath: string, rootDir: string): string;
|
|
153
150
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { realpathSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
2
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
4
|
import { createCoreTransformPlugin, createMappedSourceTransformResult } from './mapped-source-transform.js';
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ import { createCoreTransformPlugin, createMappedSourceTransformResult } from './
|
|
|
13
13
|
*/
|
|
14
14
|
export function realpathOfDirectory(dir) {
|
|
15
15
|
try {
|
|
16
|
-
return
|
|
16
|
+
return fileSystem.realpath(dir);
|
|
17
17
|
}
|
|
18
18
|
catch {
|
|
19
19
|
const parent = path.dirname(dir);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
2
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { toPackageRootSpecifier } from '../../plugins/package-specifier.js';
|
|
4
4
|
const appDeclaredPackageCache = new Map();
|
|
5
5
|
const appWorkspacePackageCache = new Map();
|
|
@@ -12,7 +12,7 @@ function getDeclaredAppPackages(rootDir) {
|
|
|
12
12
|
const packageJsonPath = path.resolve(rootDir, 'package.json');
|
|
13
13
|
const declaredPackages = new Set();
|
|
14
14
|
try {
|
|
15
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath
|
|
15
|
+
const packageJson = JSON.parse(fileSystem.readFileSync(packageJsonPath));
|
|
16
16
|
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
17
17
|
const entries = packageJson[field];
|
|
18
18
|
if (!entries || typeof entries !== 'object') {
|
|
@@ -47,7 +47,7 @@ function getWorkspacePackages(rootDir) {
|
|
|
47
47
|
const packageJsonPath = path.resolve(rootDir, 'package.json');
|
|
48
48
|
const workspacePackages = new Set();
|
|
49
49
|
try {
|
|
50
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath
|
|
50
|
+
const packageJson = JSON.parse(fileSystem.readFileSync(packageJsonPath));
|
|
51
51
|
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
52
52
|
const entries = packageJson[field];
|
|
53
53
|
if (!entries || typeof entries !== 'object') {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import { builtinModules, createRequire } from 'node:module';
|
|
13
|
-
import { readFileSync } from 'node:fs';
|
|
14
13
|
import path from 'node:path';
|
|
14
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
15
15
|
import { fileURLToPath } from 'node:url';
|
|
16
16
|
import { stripVTControlCharacters } from 'node:util';
|
|
17
17
|
import { recordBuildEntryOutput, resolveBuildEntryPath } from '../build-graph.js';
|
|
@@ -43,10 +43,10 @@ function getCorePackageNames() {
|
|
|
43
43
|
if (corePackageNames) {
|
|
44
44
|
return corePackageNames;
|
|
45
45
|
}
|
|
46
|
-
const packageJsonPath = new URL('../../../package.json', import.meta.url);
|
|
46
|
+
const packageJsonPath = fileURLToPath(new URL('../../../package.json', import.meta.url));
|
|
47
47
|
corePackageNames = new Set();
|
|
48
48
|
try {
|
|
49
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath
|
|
49
|
+
const packageJson = JSON.parse(fileSystem.readFileSync(packageJsonPath));
|
|
50
50
|
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
51
51
|
const entries = packageJson[field];
|
|
52
52
|
if (!entries || typeof entries !== 'object') {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { BuildAdapter, BuildOptions, BuildResult, BuildSuccess } from '../build-adapter.js';
|
|
12
12
|
export declare class RolldownBuildAdapter implements BuildAdapter {
|
|
13
|
-
readonly ownership: "rolldown";
|
|
14
13
|
/** Per-adapter require cache, keyed on resolved context root. */
|
|
15
14
|
private readonly appRootRequireCache;
|
|
16
15
|
/**
|
|
@@ -17,7 +17,6 @@ import { createEntryModuleClosuresPlugin } from './entry-module-closures.js';
|
|
|
17
17
|
import { createBuildInputRecorder, getBuildInputRecordingContext } from '../cache/build-input-dependency-index.js';
|
|
18
18
|
const moduleRequire = createRequire(import.meta.url);
|
|
19
19
|
export class RolldownBuildAdapter {
|
|
20
|
-
ownership = 'rolldown';
|
|
21
20
|
/** Per-adapter require cache, keyed on resolved context root. */
|
|
22
21
|
appRootRequireCache = new Map();
|
|
23
22
|
/**
|
|
@@ -31,7 +30,7 @@ export class RolldownBuildAdapter {
|
|
|
31
30
|
if (options.environment !== 'server' && options.environment !== 'browser') {
|
|
32
31
|
throw new Error('Build requests require environment: "server" or "browser".');
|
|
33
32
|
}
|
|
34
|
-
recordRolldownBuildInvocation(
|
|
33
|
+
recordRolldownBuildInvocation();
|
|
35
34
|
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
36
35
|
const outdir = path.resolve(options.outdir ?? 'dist/assets');
|
|
37
36
|
const recordingContext = getBuildInputRecordingContext();
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* Gated behind {@link isRolldownBuildMetricsEnabled} so production paths stay quiet.
|
|
5
5
|
*/
|
|
6
6
|
export declare function isRolldownBuildMetricsEnabled(): boolean;
|
|
7
|
-
export declare function recordRolldownBuildInvocation(
|
|
8
|
-
export declare function getRolldownBuildInvocationCounts(): Readonly<Record<string, number>>;
|
|
7
|
+
export declare function recordRolldownBuildInvocation(): void;
|
|
9
8
|
export declare function resetRolldownBuildInvocationCounts(): void;
|
|
10
9
|
export declare function recordPageModuleBuildInvocation(): void;
|
|
11
10
|
export declare function getPageModuleRolldownBuildInvocations(): number;
|
|
@@ -4,22 +4,19 @@
|
|
|
4
4
|
* Gated behind {@link isRolldownBuildMetricsEnabled} so production paths stay quiet.
|
|
5
5
|
*/
|
|
6
6
|
import { isEcopagesEnvEnabled } from '../../env.js';
|
|
7
|
-
|
|
7
|
+
let buildInvocations = 0;
|
|
8
8
|
let pageModuleBuildInvocations = 0;
|
|
9
9
|
export function isRolldownBuildMetricsEnabled() {
|
|
10
10
|
return isEcopagesEnvEnabled('ECOPAGES_ROLLDOWN_BUILD_METRICS') || isEcopagesEnvEnabled('ECOPAGES_LOGGER_DEBUG');
|
|
11
11
|
}
|
|
12
|
-
export function recordRolldownBuildInvocation(
|
|
12
|
+
export function recordRolldownBuildInvocation() {
|
|
13
13
|
if (!isRolldownBuildMetricsEnabled()) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export function getRolldownBuildInvocationCounts() {
|
|
19
|
-
return Object.fromEntries(invocationCounts);
|
|
16
|
+
buildInvocations += 1;
|
|
20
17
|
}
|
|
21
18
|
export function resetRolldownBuildInvocationCounts() {
|
|
22
|
-
|
|
19
|
+
buildInvocations = 0;
|
|
23
20
|
pageModuleBuildInvocations = 0;
|
|
24
21
|
}
|
|
25
22
|
export function recordPageModuleBuildInvocation() {
|
|
@@ -32,9 +29,5 @@ export function getPageModuleRolldownBuildInvocations() {
|
|
|
32
29
|
return pageModuleBuildInvocations;
|
|
33
30
|
}
|
|
34
31
|
export function getTotalRolldownBuildInvocations() {
|
|
35
|
-
|
|
36
|
-
for (const count of invocationCounts.values()) {
|
|
37
|
-
total += count;
|
|
38
|
-
}
|
|
39
|
-
return total;
|
|
32
|
+
return buildInvocations;
|
|
40
33
|
}
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* and continue to declare stylesheets in `dependencies.stylesheets`
|
|
21
21
|
* — the shim is intentionally inert for those flows.
|
|
22
22
|
*/
|
|
23
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
24
23
|
import path from 'node:path';
|
|
24
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
25
25
|
import { id as idFilter, include } from 'rolldown/filter';
|
|
26
26
|
const CSS_PATH = /\.css$/u;
|
|
27
27
|
const CSS_QUERY = '?ecopages-css-shim';
|
|
@@ -41,13 +41,13 @@ export function createServerSideCssShimPlugin() {
|
|
|
41
41
|
filter: [include(idFilter(CSS_PATH))],
|
|
42
42
|
handler(source, importer) {
|
|
43
43
|
const resolved = importer ? path.resolve(path.dirname(importer), source) : path.resolve(source);
|
|
44
|
-
return
|
|
44
|
+
return fileSystem.exists(resolved) ? `${resolved}${CSS_QUERY}` : null;
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
load: {
|
|
48
48
|
filter: [include(idFilter(CSS_SHIM_ID))],
|
|
49
49
|
handler(id) {
|
|
50
|
-
readFileSync(stripShimQuery(id)
|
|
50
|
+
fileSystem.readFileSync(stripShimQuery(id));
|
|
51
51
|
return {
|
|
52
52
|
code: 'export default "";',
|
|
53
53
|
moduleType: 'js',
|
|
@@ -11,16 +11,18 @@ import type { BuildAdapter, BuildExecutor, BuildOptions, BuildResult, BuildSucce
|
|
|
11
11
|
* `nested` is for a build that a running build waits for, such as the collection bundle a content plugin's
|
|
12
12
|
* `onResolve` hook triggers. A running build holds its lane's slot until it ends, so a build it waits for in the
|
|
13
13
|
* same lane could wait for a slot that its own parent holds, and with every slot taken that way none would ever free.
|
|
14
|
-
*
|
|
14
|
+
* The `nested` lane has no limit: a `nested` build starts at once, even one that another `nested` build waits for.
|
|
15
|
+
* The limited lane of the build at the top of each chain bounds how many run.
|
|
15
16
|
*/
|
|
16
17
|
export type BuildLane = 'build' | 'hmr' | 'nested';
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
type LimitedLane = Exclude<BuildLane, 'nested'>;
|
|
19
|
+
/** Concurrency each limited lane gets on this machine. */
|
|
20
|
+
export declare function resolveBuildLaneLimits(): Record<LimitedLane, number>;
|
|
19
21
|
/**
|
|
20
22
|
* The one queue every build of an app goes through.
|
|
21
23
|
*
|
|
22
24
|
* @remarks
|
|
23
|
-
*
|
|
25
|
+
* The `build` and `hmr` lanes each run at most their limit of builds at once and start the rest in arrival order. A request identical to one
|
|
24
26
|
* that is queued or running, by {@link createBuildRequestIdentity}, shares that build and its result whichever lane
|
|
25
27
|
* it asks for. Inside {@link BuildQueue.withRequestScope}, a finished build is also shared with later identical
|
|
26
28
|
* requests of the same scope, so one page request that asks for the same bundle twice builds it once. A build that
|
|
@@ -34,7 +36,7 @@ export declare class BuildQueue implements BuildExecutor {
|
|
|
34
36
|
private readonly lanes;
|
|
35
37
|
private readonly inFlight;
|
|
36
38
|
private readonly requestScope;
|
|
37
|
-
constructor(adapter: BuildAdapter, limits?: Record<
|
|
39
|
+
constructor(adapter: BuildAdapter, limits?: Record<LimitedLane, number>);
|
|
38
40
|
build(options: BuildOptions, lane?: BuildLane): Promise<BuildResult>;
|
|
39
41
|
/** Shares finished builds between identical requests made while `operation` runs. */
|
|
40
42
|
withRequestScope<T>(operation: () => Promise<T>): Promise<T>;
|
|
@@ -46,14 +48,6 @@ export declare class BuildQueue implements BuildExecutor {
|
|
|
46
48
|
* @throws When `appConfig` skipped finalization.
|
|
47
49
|
*/
|
|
48
50
|
export declare function requireBuildQueue(appConfig: EcoPagesAppConfig): BuildQueue;
|
|
49
|
-
/**
|
|
50
|
-
* Installs a fresh build queue on the app's {@link AppRuntime}.
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* The queue builds with the app's installed {@link BuildAdapter}. Startup installs a queue again after
|
|
54
|
-
* finalization, so an assembled {@link AppRuntime} takes that later queue instead of keeping the first one.
|
|
55
|
-
*/
|
|
56
|
-
export declare function installBuildQueue(appConfig: EcoPagesAppConfig): BuildQueue;
|
|
57
51
|
/**
|
|
58
52
|
* Builds on the app's queue and throws, with the formatted build logs, when the build fails.
|
|
59
53
|
*
|
|
@@ -61,3 +55,4 @@ export declare function installBuildQueue(appConfig: EcoPagesAppConfig): BuildQu
|
|
|
61
55
|
* Use it where a failed build is an error; read `BuildResult` from the queue directly where a failure is handled.
|
|
62
56
|
*/
|
|
63
57
|
export declare function buildOrThrow(appConfig: EcoPagesAppConfig, options: BuildOptions, failure: string | ((details: string) => string), lane?: BuildLane): Promise<BuildSuccess>;
|
|
58
|
+
export {};
|
|
@@ -3,16 +3,16 @@ import { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
|
3
3
|
import { resolveBuildParallelism } from '../build-parallelism.js';
|
|
4
4
|
import { assertBuildSucceeded } from '../build-log.js';
|
|
5
5
|
import { createBuildRequestIdentity } from './build-request-identity.js';
|
|
6
|
-
/** Concurrency each lane gets on this machine. */
|
|
6
|
+
/** Concurrency each limited lane gets on this machine. */
|
|
7
7
|
export function resolveBuildLaneLimits() {
|
|
8
8
|
const build = resolveBuildParallelism();
|
|
9
|
-
return { build, hmr: Math.min(3, build)
|
|
9
|
+
return { build, hmr: Math.min(3, build) };
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* The one queue every build of an app goes through.
|
|
13
13
|
*
|
|
14
14
|
* @remarks
|
|
15
|
-
*
|
|
15
|
+
* The `build` and `hmr` lanes each run at most their limit of builds at once and start the rest in arrival order. A request identical to one
|
|
16
16
|
* that is queued or running, by {@link createBuildRequestIdentity}, shares that build and its result whichever lane
|
|
17
17
|
* it asks for. Inside {@link BuildQueue.withRequestScope}, a finished build is also shared with later identical
|
|
18
18
|
* requests of the same scope, so one page request that asks for the same bundle twice builds it once. A build that
|
|
@@ -31,7 +31,6 @@ export class BuildQueue {
|
|
|
31
31
|
this.lanes = {
|
|
32
32
|
build: { limit: Math.max(1, limits.build), active: 0, waiting: [] },
|
|
33
33
|
hmr: { limit: Math.max(1, limits.hmr), active: 0, waiting: [] },
|
|
34
|
-
nested: { limit: Math.max(1, limits.nested), active: 0, waiting: [] },
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
build(options, lane = 'build') {
|
|
@@ -62,6 +61,9 @@ export class BuildQueue {
|
|
|
62
61
|
return this.requestScope.getStore() ? operation() : this.requestScope.run(new Map(), operation);
|
|
63
62
|
}
|
|
64
63
|
async run(lane, options) {
|
|
64
|
+
if (lane === 'nested') {
|
|
65
|
+
return this.adapter.build(options);
|
|
66
|
+
}
|
|
65
67
|
const state = this.lanes[lane];
|
|
66
68
|
if (state.active < state.limit) {
|
|
67
69
|
state.active += 1;
|
|
@@ -91,19 +93,6 @@ export class BuildQueue {
|
|
|
91
93
|
export function requireBuildQueue(appConfig) {
|
|
92
94
|
return requireAppRuntime(appConfig).buildQueue;
|
|
93
95
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Installs a fresh build queue on the app's {@link AppRuntime}.
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* The queue builds with the app's installed {@link BuildAdapter}. Startup installs a queue again after
|
|
99
|
-
* finalization, so an assembled {@link AppRuntime} takes that later queue instead of keeping the first one.
|
|
100
|
-
*/
|
|
101
|
-
export function installBuildQueue(appConfig) {
|
|
102
|
-
const runtime = requireAppRuntime(appConfig);
|
|
103
|
-
const buildQueue = new BuildQueue(runtime.buildAdapter);
|
|
104
|
-
runtime.buildQueue = buildQueue;
|
|
105
|
-
return buildQueue;
|
|
106
|
-
}
|
|
107
96
|
/**
|
|
108
97
|
* Builds on the app's queue and throws, with the formatted build logs, when the build fails.
|
|
109
98
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageModuleBuildImportOptions } from './page-module-import.service.js';
|
|
2
2
|
import type { EcoPagesAppConfig } from '../../config/internal-types.js';
|
|
3
|
-
export type AppModuleImportOptions = Omit<PageModuleBuildImportOptions, '
|
|
3
|
+
export type AppModuleImportOptions = Omit<PageModuleBuildImportOptions, 'rootDir'>;
|
|
4
4
|
export interface AppModuleLoaderContract {
|
|
5
5
|
importModule<T = unknown>(options: AppModuleImportOptions): Promise<T>;
|
|
6
6
|
invalidateDevelopmentGraph(): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { requireBuildQueue } from '../../build/runtime/build-queue.js';
|
|
2
1
|
import { PageModuleImportService } from './page-module-import.service.js';
|
|
3
2
|
/**
|
|
4
3
|
* Owns app-scoped server source imports and development invalidation.
|
|
@@ -18,7 +17,6 @@ export class AppModuleLoader {
|
|
|
18
17
|
return await this.pageModuleImportService.importModule({
|
|
19
18
|
...options,
|
|
20
19
|
rootDir: this.appConfig.rootDir,
|
|
21
|
-
buildExecutor: requireBuildQueue(this.appConfig),
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
invalidateDevelopmentGraph() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BuildOptions, type BuildResult } from '../../build/build-adapter.js';
|
|
2
2
|
import type { EcoBuildPlugin } from '../../build/contracts/build-types.js';
|
|
3
3
|
import type { EcoPagesAppConfig } from '../../config/internal-types.js';
|
|
4
4
|
interface PageModuleImportBaseOptions {
|
|
@@ -15,7 +15,6 @@ interface PageModuleImportBaseOptions {
|
|
|
15
15
|
export interface PageModuleBuildImportOptions extends PageModuleImportBaseOptions {
|
|
16
16
|
rootDir: string;
|
|
17
17
|
outdir: string;
|
|
18
|
-
buildExecutor?: BuildExecutor;
|
|
19
18
|
splitting?: boolean;
|
|
20
19
|
externalPackages?: boolean;
|
|
21
20
|
jsx?: {
|
|
@@ -40,7 +39,7 @@ export interface PageModuleBuildImportOptions extends PageModuleImportBaseOption
|
|
|
40
39
|
*/
|
|
41
40
|
export interface PageModuleImportDependencies {
|
|
42
41
|
hashFile(filePath: string): string;
|
|
43
|
-
buildModule(options: BuildOptions
|
|
42
|
+
buildModule(options: BuildOptions): Promise<BuildResult>;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
45
|
* Loads page-like modules through the Ecopages build pipeline.
|
|
@@ -36,8 +36,7 @@ export class PageModuleImportService {
|
|
|
36
36
|
this.appConfig = appConfig;
|
|
37
37
|
this.dependencies = {
|
|
38
38
|
hashFile: dependencies?.hashFile ?? ((filePath) => fileSystem.hash(filePath)),
|
|
39
|
-
buildModule: dependencies?.buildModule ??
|
|
40
|
-
((options, buildExecutor) => (buildExecutor ?? requireBuildQueue(this.appConfig)).build(options)),
|
|
39
|
+
buildModule: dependencies?.buildModule ?? ((options) => requireBuildQueue(this.appConfig).build(options)),
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
@@ -176,7 +175,7 @@ export class PageModuleImportService {
|
|
|
176
175
|
}
|
|
177
176
|
this.registerRouteModuleDependencies(cacheBuildOptions.filePath, Object.keys(cachedBuild.entry.dependencyHashes ?? {}));
|
|
178
177
|
const loadedModule = (await import(/* @vite-ignore */ pathToFileURL(cachedBuild.outputPath).href));
|
|
179
|
-
this.recordPipelineLoad('
|
|
178
|
+
this.recordPipelineLoad('route-module-cache-hit');
|
|
180
179
|
return loadedModule;
|
|
181
180
|
}
|
|
182
181
|
async tryLoadPagesUnifiedGraphModule(filePath) {
|
|
@@ -235,7 +234,7 @@ export class PageModuleImportService {
|
|
|
235
234
|
return unifiedGraphModule;
|
|
236
235
|
}
|
|
237
236
|
recordPageModuleBuildInvocation();
|
|
238
|
-
const buildResult = await this.dependencies.buildModule(buildOptions
|
|
237
|
+
const buildResult = await this.dependencies.buildModule(buildOptions);
|
|
239
238
|
assertBuildSucceeded(buildResult, transpileErrorMessage);
|
|
240
239
|
this.recordPipelineLoad('cold-build', buildResult.outputs.length);
|
|
241
240
|
const compiledOutput = this.resolveCompiledRouteModuleOutput(buildResult, filePath, resolvedRootDir, noOutputMessage);
|
|
@@ -42,6 +42,11 @@ export declare function writeServerBundleDeployManifest(appConfig: EcoPagesAppCo
|
|
|
42
42
|
* not, and need `--dist-dir`. Guessing between several would run a stale bundle from an earlier build
|
|
43
43
|
* that used another `distDir`.
|
|
44
44
|
*
|
|
45
|
+
* Static-only apps (no API or WebSocket handlers) build no server bundle. When the selected output, or `dist`
|
|
46
|
+
* when none is named, holds built HTML but no bundle, the error says so and points to `ecopages preview`
|
|
47
|
+
* instead of asking for another build. A static-only build in a custom `distDir` needs `--dist-dir` to be
|
|
48
|
+
* recognised.
|
|
49
|
+
*
|
|
45
50
|
* @param options.cwd - Project root.
|
|
46
51
|
* @param options.distDir - Directory named with `--dist-dir`, relative to `cwd`.
|
|
47
52
|
* @returns The absolute path of the build output directory.
|
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
import { SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from '../utils/resolve-entry-file.js';
|
|
5
5
|
const SERVER_BUNDLE_MANIFEST_FILENAME = 'manifest.json';
|
|
6
|
+
const DEFAULT_DIST_DIR = 'dist';
|
|
6
7
|
export function getServerBundleOutputPaths(appConfig) {
|
|
7
8
|
const distDir = appConfig.absolutePaths?.distDir ?? path.join(appConfig.rootDir, appConfig.distDir);
|
|
8
9
|
const serverOutdir = path.join(distDir, SERVER_BUNDLE_DIR);
|
|
@@ -71,6 +72,11 @@ function readServerBundleDeployManifest(serverDir) {
|
|
|
71
72
|
* not, and need `--dist-dir`. Guessing between several would run a stale bundle from an earlier build
|
|
72
73
|
* that used another `distDir`.
|
|
73
74
|
*
|
|
75
|
+
* Static-only apps (no API or WebSocket handlers) build no server bundle. When the selected output, or `dist`
|
|
76
|
+
* when none is named, holds built HTML but no bundle, the error says so and points to `ecopages preview`
|
|
77
|
+
* instead of asking for another build. A static-only build in a custom `distDir` needs `--dist-dir` to be
|
|
78
|
+
* recognised.
|
|
79
|
+
*
|
|
74
80
|
* @param options.cwd - Project root.
|
|
75
81
|
* @param options.distDir - Directory named with `--dist-dir`, relative to `cwd`.
|
|
76
82
|
* @returns The absolute path of the build output directory.
|
|
@@ -78,10 +84,14 @@ function readServerBundleDeployManifest(serverDir) {
|
|
|
78
84
|
export async function resolveProductionDistDir(options = {}) {
|
|
79
85
|
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
80
86
|
const describe = (distDir) => path.relative(cwd, distDir) || '.';
|
|
87
|
+
const staticOnlyError = (distDir) => new Error(`${describe(distDir)}/ holds a static-only build: it has no server bundle, so \`ecopages start\` cannot run it. Serve it with \`ecopages preview\` or deploy ${describe(distDir)}/ to a static host.`);
|
|
88
|
+
const holdsBuiltHtml = (distDir) => fileSystem.exists(path.join(distDir, 'index.html'));
|
|
81
89
|
if (options.distDir !== undefined) {
|
|
82
90
|
const distDir = path.resolve(cwd, options.distDir);
|
|
83
91
|
if (!fileSystem.exists(path.join(resolveServerBundleDir(cwd, distDir), SERVER_BUNDLE_MANIFEST_FILENAME))) {
|
|
84
|
-
throw
|
|
92
|
+
throw holdsBuiltHtml(distDir)
|
|
93
|
+
? staticOnlyError(distDir)
|
|
94
|
+
: new Error(`No production bundle found in ${describe(distDir)}/${SERVER_BUNDLE_DIR}. Run \`ecopages build\` first.`);
|
|
85
95
|
}
|
|
86
96
|
return distDir;
|
|
87
97
|
}
|
|
@@ -93,6 +103,10 @@ export async function resolveProductionDistDir(options = {}) {
|
|
|
93
103
|
throw new Error(`Multiple production bundles found: ${distDirs.map(describe).join(', ')}. Pass --dist-dir <dir> to select one.`);
|
|
94
104
|
}
|
|
95
105
|
if (distDirs.length === 0) {
|
|
106
|
+
const defaultDistDir = path.join(cwd, DEFAULT_DIST_DIR);
|
|
107
|
+
if (holdsBuiltHtml(defaultDistDir)) {
|
|
108
|
+
throw staticOnlyError(defaultDistDir);
|
|
109
|
+
}
|
|
96
110
|
throw new Error('No production bundle found. Run `ecopages build` before starting in production mode, or pass --dist-dir <dir> for an output that is not a direct subdirectory.');
|
|
97
111
|
}
|
|
98
112
|
return distDirs[0];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdtempSync, renameSync } from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
5
4
|
/** Creates a sibling staging directory so publication stays on one filesystem. */
|
|
6
5
|
export function createServerBundleStagingDirectory(serverOutdir) {
|
|
7
6
|
const parentDir = path.dirname(serverOutdir);
|
|
8
7
|
fileSystem.ensureDir(parentDir);
|
|
9
|
-
return
|
|
8
|
+
return fileSystem.mkdtemp(path.join(parentDir, `.${path.basename(serverOutdir)}.staging-`));
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
11
|
* Publishes a complete server bundle generation without exposing mixed artifacts.
|
|
@@ -20,12 +19,12 @@ export function publishServerBundleDirectory(stagingDir, serverOutdir) {
|
|
|
20
19
|
const hadPublishedBundle = fileSystem.exists(serverOutdir);
|
|
21
20
|
try {
|
|
22
21
|
if (hadPublishedBundle)
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
fileSystem.rename(serverOutdir, backupDir);
|
|
23
|
+
fileSystem.rename(stagingDir, serverOutdir);
|
|
25
24
|
}
|
|
26
25
|
catch (error) {
|
|
27
26
|
if (hadPublishedBundle && !fileSystem.exists(serverOutdir) && fileSystem.exists(backupDir)) {
|
|
28
|
-
|
|
27
|
+
fileSystem.rename(backupDir, serverOutdir);
|
|
29
28
|
}
|
|
30
29
|
throw error;
|
|
31
30
|
}
|
package/src/build.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render
|
|
|
5
5
|
export { type BuildAdapter, type BuildExecutor, type BuildOptions, type BuildResult, setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
|
|
6
6
|
export { CONTENT_BROWSER_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, type ParsedCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
|
|
7
7
|
export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
|
|
8
|
-
export { BuildQueue
|
|
8
|
+
export { BuildQueue } from './build/runtime/build-queue.js';
|
|
9
9
|
export { buildServerModule } from './build/server-module.js';
|
|
10
10
|
export { parseModuleSource, recordModuleTransformProfile } from './cache/index.js';
|
|
11
|
-
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './
|
|
11
|
+
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
|
|
12
12
|
export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
|
|
13
13
|
export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, type RequestPipelineMetricsState, } from './diagnostics/request-pipeline-metrics.js';
|
|
14
14
|
export { toPackageRootSpecifier } from './plugins/package-specifier.js';
|
package/src/build.js
CHANGED
|
@@ -5,10 +5,10 @@ export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render
|
|
|
5
5
|
export { setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
|
|
6
6
|
export { CONTENT_BROWSER_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
|
|
7
7
|
export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
|
|
8
|
-
export { BuildQueue
|
|
8
|
+
export { BuildQueue } from './build/runtime/build-queue.js';
|
|
9
9
|
export { buildServerModule } from './build/server-module.js';
|
|
10
10
|
export { parseModuleSource, recordModuleTransformProfile } from './cache/index.js';
|
|
11
|
-
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './
|
|
11
|
+
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
|
|
12
12
|
export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
|
|
13
13
|
export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, } from './diagnostics/request-pipeline-metrics.js';
|
|
14
14
|
export { toPackageRootSpecifier } from './plugins/package-specifier.js';
|
|
@@ -65,8 +65,8 @@ export interface AppRuntime {
|
|
|
65
65
|
* @remarks
|
|
66
66
|
* Finalization calls this once. A second call returns that same object. The module loader is
|
|
67
67
|
* created before the runtime is stored: it reads the server-invalidation counter when a generation
|
|
68
|
-
* is requested, not while it is constructed.
|
|
69
|
-
*
|
|
68
|
+
* is requested, not while it is constructed. The runtime keeps its one `buildQueue` for its lifetime,
|
|
69
|
+
* so identical builds share one in-flight result from config setup onwards.
|
|
70
70
|
*
|
|
71
71
|
* @throws When the config was not assembled by finalization.
|
|
72
72
|
*/
|
|
@@ -32,8 +32,8 @@ export class ServerInvalidationState {
|
|
|
32
32
|
* @remarks
|
|
33
33
|
* Finalization calls this once. A second call returns that same object. The module loader is
|
|
34
34
|
* created before the runtime is stored: it reads the server-invalidation counter when a generation
|
|
35
|
-
* is requested, not while it is constructed.
|
|
36
|
-
*
|
|
35
|
+
* is requested, not while it is constructed. The runtime keeps its one `buildQueue` for its lifetime,
|
|
36
|
+
* so identical builds share one in-flight result from config setup onwards.
|
|
37
37
|
*
|
|
38
38
|
* @throws When the config was not assembled by finalization.
|
|
39
39
|
*/
|
|
@@ -10,14 +10,14 @@ import type { EcoPagesUserConfig, FinalizeEcoPagesConfigOptions } from '../user-
|
|
|
10
10
|
* 1. applies defaults (`baseUrl` falls back to `ECOPAGES_BASE_URL`, then `http://localhost:3000`),
|
|
11
11
|
* 2. appends the HTML Pages Integration and rejects duplicate Integration names and extensions,
|
|
12
12
|
* 3. resolves absolute paths, including the semantic `html.*` and error-page templates,
|
|
13
|
-
* 4.
|
|
14
|
-
*
|
|
13
|
+
* 4. assembles one app runtime on the config, with the app-owned build adapter, build manifest, and
|
|
14
|
+
* build queue.
|
|
15
15
|
*
|
|
16
16
|
* Every call returns a new config; nothing is cached.
|
|
17
17
|
*
|
|
18
18
|
* App code never calls this: it exports `defineConfig(...)` and `createApp()` finalizes it.
|
|
19
|
-
* Workspace packages and tests import it from `@ecopages/core/config
|
|
20
|
-
*
|
|
19
|
+
* Workspace packages and tests import it from `@ecopages/core/config`. That subpath is published, but
|
|
20
|
+
* keep this function out of user-facing docs.
|
|
21
21
|
*
|
|
22
22
|
* @throws When `userConfig` is an already finalized config; when Integration names or
|
|
23
23
|
* extensions, or Processor or loader names, repeat; when a semantic
|
|
@@ -181,14 +181,14 @@ function createAbsolutePaths(config, configFilePath, configModuleFiles) {
|
|
|
181
181
|
* 1. applies defaults (`baseUrl` falls back to `ECOPAGES_BASE_URL`, then `http://localhost:3000`),
|
|
182
182
|
* 2. appends the HTML Pages Integration and rejects duplicate Integration names and extensions,
|
|
183
183
|
* 3. resolves absolute paths, including the semantic `html.*` and error-page templates,
|
|
184
|
-
* 4.
|
|
185
|
-
*
|
|
184
|
+
* 4. assembles one app runtime on the config, with the app-owned build adapter, build manifest, and
|
|
185
|
+
* build queue.
|
|
186
186
|
*
|
|
187
187
|
* Every call returns a new config; nothing is cached.
|
|
188
188
|
*
|
|
189
189
|
* App code never calls this: it exports `defineConfig(...)` and `createApp()` finalizes it.
|
|
190
|
-
* Workspace packages and tests import it from `@ecopages/core/config
|
|
191
|
-
*
|
|
190
|
+
* Workspace packages and tests import it from `@ecopages/core/config`. That subpath is published, but
|
|
191
|
+
* keep this function out of user-facing docs.
|
|
192
192
|
*
|
|
193
193
|
* @throws When `userConfig` is an already finalized config; when Integration names or
|
|
194
194
|
* extensions, or Processor or loader names, repeat; when a semantic
|
|
@@ -225,7 +225,6 @@ export async function finalizeEcoPagesConfig(userConfig, options = {}) {
|
|
|
225
225
|
devPrewarmPaths: userConfig.devPrewarmPaths ?? [],
|
|
226
226
|
cache: userConfig.cache,
|
|
227
227
|
devToolbar: userConfig.devToolbar,
|
|
228
|
-
experimental: userConfig.experimental,
|
|
229
228
|
};
|
|
230
229
|
const configFilePath = options.configFilePath ?? path.join(rootDir, DEFAULT_ECO_CONFIG_FILENAME);
|
|
231
230
|
const config = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { realpathSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
3
|
import { rolldown } from 'rolldown';
|
|
@@ -27,9 +26,9 @@ function toProjectPath(id, realRoot, root) {
|
|
|
27
26
|
*/
|
|
28
27
|
export async function collectConfigModuleFiles(configFilePath, rootDir) {
|
|
29
28
|
const root = path.resolve(rootDir);
|
|
30
|
-
const realRoot = fileSystem.exists(root) ?
|
|
29
|
+
const realRoot = fileSystem.exists(root) ? fileSystem.realpath(root) : root;
|
|
31
30
|
const configFile = path.resolve(configFilePath);
|
|
32
|
-
const realConfigFile = fileSystem.exists(configFile) ?
|
|
31
|
+
const realConfigFile = fileSystem.exists(configFile) ? fileSystem.realpath(configFile) : configFile;
|
|
33
32
|
const moduleFiles = new Set([configFile]);
|
|
34
33
|
try {
|
|
35
34
|
const bundle = await rolldown({
|