@ecopages/core 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -15
- package/package.json +13 -4
- package/src/adapters/create-app.js +9 -5
- package/src/adapters/node/create-app.d.ts +18 -16
- package/src/adapters/node/create-app.js +26 -30
- package/src/adapters/node/server-adapter.d.ts +26 -9
- package/src/adapters/node/server-adapter.js +38 -8
- package/src/adapters/shared/hmr/hmr-manager.js +3 -2
- package/src/adapters/shared/http/api-request-pipeline.js +2 -2
- package/src/adapters/shared/http/dist-file-handler.js +25 -7
- package/src/adapters/shared/runtime/render-context.d.ts +2 -1
- package/src/adapters/shared/runtime/render-context.js +18 -21
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +4 -3
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +6 -4
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +6 -1
- package/src/adapters/shared/runtime/server-request-pipeline.js +11 -10
- package/src/adapters/shared/runtime/server-route-handler.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +11 -11
- package/src/adapters/shared/runtime/server-static-builder.js +37 -18
- package/src/assets/app-browser-client-build.js +8 -21
- package/src/assets/app-browser-client-manifest.d.ts +1 -4
- package/src/assets/app-browser-client-manifest.js +6 -78
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +2 -2
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +2 -2
- package/src/assets/browser-asset-output.d.ts +1 -1
- package/src/assets/browser-asset-output.js +1 -1
- package/src/build/app-build-manifest-runtime.d.ts +11 -1
- package/src/build/app-build-manifest-runtime.js +17 -3
- package/src/build/cache/pages-unified-graph-build.d.ts +32 -35
- package/src/build/cache/pages-unified-graph-build.js +206 -124
- package/src/build/cache/server-module-entries.d.ts +35 -0
- package/src/build/cache/server-module-entries.js +109 -0
- package/src/build/contracts/build-contracts.d.ts +5 -0
- package/src/build/contracts/content-virtual-modules.d.ts +9 -3
- package/src/build/contracts/content-virtual-modules.js +11 -5
- package/src/build/contracts.d.ts +1 -1
- package/src/build/contracts.js +1 -1
- package/src/build/copy-server-files.d.ts +10 -0
- package/src/build/copy-server-files.js +37 -0
- package/src/build/preserve-import-meta-transform.d.ts +1 -1
- package/src/build/preserve-import-meta-transform.js +1 -1
- package/src/build/production-build-id.d.ts +9 -0
- package/src/build/production-build-id.js +19 -0
- package/src/build/production-dist-complete.d.ts +5 -0
- package/src/build/production-dist-complete.js +101 -0
- package/src/build/production-route-list.d.ts +26 -0
- package/src/build/production-route-list.js +78 -0
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +2 -2
- package/src/build/rolldown/rolldown-adapter-helpers.js +56 -4
- package/src/build/rolldown/rolldown-build-adapter.js +1 -1
- package/src/build/rolldown/rolldown-plugin-bridge.js +2 -2
- package/src/build/runtime/build-request-identity.js +2 -1
- package/src/build/runtime/build-request-policy.d.ts +3 -2
- package/src/build/runtime/build-request-policy.js +5 -3
- package/src/build/server/import-view-module.d.ts +11 -0
- package/src/build/server/import-view-module.js +21 -0
- package/src/build/server/imported-view-plugin.d.ts +16 -0
- package/src/build/server/imported-view-plugin.js +59 -0
- package/src/build/server/page-module-import.service.d.ts +19 -20
- package/src/build/server/page-module-import.service.js +65 -36
- package/src/build/server/resolve-static-view.d.ts +9 -0
- package/src/build/server/resolve-static-view.js +28 -0
- package/src/build/server/route-module-build-cache-registry.d.ts +5 -3
- package/src/build/server/route-module-build-cache-registry.js +5 -3
- package/src/build/server/server-modules-manifest.d.ts +51 -0
- package/src/build/server/server-modules-manifest.js +129 -0
- package/src/build/server/view-reference.d.ts +38 -0
- package/src/build/server/view-reference.js +112 -0
- package/src/build/server-bundle-deploy-manifest.d.ts +9 -9
- package/src/build/server-bundle-deploy-manifest.js +24 -28
- package/src/build.d.ts +4 -2
- package/src/build.js +4 -2
- package/src/config/assembly/app-runtime.d.ts +15 -2
- package/src/config/assembly/app-runtime.js +3 -1
- package/src/config/assembly/finalize-config.js +64 -13
- package/src/config/index.d.ts +1 -0
- package/src/config/index.js +1 -0
- package/src/config/internal-types.d.ts +6 -0
- package/src/config/load-eco-config.d.ts +1 -0
- package/src/config/load-eco-config.js +11 -2
- package/src/config/resolve-eco-config-path.d.ts +2 -1
- package/src/config/resolve-eco-config-path.js +21 -15
- package/src/config/user-config-types.d.ts +9 -2
- package/src/dev/transform-server/dev-transform-server.js +1 -1
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +29 -6
- package/src/dev/transform-server/dev-transform-vendor-registry.js +101 -53
- package/src/errors/http-error.d.ts +9 -0
- package/src/errors/http-error.js +11 -0
- package/src/html/html-transformer.service.d.ts +0 -21
- package/src/html/html-transformer.service.js +0 -32
- package/src/html-pages/html-page-module.d.ts +19 -0
- package/src/html-pages/html-page-module.js +66 -13
- package/src/html-pages/html-page-renderer.d.ts +6 -1
- package/src/html-pages/html-page-renderer.js +14 -6
- package/src/html-pages/html-pages.plugin.d.ts +10 -0
- package/src/html-pages/html-pages.plugin.js +7 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/integration.d.ts +2 -2
- package/src/integration.js +1 -1
- package/src/islands/island-host.d.ts +1 -2
- package/src/islands/island-host.js +1 -2
- package/src/page-cache/page-cache-service.d.ts +8 -0
- package/src/page-cache/page-cache-service.js +12 -0
- package/src/plugins/integration-plugin.d.ts +34 -7
- package/src/plugins/integration-plugin.js +14 -2
- package/src/plugins/processor.d.ts +18 -1
- package/src/plugins/processor.js +20 -1
- package/src/plugins/server-dom.d.ts +29 -0
- package/src/plugins/server-dom.js +36 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/processor.d.ts +1 -1
- package/src/route-renderer/error-pages/error-page-renderer.d.ts +6 -4
- package/src/route-renderer/error-pages/error-page-renderer.js +9 -5
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +2 -44
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +14 -89
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +4 -16
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +2 -10
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +3 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +21 -44
- package/src/route-renderer/orchestration/integration-renderer.js +69 -117
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +3 -4
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +4 -15
- package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.d.ts +22 -0
- package/src/route-renderer/orchestration/ownership-graph/prepared-graph-membership.js +45 -0
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +0 -1
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +21 -0
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +31 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +58 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +55 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +4 -3
- package/src/router/server/route-registry.d.ts +23 -1
- package/src/router/server/route-registry.js +41 -14
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +8 -2
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +14 -13
- package/src/static-site-generator/static-site-generator.d.ts +19 -3
- package/src/static-site-generator/static-site-generator.js +78 -40
- package/src/types/build-types.d.ts +6 -0
- package/src/types/contracts.d.ts +26 -35
- package/src/types/eco-api-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -0
- package/src/types/view-reference.d.ts +31 -0
- package/src/types/view-reference.js +15 -0
- package/src/utils/additional-watch-paths.d.ts +3 -3
- package/src/utils/additional-watch-paths.js +3 -1
- package/src/utils/resolve-entry-file.d.ts +4 -2
- package/src/utils/resolve-entry-file.js +4 -2
- package/src/utils/root-relative-path.d.ts +4 -0
- package/src/utils/root-relative-path.js +8 -0
- package/src/utils/server-bundle-context.d.ts +14 -0
- package/src/utils/server-bundle-context.js +45 -0
- package/src/watchers/project-watcher-ignore.d.ts +2 -5
- package/src/watchers/project-watcher-ignore.js +2 -5
- package/src/watchers/project-watcher.d.ts +9 -7
- package/src/watchers/project-watcher.js +100 -52
- package/src/watchers/workspace-package-watch-roots.d.ts +4 -4
- package/src/watchers/workspace-package-watch-roots.js +41 -25
- package/src/build/server/view-module-loader.d.ts +0 -10
- package/src/build/server/view-module-loader.js +0 -46
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +0 -12
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +0 -32
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { isPathStrictlyInside } from '../utils/path-containment.js';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
|
-
import {
|
|
4
|
+
import { ensureProductionBuildId } from '../build/production-build-id.js';
|
|
5
|
+
import { getServerBundleOutputPaths } from '../build/server-bundle-deploy-manifest.js';
|
|
5
6
|
import { collectHtmlPageModuleScriptBuildInputs, getPrebuiltHtmlPageModuleScriptUrls, } from '../html-pages/html-page-module-scripts.js';
|
|
6
7
|
import { createAppBrowserClientEntryKey } from './app-browser-client-build.js';
|
|
7
8
|
import { createPageDependencyInstanceKey, createRouteGraphLookupKey, } from '../route-renderer/orchestration/page-browser-graph/route-instance-key.js';
|
|
8
9
|
const APP_BROWSER_CLIENT_MANIFEST_FILENAME = 'browser-client-manifest.json';
|
|
9
10
|
function getManifestPath(appConfig) {
|
|
10
|
-
return path.join(appConfig.
|
|
11
|
+
return path.join(getServerBundleOutputPaths(appConfig).serverOutdir, APP_BROWSER_CLIENT_MANIFEST_FILENAME);
|
|
11
12
|
}
|
|
12
13
|
function toProjectPath(rootDir, filePath) {
|
|
13
14
|
return path.relative(rootDir, filePath).split(path.sep).join('/');
|
|
@@ -78,13 +79,6 @@ function isStringArray(value) {
|
|
|
78
79
|
function isProcessedAssetArray(value) {
|
|
79
80
|
return Array.isArray(value) && value.every(isProcessedAsset);
|
|
80
81
|
}
|
|
81
|
-
function isIslandRenderAssetEntries(value) {
|
|
82
|
-
return (Array.isArray(value) &&
|
|
83
|
-
value.every((entry) => Array.isArray(entry) &&
|
|
84
|
-
entry.length === 2 &&
|
|
85
|
-
typeof entry[0] === 'string' &&
|
|
86
|
-
isProcessedAssetArray(entry[1])));
|
|
87
|
-
}
|
|
88
82
|
function isManifestEntry(value) {
|
|
89
83
|
if (!isRecord(value) || !isRecord(value.pageClientAssets))
|
|
90
84
|
return false;
|
|
@@ -99,17 +93,16 @@ function isManifestEntry(value) {
|
|
|
99
93
|
isStringArray(value.pageClientBuildEntryKeys) &&
|
|
100
94
|
isProcessedAssetArray(value.groupedAssets) &&
|
|
101
95
|
isProcessedAssetArray(pageClientAssets.processedAssets) &&
|
|
102
|
-
isStringArray(pageClientAssets.fallbackPageClientBuildEntryKeys)
|
|
103
|
-
isIslandRenderAssetEntries(pageClientAssets.islandRenderAssetsByFile));
|
|
96
|
+
isStringArray(pageClientAssets.fallbackPageClientBuildEntryKeys));
|
|
104
97
|
}
|
|
105
98
|
function isManifest(value) {
|
|
106
99
|
return (isRecord(value) &&
|
|
107
100
|
value.version === 1 &&
|
|
101
|
+
isOptionalString(value, 'buildId') &&
|
|
108
102
|
Array.isArray(value.entries) &&
|
|
109
103
|
value.entries.every(isManifestEntry) &&
|
|
110
104
|
isStringRecord(value.htmlPageModuleScriptUrls) &&
|
|
111
105
|
typeof value.htmlPageModuleScriptFingerprint === 'string' &&
|
|
112
|
-
isStringRecord(value.sourceFingerprints) &&
|
|
113
106
|
isStringArray(value.browserOutputPaths));
|
|
114
107
|
}
|
|
115
108
|
function serializeEntry(rootDir, plan, instance, params) {
|
|
@@ -137,50 +130,10 @@ function serializeEntry(rootDir, plan, instance, params) {
|
|
|
137
130
|
groupedAssets: (instance.prebuiltGroupedAssets ?? []).map((asset) => serializeProcessedAsset(rootDir, asset)),
|
|
138
131
|
pageClientAssets: {
|
|
139
132
|
processedAssets: (pageClientAssets?.processedAssets ?? []).map((asset) => serializeProcessedAsset(rootDir, asset)),
|
|
140
|
-
islandRenderAssetsByFile: [...(pageClientAssets?.islandRenderAssetsByFile ?? [])].map(([filePath, assets]) => [
|
|
141
|
-
toProjectPath(rootDir, filePath),
|
|
142
|
-
assets.map((asset) => serializeProcessedAsset(rootDir, asset)),
|
|
143
|
-
]),
|
|
144
133
|
fallbackPageClientBuildEntryKeys,
|
|
145
134
|
},
|
|
146
135
|
};
|
|
147
136
|
}
|
|
148
|
-
function addDependencySourceFilepaths(filepaths, dependency) {
|
|
149
|
-
if (dependency.source === 'file' && dependency.filepath)
|
|
150
|
-
filepaths.add(path.resolve(dependency.filepath));
|
|
151
|
-
for (const filepath of dependency.bundledSourceFilepaths ?? [])
|
|
152
|
-
filepaths.add(path.resolve(filepath));
|
|
153
|
-
}
|
|
154
|
-
function addAssetSourceFilepaths(filepaths, asset) {
|
|
155
|
-
if (asset.sourceFilepath)
|
|
156
|
-
filepaths.add(path.resolve(asset.sourceFilepath));
|
|
157
|
-
for (const filepath of asset.bundledSourceFilepaths ?? [])
|
|
158
|
-
filepaths.add(path.resolve(filepath));
|
|
159
|
-
}
|
|
160
|
-
function collectInstanceSourceFilepaths(filepaths, instance) {
|
|
161
|
-
for (const dependency of instance.contribution?.dependencies ?? [])
|
|
162
|
-
addDependencySourceFilepaths(filepaths, dependency);
|
|
163
|
-
for (const clientEntry of instance.pageClientBuildEntries ?? []) {
|
|
164
|
-
addDependencySourceFilepaths(filepaths, clientEntry.dependency);
|
|
165
|
-
}
|
|
166
|
-
for (const asset of instance.prebuiltGroupedAssets ?? [])
|
|
167
|
-
addAssetSourceFilepaths(filepaths, asset);
|
|
168
|
-
for (const asset of instance.prebuiltPageClientBrowserAssets?.processedAssets ?? []) {
|
|
169
|
-
addAssetSourceFilepaths(filepaths, asset);
|
|
170
|
-
}
|
|
171
|
-
for (const assets of instance.prebuiltPageClientBrowserAssets?.islandRenderAssetsByFile.values() ?? []) {
|
|
172
|
-
for (const asset of assets)
|
|
173
|
-
addAssetSourceFilepaths(filepaths, asset);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function collectSourceFilepaths(plans) {
|
|
177
|
-
const filepaths = new Set();
|
|
178
|
-
for (const plan of plans) {
|
|
179
|
-
for (const instance of plan.instances)
|
|
180
|
-
collectInstanceSourceFilepaths(filepaths, instance);
|
|
181
|
-
}
|
|
182
|
-
return filepaths;
|
|
183
|
-
}
|
|
184
137
|
function addAssetOutputFilepaths(filepaths, assets = []) {
|
|
185
138
|
for (const asset of assets) {
|
|
186
139
|
if (asset.filepath)
|
|
@@ -190,9 +143,6 @@ function addAssetOutputFilepaths(filepaths, assets = []) {
|
|
|
190
143
|
function collectInstanceOutputFilepaths(filepaths, instance) {
|
|
191
144
|
addAssetOutputFilepaths(filepaths, instance.prebuiltGroupedAssets);
|
|
192
145
|
addAssetOutputFilepaths(filepaths, instance.prebuiltPageClientBrowserAssets?.processedAssets);
|
|
193
|
-
for (const assets of instance.prebuiltPageClientBrowserAssets?.islandRenderAssetsByFile.values() ?? []) {
|
|
194
|
-
addAssetOutputFilepaths(filepaths, assets);
|
|
195
|
-
}
|
|
196
146
|
}
|
|
197
147
|
function addHtmlScriptOutputFilepaths(filepaths, distDir, htmlPageModuleScriptUrls) {
|
|
198
148
|
for (const url of Object.values(htmlPageModuleScriptUrls)) {
|
|
@@ -210,12 +160,6 @@ function collectOutputFilepaths(appConfig, plans, htmlPageModuleScriptUrls, brow
|
|
|
210
160
|
addHtmlScriptOutputFilepaths(filepaths, appConfig.absolutePaths.distDir, htmlPageModuleScriptUrls);
|
|
211
161
|
return filepaths;
|
|
212
162
|
}
|
|
213
|
-
function fingerprintSources(rootDir, filepaths) {
|
|
214
|
-
return Object.fromEntries([...new Set(filepaths)]
|
|
215
|
-
.filter((filepath) => fileSystem.exists(filepath))
|
|
216
|
-
.sort()
|
|
217
|
-
.map((filepath) => [toProjectPath(rootDir, filepath), contentHash(fileSystem.readFileSync(filepath))]));
|
|
218
|
-
}
|
|
219
163
|
/** Persists the browser outputs built for production routes so `ecopages start` can reuse them. */
|
|
220
164
|
export async function writeAppBrowserClientManifest(appConfig, plans, routeInstances, browserBuild) {
|
|
221
165
|
const paramsByRouteKey = new Map(routeInstances.map((instance) => [
|
|
@@ -242,19 +186,12 @@ export async function writeAppBrowserClientManifest(appConfig, plans, routeInsta
|
|
|
242
186
|
url,
|
|
243
187
|
]));
|
|
244
188
|
const htmlBuildInputs = collectHtmlPageModuleScriptBuildInputs(appConfig);
|
|
245
|
-
const sourceFilepaths = collectSourceFilepaths(plans);
|
|
246
|
-
for (const filepath of [...htmlBuildInputs.htmlFiles, ...htmlBuildInputs.files]) {
|
|
247
|
-
sourceFilepaths.add(path.resolve(filepath));
|
|
248
|
-
}
|
|
249
|
-
for (const filepath of browserBuild.sourceFiles) {
|
|
250
|
-
sourceFilepaths.add(path.resolve(filepath));
|
|
251
|
-
}
|
|
252
189
|
const manifest = {
|
|
253
190
|
version: 1,
|
|
191
|
+
buildId: ensureProductionBuildId(appConfig),
|
|
254
192
|
entries,
|
|
255
193
|
htmlPageModuleScriptUrls,
|
|
256
194
|
htmlPageModuleScriptFingerprint: htmlBuildInputs.fingerprint,
|
|
257
|
-
sourceFingerprints: fingerprintSources(appConfig.rootDir, sourceFilepaths),
|
|
258
195
|
browserOutputPaths: [
|
|
259
196
|
...collectOutputFilepaths(appConfig, plans, htmlPageModuleScriptUrls, browserBuild.outputPaths),
|
|
260
197
|
]
|
|
@@ -317,15 +254,6 @@ export function restoreAppBrowserClientAssets(appConfig, assets) {
|
|
|
317
254
|
};
|
|
318
255
|
});
|
|
319
256
|
}
|
|
320
|
-
/** Ensures the source files used by the browser build have not changed since export. */
|
|
321
|
-
export function assertAppBrowserClientSourcesMatch(appConfig, sourceFingerprints) {
|
|
322
|
-
for (const [relativePath, expectedFingerprint] of Object.entries(sourceFingerprints)) {
|
|
323
|
-
const filepath = path.resolve(appConfig.rootDir, relativePath);
|
|
324
|
-
if (!fileSystem.exists(filepath) || contentHash(fileSystem.readFileSync(filepath)) !== expectedFingerprint) {
|
|
325
|
-
throw new Error(`The app browser build manifest is stale because ${relativePath} changed or is missing. Run \`ecopages build\` again.`);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
257
|
/** Resolves an app-relative file path stored in the build manifest. */
|
|
330
258
|
export function resolveAppBrowserClientManifestPath(appConfig, filePath) {
|
|
331
259
|
return path.resolve(appConfig.rootDir, filePath);
|
|
@@ -27,7 +27,7 @@ export declare class FileScriptProcessor extends BaseScriptProcessor<FileScriptA
|
|
|
27
27
|
* is copied to its source-relative path. A classic script inside `srcDir` is compiled and written
|
|
28
28
|
* under that path with a `.js` name. A file outside `srcDir` has no such path that stays inside
|
|
29
29
|
* `dist`: an unbundled or classic script is written under a content hash, and a bundled script
|
|
30
|
-
* is emitted in `dist/assets` under the bundler's `[name]-[hash]` name. Vendor runtimes inside
|
|
30
|
+
* is emitted in `dist/client/assets` under the bundler's `[name]-[hash]` name. Vendor runtimes inside
|
|
31
31
|
* `src` keep their stable names.
|
|
32
32
|
*/
|
|
33
33
|
process(dep: FileScriptAsset): Promise<ProcessedAsset>;
|
|
@@ -38,7 +38,7 @@ export declare class FileScriptProcessor extends BaseScriptProcessor<FileScriptA
|
|
|
38
38
|
* @remarks
|
|
39
39
|
* The output keeps the source path and name when the file is inside `srcDir`, with a TypeScript
|
|
40
40
|
* extension turned into `.js`, as a copied classic `.js` does. A file outside `srcDir` is written
|
|
41
|
-
* under a content hash in `dist/assets`. A second source file for the same output is rejected while
|
|
41
|
+
* under a content hash in `dist/client/assets`. A second source file for the same output is rejected while
|
|
42
42
|
* the first still exists, so a last write cannot silently win.
|
|
43
43
|
*
|
|
44
44
|
* @throws When the file cannot be a classic script, or another existing file is emitted to its output.
|
|
@@ -56,7 +56,7 @@ export class FileScriptProcessor extends BaseScriptProcessor {
|
|
|
56
56
|
* is copied to its source-relative path. A classic script inside `srcDir` is compiled and written
|
|
57
57
|
* under that path with a `.js` name. A file outside `srcDir` has no such path that stays inside
|
|
58
58
|
* `dist`: an unbundled or classic script is written under a content hash, and a bundled script
|
|
59
|
-
* is emitted in `dist/assets` under the bundler's `[name]-[hash]` name. Vendor runtimes inside
|
|
59
|
+
* is emitted in `dist/client/assets` under the bundler's `[name]-[hash]` name. Vendor runtimes inside
|
|
60
60
|
* `src` keep their stable names.
|
|
61
61
|
*/
|
|
62
62
|
async process(dep) {
|
|
@@ -151,7 +151,7 @@ export class FileScriptProcessor extends BaseScriptProcessor {
|
|
|
151
151
|
* @remarks
|
|
152
152
|
* The output keeps the source path and name when the file is inside `srcDir`, with a TypeScript
|
|
153
153
|
* extension turned into `.js`, as a copied classic `.js` does. A file outside `srcDir` is written
|
|
154
|
-
* under a content hash in `dist/assets`. A second source file for the same output is rejected while
|
|
154
|
+
* under a content hash in `dist/client/assets`. A second source file for the same output is rejected while
|
|
155
155
|
* the first still exists, so a last write cannot silently win.
|
|
156
156
|
*
|
|
157
157
|
* @throws When the file cannot be a classic script, or another existing file is emitted to its output.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @remarks
|
|
5
5
|
* `path.relative` from `srcDir` to a file outside it starts with `..`. Joining
|
|
6
6
|
* that onto `dist` writes the asset outside the build. Callers then emit the file
|
|
7
|
-
* in `dist/assets`: a bundled script under the bundler's `[name]-[hash]` name, and
|
|
7
|
+
* in `dist/client/assets`: a bundled script under the bundler's `[name]-[hash]` name, and
|
|
8
8
|
* an unbundled script or stylesheet under a content hash.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sourceRelativeBrowserAssetPath(srcDir: string, filepath: string): string | undefined;
|
|
@@ -6,7 +6,7 @@ import { isPathInside } from '../utils/path-containment.js';
|
|
|
6
6
|
* @remarks
|
|
7
7
|
* `path.relative` from `srcDir` to a file outside it starts with `..`. Joining
|
|
8
8
|
* that onto `dist` writes the asset outside the build. Callers then emit the file
|
|
9
|
-
* in `dist/assets`: a bundled script under the bundler's `[name]-[hash]` name, and
|
|
9
|
+
* in `dist/client/assets`: a bundled script under the bundler's `[name]-[hash]` name, and
|
|
10
10
|
* an unbundled script or stylesheet under a content hash.
|
|
11
11
|
*/
|
|
12
12
|
export function sourceRelativeBrowserAssetPath(srcDir, filepath) {
|
|
@@ -9,15 +9,25 @@ import type { EcoPagesAppConfig } from '../config/internal-types.js';
|
|
|
9
9
|
* runtime manifests are data, not lifecycle hooks. Runtime setup happens after finalization.
|
|
10
10
|
*/
|
|
11
11
|
export declare function sealAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest;
|
|
12
|
+
/**
|
|
13
|
+
* Gives each Processor its app config and calls `setup()`.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* When `skipProcessorSetup` is set, or this is the Lit static-render worker, each Processor
|
|
17
|
+
* restores from the production server-modules map instead of scanning sources.
|
|
18
|
+
*/
|
|
12
19
|
export declare function setupAppRuntimePlugins(options: {
|
|
13
20
|
appConfig: EcoPagesAppConfig;
|
|
21
|
+
skipProcessorSetup?: boolean;
|
|
14
22
|
}): Promise<void>;
|
|
15
23
|
/**
|
|
16
24
|
* Activates one integration's runtime setup on first use.
|
|
17
25
|
*
|
|
18
26
|
* @remarks
|
|
19
27
|
* Concurrent callers share a single in-flight promise per integration name.
|
|
20
|
-
*
|
|
28
|
+
* Server DOM install runs inside that promise, before `setup()`, so a second
|
|
29
|
+
* caller cannot skip the in-flight activation. Failed activations are evicted
|
|
30
|
+
* so a later caller can retry.
|
|
21
31
|
*/
|
|
22
32
|
export declare function ensureIntegrationRuntimeReady(options: {
|
|
23
33
|
appConfig: EcoPagesAppConfig;
|
|
@@ -5,6 +5,7 @@ import { requireAppRuntime } from '../utils/app-runtime.js';
|
|
|
5
5
|
import { appLogger } from '../global/app-logger.js';
|
|
6
6
|
import { startupTrace } from '../diagnostics/startup-trace.js';
|
|
7
7
|
import { isLitStaticRenderWorkerThread } from './browser/lit-static-render-worker-context.js';
|
|
8
|
+
import { installConfiguredServerDom } from '../plugins/server-dom.js';
|
|
8
9
|
/**
|
|
9
10
|
* Seals the app's build manifest from its loaders, processors and integrations.
|
|
10
11
|
*
|
|
@@ -32,6 +33,13 @@ export function sealAppBuildManifest(appConfig) {
|
|
|
32
33
|
}
|
|
33
34
|
return createAppBuildManifest(registrations, mergeBrowserRuntimeManifests(...browserRuntimeManifests));
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Gives each Processor its app config and calls `setup()`.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* When `skipProcessorSetup` is set, or this is the Lit static-render worker, each Processor
|
|
41
|
+
* restores from the production server-modules map instead of scanning sources.
|
|
42
|
+
*/
|
|
35
43
|
export async function setupAppRuntimePlugins(options) {
|
|
36
44
|
startupTrace.markPhaseStart('setupAppRuntimePlugins');
|
|
37
45
|
const runtime = requireAppRuntime(options.appConfig);
|
|
@@ -45,10 +53,13 @@ export async function setupAppRuntimePlugins(options) {
|
|
|
45
53
|
}
|
|
46
54
|
appLogger.debugTime('setupAppRuntimePlugins');
|
|
47
55
|
try {
|
|
48
|
-
const skipProcessorSetup = isLitStaticRenderWorkerThread();
|
|
56
|
+
const skipProcessorSetup = options.skipProcessorSetup === true || isLitStaticRenderWorkerThread();
|
|
49
57
|
for (const processor of options.appConfig.processors.values()) {
|
|
50
58
|
processor.setContext(options.appConfig);
|
|
51
|
-
if (
|
|
59
|
+
if (skipProcessorSetup) {
|
|
60
|
+
await processor.restoreProductionRuntime?.();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
52
63
|
await processor.setup();
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -65,7 +76,9 @@ export async function setupAppRuntimePlugins(options) {
|
|
|
65
76
|
*
|
|
66
77
|
* @remarks
|
|
67
78
|
* Concurrent callers share a single in-flight promise per integration name.
|
|
68
|
-
*
|
|
79
|
+
* Server DOM install runs inside that promise, before `setup()`, so a second
|
|
80
|
+
* caller cannot skip the in-flight activation. Failed activations are evicted
|
|
81
|
+
* so a later caller can retry.
|
|
69
82
|
*/
|
|
70
83
|
export async function ensureIntegrationRuntimeReady(options) {
|
|
71
84
|
const runtime = requireAppRuntime(options.appConfig);
|
|
@@ -79,6 +92,7 @@ export async function ensureIntegrationRuntimeReady(options) {
|
|
|
79
92
|
return;
|
|
80
93
|
}
|
|
81
94
|
const activation = (async () => {
|
|
95
|
+
await installConfiguredServerDom(options.appConfig.integrations);
|
|
82
96
|
await integration.setup({ appConfig: options.appConfig, runtime });
|
|
83
97
|
})();
|
|
84
98
|
runtime.integrationActivations.set(options.integrationName, activation);
|
|
@@ -1,54 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Unified
|
|
2
|
+
* Unified production server-module graph.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
* registered on the app config.
|
|
4
|
+
* `ecopages build` emits every server entry into `dist/server/` and writes
|
|
5
|
+
* `server-modules.json`. `ecopages start` imports those modules and never compiles.
|
|
7
6
|
*/
|
|
8
7
|
import type { EcoPagesAppConfig } from '../../config/internal-types.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
outputs: Record<string, string>;
|
|
13
|
-
/**
|
|
14
|
-
* Local files reachable from the outputs through local imports, including
|
|
15
|
-
* shared chunks. The graph is reused only while all of them exist.
|
|
16
|
-
*/
|
|
17
|
-
outputImports: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Content hashes for every trackable source file in the graph.
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* Compiled chunks can outlive a deleted layout or component. Reuse also
|
|
23
|
-
* requires these hashes so a source edit or deletion rebuilds the graph.
|
|
24
|
-
*/
|
|
25
|
-
dependencyHashes: RouteModuleDependencyHashes;
|
|
26
|
-
/**
|
|
27
|
-
* Memoized result of {@link isGraphManifestCurrent} for page imports.
|
|
28
|
-
*/
|
|
29
|
-
importable?: boolean;
|
|
30
|
-
}
|
|
8
|
+
import type { ErrorPageLoaders, StaticRoute } from '../../types/contracts.js';
|
|
9
|
+
import { type ProductionServerModulesManifest } from '../server/server-modules-manifest.js';
|
|
10
|
+
import { type ServerModuleEntryRouteSource } from './server-module-entries.js';
|
|
31
11
|
/**
|
|
32
|
-
* True when
|
|
12
|
+
* True when a production build should emit the server-modules map.
|
|
33
13
|
*
|
|
34
14
|
* @remarks
|
|
35
15
|
* Enabled by default in production builds. `ECOPAGES_UNIFIED_PAGES_GRAPH=false` or `0` opts out, which the
|
|
36
|
-
* bench parity suite uses as its per-page build oracle.
|
|
16
|
+
* bench parity suite uses as its per-page build oracle. Production `ecopages start` still requires
|
|
17
|
+
* the emitted server-modules map from a build that did emit.
|
|
37
18
|
*/
|
|
38
19
|
export declare function shouldBuildPagesUnifiedGraph(): boolean;
|
|
39
20
|
/**
|
|
40
21
|
* @remarks
|
|
41
22
|
* Pages of an Integration that compiles its own modules (`compilePageModule`), such as
|
|
42
|
-
* HTML Pages, are not bundled, so they stay out of the graph.
|
|
23
|
+
* HTML Pages, are not bundled, so they stay out of the Rolldown graph.
|
|
43
24
|
*/
|
|
44
25
|
export declare function isPagesUnifiedGraphPage(filePath: string, appConfig: EcoPagesAppConfig): boolean;
|
|
26
|
+
export declare function importEmittedServerModule<T>(appConfig: EcoPagesAppConfig, filePath: string, outputPath: string): Promise<T>;
|
|
45
27
|
/**
|
|
46
|
-
*
|
|
28
|
+
* Emits every production server entry into `outdir` and writes `server-modules.json`.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Imports the emitted Rolldown modules to discover extra `ssr: true` scripts, so
|
|
32
|
+
* Integrations are activated first; Core installs the configured server DOM
|
|
33
|
+
* before their `setup()`. A discovered script already bundled into the first
|
|
34
|
+
* emit maps to that output. Otherwise a second emit adds the scripts; preserved
|
|
35
|
+
* modules keep their output path across both emits, so a module imported after
|
|
36
|
+
* the first emit is not evaluated again from a second copy.
|
|
47
37
|
*/
|
|
48
|
-
export declare function
|
|
38
|
+
export declare function emitProductionServerModules(options: {
|
|
49
39
|
appConfig: EcoPagesAppConfig;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
router: ServerModuleEntryRouteSource;
|
|
41
|
+
staticRoutes?: readonly StaticRoute[];
|
|
42
|
+
errorPageLoaders?: ErrorPageLoaders;
|
|
43
|
+
outdir?: string;
|
|
44
|
+
}): Promise<ProductionServerModulesManifest>;
|
|
45
|
+
/**
|
|
46
|
+
* Imports the emitted module for `filePath` from the production server-modules map.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Resolves `undefined` when no map was emitted or it does not list the file.
|
|
50
|
+
*/
|
|
54
51
|
export declare function importPagesUnifiedGraphModule<T>(appConfig: EcoPagesAppConfig, filePath: string): Promise<T | undefined>;
|