@ecopages/core 0.2.0-beta.2 → 0.2.0-beta.21
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 +1 -1
- package/package.json +163 -3
- package/src/adapters/abstract/application-adapter.d.ts +104 -5
- package/src/adapters/abstract/application-adapter.js +125 -1
- package/src/adapters/abstract/server-adapter.d.ts +6 -2
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +60 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +61 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +6 -4
- package/src/adapters/bun/create-app.js +65 -43
- package/src/adapters/bun/server-adapter.d.ts +90 -22
- package/src/adapters/bun/server-adapter.js +266 -84
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -11
- package/src/adapters/create-app.js +2 -51
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +1 -2
- package/src/adapters/node/create-app.d.ts +5 -1
- package/src/adapters/node/create-app.js +51 -12
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/server-adapter-dependencies.js +4 -0
- package/src/adapters/node/server-adapter.d.ts +62 -20
- package/src/adapters/node/server-adapter.js +160 -131
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/shared/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/shared/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +2 -0
- package/src/adapters/shared/fs-server-response-matcher.js +40 -18
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +21 -30
- package/src/adapters/shared/hmr-entrypoint-registrar.js +49 -54
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -1
- package/src/adapters/shared/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/port-manager.d.ts +116 -0
- package/src/adapters/shared/port-manager.js +196 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +2 -1
- package/src/adapters/shared/runtime-app-bootstrap.js +3 -6
- package/src/adapters/shared/runtime-server-lifecycle.d.ts +46 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +50 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +13 -6
- package/src/adapters/shared/server-route-handler.d.ts +4 -1
- package/src/adapters/shared/server-route-handler.js +5 -2
- package/src/adapters/shared/server-static-builder.d.ts +23 -32
- package/src/adapters/shared/server-static-builder.js +100 -73
- package/src/adapters/shared/shared-hmr-manager.d.ts +45 -11
- package/src/adapters/shared/shared-hmr-manager.js +204 -58
- package/src/adapters/shared/static-preview-host.d.ts +5 -0
- package/src/adapters/shared/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/websocket-lifecycle.js +55 -0
- package/src/build/README.md +77 -14
- package/src/build/app-build-manifest-runtime.d.ts +9 -0
- package/src/build/app-build-manifest-runtime.js +87 -0
- package/src/build/build-adapter.d.ts +17 -319
- package/src/build/build-adapter.js +28 -94
- package/src/build/build-contracts.d.ts +97 -0
- package/src/build/build-contracts.js +0 -0
- package/src/build/build-input-fingerprint.d.ts +28 -0
- package/src/build/build-input-fingerprint.js +31 -0
- package/src/build/build-profile-options.d.ts +7 -0
- package/src/build/build-profile-options.js +37 -0
- package/src/build/build-runtime.d.ts +24 -0
- package/src/build/build-runtime.js +65 -0
- package/src/build/deduping-build-executor.d.ts +28 -0
- package/src/build/deduping-build-executor.js +56 -0
- package/src/build/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/jsx-ownership-plugins.js +41 -0
- package/src/build/pages-unified-graph-build.d.ts +31 -0
- package/src/build/pages-unified-graph-build.js +206 -0
- package/src/build/parallel-build-executor.d.ts +21 -0
- package/src/build/parallel-build-executor.js +52 -0
- package/src/build/production-build-cache.d.ts +20 -0
- package/src/build/production-build-cache.js +63 -0
- package/src/build/rolldown-adapter-helpers.d.ts +3 -6
- package/src/build/rolldown-adapter-helpers.js +71 -6
- package/src/build/rolldown-build-adapter.d.ts +2 -6
- package/src/build/rolldown-build-adapter.js +3 -3
- package/src/build/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/rolldown-plugin-bridge.d.ts +15 -1
- package/src/build/rolldown-plugin-bridge.js +20 -5
- package/src/build/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown-source-transform-pass.js +58 -0
- package/src/build/runtime-build-executor.d.ts +8 -15
- package/src/build/runtime-build-executor.js +12 -15
- package/src/build/runtime-build-output-normalizer.d.ts +7 -0
- package/src/build/runtime-build-output-normalizer.js +94 -2
- package/src/build/server-entry-build-cache.d.ts +44 -0
- package/src/build/server-entry-build-cache.js +161 -0
- package/src/client/navigation-scripts/classification.d.ts +16 -0
- package/src/client/navigation-scripts/classification.js +41 -0
- package/src/client/navigation-scripts/index.d.ts +3 -0
- package/src/client/navigation-scripts/index.js +23 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
- package/src/client/navigation-scripts/registry.d.ts +11 -0
- package/src/client/navigation-scripts/registry.js +12 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
- package/src/client/navigation-scripts/rerun-queue.js +73 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +25 -0
- package/src/client/scroll.test.browser.js +37 -0
- package/src/client/view-transitions.d.ts +16 -0
- package/src/client/view-transitions.js +63 -0
- package/src/config/config-builder.d.ts +12 -7
- package/src/config/config-builder.js +12 -9
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/hmr-manager-registry.d.ts +8 -0
- package/src/dev/hmr-manager-registry.js +15 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/dev/runtime-server-started-message.d.ts +2 -0
- package/src/dev/runtime-server-started-message.js +6 -0
- package/src/eco/README.md +11 -0
- package/src/eco/eco-declared-component.d.ts +14 -0
- package/src/eco/eco-declared-component.js +16 -0
- package/src/eco/eco.browser.js +5 -6
- package/src/eco/eco.js +5 -6
- package/src/eco/eco.types.d.ts +2 -2
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +59 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +7 -1
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/hmr-entrypoint-output.d.ts +43 -0
- package/src/hmr/hmr-entrypoint-output.js +53 -0
- package/src/hmr/hmr-strategy.d.ts +15 -0
- package/src/hmr/hmr-strategy.js +19 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
- package/src/hmr/strategies/js-hmr-strategy.js +67 -19
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +19 -9
- package/src/plugins/integration-plugin.js +7 -4
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +19 -4
- package/src/plugins/processor.js +22 -4
- package/src/plugins/source-transform.d.ts +31 -0
- package/src/plugins/source-transform.js +23 -1
- package/src/route-renderer/GRAPH.md +8 -8
- package/src/route-renderer/README.md +30 -28
- package/src/route-renderer/orchestration/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/component-graph.d.ts +36 -0
- package/src/route-renderer/orchestration/component-graph.js +98 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +3 -10
- package/src/route-renderer/orchestration/component-render-context.js +3 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +1 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +5 -31
- package/src/route-renderer/orchestration/document-shell-render.service.d.ts +90 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +120 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +59 -29
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +164 -35
- package/src/route-renderer/orchestration/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +18 -54
- package/src/route-renderer/orchestration/integration-renderer.js +113 -195
- package/src/route-renderer/orchestration/integration-route-render-adapter.d.ts +38 -0
- package/src/route-renderer/orchestration/integration-route-render-adapter.js +27 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.d.ts +20 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.js +31 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +5 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +29 -1
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.d.ts +25 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.js +174 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +2 -0
- package/src/route-renderer/orchestration/render-output.utils.js +4 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.d.ts +17 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.js +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.d.ts +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +54 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +8 -39
- package/src/route-renderer/orchestration/route-render-orchestrator.js +53 -461
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +10 -0
- package/src/router/client/link-intent.test.browser.js +12 -1
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +101 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +92 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +27 -7
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/browser-bundle.service.d.ts +3 -1
- package/src/services/assets/browser-bundle.service.js +17 -5
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +4 -4
- package/src/services/invalidation/development-invalidation.service.d.ts +20 -2
- package/src/services/invalidation/development-invalidation.service.js +56 -2
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +5 -17
- package/src/services/module-loading/page-module-import.service.d.ts +5 -1
- package/src/services/module-loading/page-module-import.service.js +96 -45
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +61 -0
- package/src/services/module-loading/route-module-build-manifest.js +116 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +122 -0
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/static-site-generator/README.md +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +22 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +17 -20
- package/src/static-site-generator/static-site-generator.js +188 -85
- package/src/types/internal-types.d.ts +16 -9
- package/src/types/public-types.d.ts +144 -40
- package/src/utils/parse-cli-args.d.ts +2 -0
- package/src/utils/parse-cli-args.js +6 -0
- package/src/utils/server-utils.module.d.ts +3 -2
- package/src/utils/server-utils.module.js +5 -6
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +48 -0
- package/src/watchers/project-watcher-ignore.d.ts +11 -0
- package/src/watchers/project-watcher-ignore.js +16 -0
- package/src/watchers/project-watcher.d.ts +26 -3
- package/src/watchers/project-watcher.js +132 -30
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { mergeBrowserRuntimeManifests } from "./browser-runtime-manifest.js";
|
|
2
|
+
import { appLogger } from "../global/app-logger.js";
|
|
3
|
+
function patchAppRuntime(appConfig, patch) {
|
|
4
|
+
appConfig.runtime = {
|
|
5
|
+
...appConfig.runtime ?? {},
|
|
6
|
+
...patch
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function registerRuntimePlugins(appConfig, onRuntimePlugin) {
|
|
10
|
+
for (const loader of appConfig.loaders.values()) {
|
|
11
|
+
onRuntimePlugin?.(loader);
|
|
12
|
+
}
|
|
13
|
+
for (const processor of appConfig.processors.values()) {
|
|
14
|
+
if (processor.plugins) {
|
|
15
|
+
for (const plugin of processor.plugins) {
|
|
16
|
+
onRuntimePlugin?.(plugin);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const integration of appConfig.integrations) {
|
|
21
|
+
for (const plugin of integration.plugins) {
|
|
22
|
+
onRuntimePlugin?.(plugin);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function collectConfiguredAppBuildManifestContributions(appConfig) {
|
|
27
|
+
const runtimePlugins = [];
|
|
28
|
+
const browserBundlePlugins = [];
|
|
29
|
+
const browserRuntimeManifests = [];
|
|
30
|
+
for (const processor of appConfig.processors.values()) {
|
|
31
|
+
await processor.prepareBuildContributions();
|
|
32
|
+
if (processor.plugins) {
|
|
33
|
+
runtimePlugins.push(...processor.plugins);
|
|
34
|
+
}
|
|
35
|
+
if (processor.buildPlugins) {
|
|
36
|
+
browserBundlePlugins.push(...processor.buildPlugins);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const integration of appConfig.integrations) {
|
|
40
|
+
integration.setConfig(appConfig);
|
|
41
|
+
await integration.prepareBuildContributions();
|
|
42
|
+
runtimePlugins.push(...integration.plugins ?? []);
|
|
43
|
+
browserBundlePlugins.push(...integration.browserBuildPlugins ?? []);
|
|
44
|
+
browserRuntimeManifests.push(integration.browserRuntimeManifest);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
runtimePlugins,
|
|
48
|
+
browserBundlePlugins,
|
|
49
|
+
browserRuntimeManifest: mergeBrowserRuntimeManifests(...browserRuntimeManifests)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function setupAppRuntimePlugins(options) {
|
|
53
|
+
if (options.appConfig.runtime?.runtimeAssetsPrepared) {
|
|
54
|
+
appLogger.debug("Skipped setupAppRuntimePlugins: runtime assets already prepared");
|
|
55
|
+
registerRuntimePlugins(options.appConfig, options.onRuntimePlugin);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
appLogger.debugTime("setupAppRuntimePlugins");
|
|
59
|
+
try {
|
|
60
|
+
for (const loader of options.appConfig.loaders.values()) {
|
|
61
|
+
options.onRuntimePlugin?.(loader);
|
|
62
|
+
}
|
|
63
|
+
for (const processor of options.appConfig.processors.values()) {
|
|
64
|
+
await processor.setup();
|
|
65
|
+
if (processor.plugins) {
|
|
66
|
+
for (const plugin of processor.plugins) {
|
|
67
|
+
options.onRuntimePlugin?.(plugin);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const integration of options.appConfig.integrations) {
|
|
72
|
+
integration.setConfig(options.appConfig);
|
|
73
|
+
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
74
|
+
await integration.setup();
|
|
75
|
+
for (const plugin of integration.plugins) {
|
|
76
|
+
options.onRuntimePlugin?.(plugin);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
patchAppRuntime(options.appConfig, { runtimeAssetsPrepared: true });
|
|
80
|
+
} finally {
|
|
81
|
+
appLogger.debugTimeEnd("setupAppRuntimePlugins");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
collectConfiguredAppBuildManifestContributions,
|
|
86
|
+
setupAppRuntimePlugins
|
|
87
|
+
};
|
|
@@ -9,274 +9,17 @@
|
|
|
9
9
|
* {@link ViteHostBuildAdapter} (a host-owned boundary marker that throws
|
|
10
10
|
* on direct use, for host runtimes that own their own build pipeline).
|
|
11
11
|
* - `BuildExecutor` — the runtime-facing facade stored on
|
|
12
|
-
* `appConfig.runtime.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* and mutate the active adapter per `EcoPagesAppConfig`.
|
|
12
|
+
* `appConfig.runtime.buildRuntime` via profile-based accessors.
|
|
13
|
+
* - App-owned helpers (`getAppBuildAdapter` and the `set*` counterparts) —
|
|
14
|
+
* the supported way for runtime code to read and mutate the active adapter
|
|
15
|
+
* per `EcoPagesAppConfig`. Profile executors live on
|
|
16
|
+
* `appConfig.runtime.buildRuntime`.
|
|
18
17
|
*/
|
|
19
18
|
import type { EcoBuildPlugin } from './build-types.js';
|
|
19
|
+
import { type BuildAdapter, type BuildExecutor, type BuildOptions, type BuildOwnership, type BuildResult, type BuildTranspileOptions, type BuildTranspileProfile } from './build-contracts.js';
|
|
20
|
+
export type { BuildAdapter, BuildDependencyGraph, BuildExecutor, BuildLog, BuildOptions, BuildOutput, BuildOwnership, BuildResult, BuildTranspileOptions, BuildTranspileProfile, } from './build-contracts.js';
|
|
20
21
|
import { type AppBuildManifest } from './build-manifest.js';
|
|
21
22
|
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
22
|
-
import type { IHmrManager } from '../types/public-types.js';
|
|
23
|
-
/**
|
|
24
|
-
* Which backend owns the app's build pipeline.
|
|
25
|
-
*
|
|
26
|
-
* - `'rolldown'`: the default. Ecopages runs the build directly through
|
|
27
|
-
* its bundler-backed adapter.
|
|
28
|
-
* - `'rolldown-dev'`: uses Rolldown's DevEngine for cached incremental
|
|
29
|
-
* rebuilds. Ideal for HMR and watch mode where the same entrypoints
|
|
30
|
-
* are rebuilt repeatedly.
|
|
31
|
-
* - `'vite-host'`: a host runtime owns the build. {@link ViteHostBuildAdapter}
|
|
32
|
-
* is exposed as a boundary marker; any direct call into it throws.
|
|
33
|
-
*/
|
|
34
|
-
export type BuildOwnership = 'vite-host' | 'rolldown' | 'rolldown-dev';
|
|
35
|
-
/**
|
|
36
|
-
* A single message emitted by the build backend.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* Today this only carries `message`. Severity and structured fields
|
|
40
|
-
* belong in a future schema bump; the current shape mirrors the
|
|
41
|
-
* bundler's log output 1:1.
|
|
42
|
-
*/
|
|
43
|
-
export interface BuildLog {
|
|
44
|
-
message: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* A single artifact emitted by the build backend.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* `path` is the absolute on-disk path of the emitted file. For
|
|
51
|
-
* filename templates that include a content-hash token, the bundler
|
|
52
|
-
* returns the concrete resolved path (not the template), so callers
|
|
53
|
-
* can read the file directly.
|
|
54
|
-
*/
|
|
55
|
-
export interface BuildOutput {
|
|
56
|
-
path: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Per-entrypoint dependency metadata surfaced alongside a build.
|
|
60
|
-
*
|
|
61
|
-
* @remarks
|
|
62
|
-
* Populated from the bundler's per-chunk module list and exposed as a
|
|
63
|
-
* normalized absolute-path map. Consumers (HMR invalidation, the build
|
|
64
|
-
* manifest) read this without needing to know which adapter produced
|
|
65
|
-
* it. The shape is preserved across adapters so historical callers
|
|
66
|
-
* continue to compile.
|
|
67
|
-
*/
|
|
68
|
-
export interface BuildDependencyGraph {
|
|
69
|
-
/**
|
|
70
|
-
* Normalized absolute entrypoint path mapped to every normalized
|
|
71
|
-
* absolute source input that contributed to that entrypoint's
|
|
72
|
-
* output, including the entrypoint itself.
|
|
73
|
-
*/
|
|
74
|
-
entrypoints: Record<string, string[]>;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* The full result of one `BuildAdapter.build` call.
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* `success === false` means the build failed and `outputs` will be
|
|
81
|
-
* empty. Inspect `logs` for the error message; the original `Error` is
|
|
82
|
-
* already normalized into `BuildLog` shape.
|
|
83
|
-
*/
|
|
84
|
-
export interface BuildResult {
|
|
85
|
-
success: boolean;
|
|
86
|
-
logs: BuildLog[];
|
|
87
|
-
outputs: BuildOutput[];
|
|
88
|
-
/**
|
|
89
|
-
* Per-entrypoint dependency metadata, when the backend produced it.
|
|
90
|
-
* Some backends (notably the Vite-host boundary marker) leave this
|
|
91
|
-
* undefined; callers must treat that as a valid state and fall
|
|
92
|
-
* back deterministically.
|
|
93
|
-
*/
|
|
94
|
-
dependencyGraph?: BuildDependencyGraph;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Options accepted by every `BuildAdapter.build` call.
|
|
98
|
-
*
|
|
99
|
-
* @remarks
|
|
100
|
-
* Fields that the adapter can forward are honored; fields that cannot
|
|
101
|
-
* (currently `splitting`, `bundle`, and `outbase`) are accepted so
|
|
102
|
-
* call-sites compile, but the adapter ignores them. See each field's
|
|
103
|
-
* docstring for the current behavior.
|
|
104
|
-
*/
|
|
105
|
-
export interface BuildOptions {
|
|
106
|
-
/**
|
|
107
|
-
* Absolute or context-root-relative source files that begin the build graph.
|
|
108
|
-
*
|
|
109
|
-
* Use a record (key → source path) when the caller needs to control chunk
|
|
110
|
-
* names. Keys become the `[name]` token in `naming`, which lets the caller
|
|
111
|
-
* embed path information that the bundler would otherwise strip.
|
|
112
|
-
*/
|
|
113
|
-
entrypoints: string[] | Record<string, string>;
|
|
114
|
-
/** Output directory. Defaults to `dist/assets` when omitted. */
|
|
115
|
-
outdir?: string;
|
|
116
|
-
/**
|
|
117
|
-
* Base directory for `[dir]` placeholders in `naming`. Currently
|
|
118
|
-
* the bundled adapter derives the base from `root` directly and
|
|
119
|
-
* ignores this field.
|
|
120
|
-
*/
|
|
121
|
-
outbase?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Filename pattern for entrypoints. The bundled adapter honors
|
|
124
|
-
* `[name]`, `[hash]`, and `[ext]`. The `[dir]` token is stripped
|
|
125
|
-
* before forwarding to the bundler (rolldown does not implement it);
|
|
126
|
-
* callers that need directory structure preserved should use the
|
|
127
|
-
* record form of `entrypoints` so each key becomes its own chunk.
|
|
128
|
-
* When omitted, the bundler's default applies.
|
|
129
|
-
*/
|
|
130
|
-
naming?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Package export conditions to honor during resolution
|
|
133
|
-
* (e.g. `['import', 'browser', 'default']`).
|
|
134
|
-
*/
|
|
135
|
-
conditions?: string[];
|
|
136
|
-
/**
|
|
137
|
-
* Global identifier replacements. Honored by the bundled adapter.
|
|
138
|
-
*/
|
|
139
|
-
define?: Record<string, string>;
|
|
140
|
-
/** Run the bundler's minifier. Off by default. */
|
|
141
|
-
minify?: boolean;
|
|
142
|
-
/** Enable the bundler's tree-shaker. Defaults to `true`. */
|
|
143
|
-
treeshaking?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Output target family. Accepted values: `'browser'`, `'node'`,
|
|
146
|
-
* anything else falls through to a platform-neutral setup.
|
|
147
|
-
*/
|
|
148
|
-
target?: string;
|
|
149
|
-
/** Output module format. Accepted: `'esm'`, `'cjs'`, `'iife'`. */
|
|
150
|
-
format?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Source map mode. Accepted: `'none'`, `'inline'`, `'external'`,
|
|
153
|
-
* `'linked'`. Anything else maps to the bundler's default (linked).
|
|
154
|
-
*/
|
|
155
|
-
sourcemap?: string;
|
|
156
|
-
/**
|
|
157
|
-
* Historical code-splitting flag. Currently a no-op on the bundled
|
|
158
|
-
* adapter: the bundler splits by default and this flag is not
|
|
159
|
-
* forwarded. See the per-chunk naming convention in the adapter for
|
|
160
|
-
* the available control.
|
|
161
|
-
*/
|
|
162
|
-
splitting?: boolean;
|
|
163
|
-
/** Project root used to resolve relative paths and the tsconfig lookup. */
|
|
164
|
-
root?: string;
|
|
165
|
-
/**
|
|
166
|
-
* Historical bundle flag. Currently a no-op on the bundled adapter:
|
|
167
|
-
* the bundler always bundles. Accepted so call-sites compile.
|
|
168
|
-
*/
|
|
169
|
-
bundle?: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Treat `node_modules` packages as external. Honored by the bundled
|
|
172
|
-
* adapter.
|
|
173
|
-
*/
|
|
174
|
-
externalPackages?: boolean;
|
|
175
|
-
/** Explicit list of module specifiers to leave as external imports. */
|
|
176
|
-
external?: string[];
|
|
177
|
-
/**
|
|
178
|
-
* JSX runtime configuration. Mirrors the bundler's `jsx` option shape.
|
|
179
|
-
*/
|
|
180
|
-
jsx?: {
|
|
181
|
-
development?: boolean;
|
|
182
|
-
factory?: string;
|
|
183
|
-
fragment?: string;
|
|
184
|
-
importSource?: string;
|
|
185
|
-
runtime?: 'classic' | 'automatic';
|
|
186
|
-
sideEffects?: boolean;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Runtime-agnostic `EcoBuildPlugin[]` to attach to this build. The
|
|
190
|
-
* bundled adapter translates the array via the rolldown plugin
|
|
191
|
-
* bridge.
|
|
192
|
-
*/
|
|
193
|
-
plugins?: EcoBuildPlugin[];
|
|
194
|
-
/**
|
|
195
|
-
* Escape hatch for backends that need to forward unknown options
|
|
196
|
-
* to their underlying driver. Consumers should prefer the typed
|
|
197
|
-
* fields above.
|
|
198
|
-
*/
|
|
199
|
-
[key: string]: unknown;
|
|
200
|
-
}
|
|
201
|
-
/** Stable profile identifiers for `BuildAdapter.getTranspileOptions`. */
|
|
202
|
-
export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
|
|
203
|
-
/**
|
|
204
|
-
* Resolved transpile settings for a given profile.
|
|
205
|
-
*
|
|
206
|
-
* @remarks
|
|
207
|
-
* The three fields map 1:1 to the trio the HMR and browser-script
|
|
208
|
-
* code paths look at: target platform, output format, and source-map
|
|
209
|
-
* mode. Today the bundled adapter returns identical defaults for all
|
|
210
|
-
* three profiles; the type is kept open so per-profile tuning can
|
|
211
|
-
* land without breaking callers.
|
|
212
|
-
*/
|
|
213
|
-
export interface BuildTranspileOptions {
|
|
214
|
-
target: string;
|
|
215
|
-
format: string;
|
|
216
|
-
sourcemap: string;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Low-level build backend contract.
|
|
220
|
-
*
|
|
221
|
-
* @remarks
|
|
222
|
-
* One instance is owned by each `EcoPagesAppConfig` (see
|
|
223
|
-
* {@link getAppBuildAdapter}). Two implementations exist: the bundled
|
|
224
|
-
* adapter does the work; {@link ViteHostBuildAdapter} is a host-owned
|
|
225
|
-
* boundary marker that throws on direct use.
|
|
226
|
-
*/
|
|
227
|
-
export interface BuildAdapter {
|
|
228
|
-
/** Which backend owns this adapter. Used for routing decisions in app helpers. */
|
|
229
|
-
readonly ownership?: BuildOwnership;
|
|
230
|
-
/**
|
|
231
|
-
* Run one build.
|
|
232
|
-
*
|
|
233
|
-
* @remarks
|
|
234
|
-
* Implementations are expected to be safe to call from any caller.
|
|
235
|
-
* Concurrent calls are not guaranteed to be serialized by the
|
|
236
|
-
* adapter itself; the dev-watch pipeline wraps the adapter in
|
|
237
|
-
* {@link SerializedBuildExecutor} when it needs FIFO ordering.
|
|
238
|
-
*
|
|
239
|
-
* Returns a `BuildResult` with `success: false` on failure; the
|
|
240
|
-
* thrown-error variant (`buildOrThrow`) is reserved for callers
|
|
241
|
-
* that need the original `Error` object.
|
|
242
|
-
*/
|
|
243
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
244
|
-
/**
|
|
245
|
-
* Resolve a module specifier against the project's `rootDir`.
|
|
246
|
-
*
|
|
247
|
-
* @remarks
|
|
248
|
-
* Used by the source-loading services when they need to know the
|
|
249
|
-
* absolute path of a specifier without performing a full build.
|
|
250
|
-
*/
|
|
251
|
-
resolve(importPath: string, rootDir: string): string;
|
|
252
|
-
/**
|
|
253
|
-
* Resolve transpile settings for a known profile.
|
|
254
|
-
*
|
|
255
|
-
* @remarks
|
|
256
|
-
* Today the bundled adapter returns identical defaults for all
|
|
257
|
-
* profiles. The profile argument is kept so per-profile tuning
|
|
258
|
-
* can land without breaking callers.
|
|
259
|
-
*/
|
|
260
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Runtime-facing facade for issuing builds.
|
|
264
|
-
*
|
|
265
|
-
* @remarks
|
|
266
|
-
* Strictly narrower than {@link BuildAdapter}: it only exposes `build`.
|
|
267
|
-
* This is the shape stored on `appConfig.runtime.buildExecutor` and
|
|
268
|
-
* passed across the dev-watch and server-module-loading seams, so
|
|
269
|
-
* callers cannot accidentally depend on `resolve` or
|
|
270
|
-
* `getTranspileOptions`.
|
|
271
|
-
*
|
|
272
|
-
* In production and non-watch flows the executor is the adapter
|
|
273
|
-
* itself. In development watch flows the executor is a
|
|
274
|
-
* {@link SerializedBuildExecutor} wrapping the adapter so dev-watch
|
|
275
|
-
* pipelines are FIFO-serialized.
|
|
276
|
-
*/
|
|
277
|
-
export interface BuildExecutor {
|
|
278
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
279
|
-
}
|
|
280
23
|
/**
|
|
281
24
|
* Wraps a {@link BuildExecutor} so each call to `build` receives the
|
|
282
25
|
* union of the caller's `options.plugins` and the plugins sourced
|
|
@@ -287,9 +30,9 @@ export interface BuildExecutor {
|
|
|
287
30
|
* `ConfigBuilder` stores a raw adapter on
|
|
288
31
|
* `appConfig.runtime.buildAdapter` and the
|
|
289
32
|
* `installAppRuntimeBuildExecutor` step wraps that adapter with this
|
|
290
|
-
* helper. Callers that issue builds
|
|
291
|
-
* `appConfig.
|
|
292
|
-
* further ceremony.
|
|
33
|
+
* helper. Callers that issue builds through
|
|
34
|
+
* `requireBuildRuntime(appConfig).getProfile(...)` get the merged plugin set
|
|
35
|
+
* without further ceremony.
|
|
293
36
|
*/
|
|
294
37
|
export declare function withBuildExecutorPlugins(executor: BuildExecutor, getPlugins: () => EcoBuildPlugin[]): BuildExecutor;
|
|
295
38
|
/**
|
|
@@ -415,43 +158,7 @@ export declare function createConfiguredAppBuildManifest(appConfig: EcoPagesAppC
|
|
|
415
158
|
* caller-supplied contribution input.
|
|
416
159
|
*/
|
|
417
160
|
export declare function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void;
|
|
418
|
-
|
|
419
|
-
* Collects the build-facing processor and integration contributions
|
|
420
|
-
* that should be sealed into the app manifest during config
|
|
421
|
-
* finalization.
|
|
422
|
-
*
|
|
423
|
-
* @remarks
|
|
424
|
-
* Runs `prepareBuildContributions()` on every processor and
|
|
425
|
-
* integration. Runtime-only side effects (HMR registration, cache
|
|
426
|
-
* prewarming, runtime-origin wiring) belong to the startup path and
|
|
427
|
-
* must not be triggered here; use {@link setupAppRuntimePlugins} for
|
|
428
|
-
* those.
|
|
429
|
-
*
|
|
430
|
-
* @returns The new manifest's runtime / browser / browser-runtime-manifest
|
|
431
|
-
* contribution buckets. Caller seals them into a manifest via
|
|
432
|
-
* {@link updateAppBuildManifest}.
|
|
433
|
-
*/
|
|
434
|
-
export declare function collectConfiguredAppBuildManifestContributions(appConfig: EcoPagesAppConfig): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins' | 'browserRuntimeManifest'>>;
|
|
435
|
-
/**
|
|
436
|
-
* Runs runtime-only processor and integration setup against an already
|
|
437
|
-
* sealed app manifest.
|
|
438
|
-
*
|
|
439
|
-
* @remarks
|
|
440
|
-
* Startup paths call this after `ConfigBuilder.build` has finalized
|
|
441
|
-
* the manifest. The manifest is reused as-is; this helper only performs
|
|
442
|
-
* the runtime side effects that need live startup context (cache
|
|
443
|
-
* prewarming, runtime-origin wiring, HMR manager attachment).
|
|
444
|
-
*
|
|
445
|
-
* Loaders, processors, and integrations are visited in that order;
|
|
446
|
-
* each one's plugins are forwarded to the optional `onRuntimePlugin`
|
|
447
|
-
* callback so callers can attach to every plugin discovered.
|
|
448
|
-
*/
|
|
449
|
-
export declare function setupAppRuntimePlugins(options: {
|
|
450
|
-
appConfig: EcoPagesAppConfig;
|
|
451
|
-
runtimeOrigin: string;
|
|
452
|
-
hmrManager?: IHmrManager;
|
|
453
|
-
onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
|
|
454
|
-
}): Promise<void>;
|
|
161
|
+
export { collectConfiguredAppBuildManifestContributions, setupAppRuntimePlugins, } from './app-build-manifest-runtime.js';
|
|
455
162
|
/**
|
|
456
163
|
* Returns the server-bundle plugin list for one app/runtime instance.
|
|
457
164
|
*
|
|
@@ -468,28 +175,19 @@ export declare function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig):
|
|
|
468
175
|
* Reads from the app's sealed build manifest. The browser-bundle
|
|
469
176
|
* manifest is the source of truth for which plugins participate in the
|
|
470
177
|
* browser bundle.
|
|
471
|
-
*/
|
|
472
|
-
export declare function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
|
|
473
|
-
/**
|
|
474
|
-
* Returns the executor owned by an app/runtime instance.
|
|
475
178
|
*
|
|
476
|
-
* @
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
* a {@link SerializedBuildExecutor} via
|
|
480
|
-
* {@link installAppRuntimeBuildExecutor}.
|
|
179
|
+
* Plugins whose `name` matches a registered {@link EcoSourceTransform} are
|
|
180
|
+
* excluded here because browser builds run those transforms via the Rolldown
|
|
181
|
+
* bridge post-load pass instead of as competing `onLoad` handlers.
|
|
481
182
|
*/
|
|
482
|
-
export declare function
|
|
483
|
-
/** Installs the executor that should serve future builds for one app instance. */
|
|
484
|
-
export declare function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void;
|
|
183
|
+
export declare function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
|
|
485
184
|
/**
|
|
486
185
|
* Runs a build through the active pipeline.
|
|
487
186
|
*
|
|
488
187
|
* @remarks
|
|
489
188
|
* `executor` defaults to the default-bundler adapter for non-app-aware
|
|
490
|
-
* callsites. App-aware code should pass
|
|
491
|
-
*
|
|
492
|
-
* per-app pipeline.
|
|
189
|
+
* callsites. App-aware code should pass a profile executor from
|
|
190
|
+
* {@link requireBuildRuntime} to honor the per-app pipeline.
|
|
493
191
|
*/
|
|
494
192
|
export declare function build(options: BuildOptions, executor?: BuildExecutor): Promise<BuildResult>;
|
|
495
193
|
/**
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { mergeBrowserRuntimeManifests } from "./browser-runtime-manifest.js";
|
|
2
1
|
import { normalizeNodeRuntimeBuildOutputs } from "./runtime-build-output-normalizer.js";
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
} from "./build-contracts.js";
|
|
4
4
|
import {
|
|
5
5
|
createAppBuildManifest,
|
|
6
6
|
getBrowserBuildPlugins,
|
|
7
7
|
getServerBuildPlugins
|
|
8
8
|
} from "./build-manifest.js";
|
|
9
|
+
import { getAppSourceTransforms } from "../plugins/source-transform.js";
|
|
10
|
+
import { createAliasResolverPlugin } from "../plugins/alias-resolver-plugin.js";
|
|
11
|
+
import { getJsxOwnershipPlugins } from "./jsx-ownership-plugins.js";
|
|
9
12
|
import { createRolldownBuildAdapter } from "./rolldown-build-adapter.js";
|
|
10
|
-
import { createRolldownDevBuildAdapter } from "./rolldown-dev-build-adapter.js";
|
|
11
13
|
function mergeBuildExecutorPlugins(existing, appPlugins) {
|
|
12
14
|
if (!existing || existing.length === 0) {
|
|
13
15
|
return appPlugins;
|
|
@@ -35,6 +37,12 @@ function withBuildExecutorPlugins(executor, getPlugins) {
|
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
}
|
|
40
|
+
function patchAppRuntime(appConfig, patch) {
|
|
41
|
+
appConfig.runtime = {
|
|
42
|
+
...appConfig.runtime ?? {},
|
|
43
|
+
...patch
|
|
44
|
+
};
|
|
45
|
+
}
|
|
38
46
|
function createHostOwnedBuildError(methodName) {
|
|
39
47
|
return new Error(
|
|
40
48
|
`Vite-hosted builds are owned by the host runtime. Core cannot ${methodName} through the host-owned compatibility adapter.`
|
|
@@ -59,8 +67,6 @@ function createBuildAdapter(options) {
|
|
|
59
67
|
switch (options?.ownership ?? "rolldown") {
|
|
60
68
|
case "vite-host":
|
|
61
69
|
return createViteHostBuildAdapter();
|
|
62
|
-
case "rolldown-dev":
|
|
63
|
-
return createRolldownDevBuildAdapter();
|
|
64
70
|
case "rolldown":
|
|
65
71
|
default:
|
|
66
72
|
return createRolldownBuildAdapter();
|
|
@@ -79,31 +85,24 @@ function getAppBuildOwnership(appConfig) {
|
|
|
79
85
|
return appConfig.runtime?.buildOwnership ?? getBuildAdapterOwnership(appConfig.runtime?.buildAdapter);
|
|
80
86
|
}
|
|
81
87
|
function setAppBuildOwnership(appConfig, buildOwnership) {
|
|
82
|
-
appConfig
|
|
83
|
-
...appConfig.runtime ?? {},
|
|
84
|
-
buildOwnership
|
|
85
|
-
};
|
|
88
|
+
patchAppRuntime(appConfig, { buildOwnership });
|
|
86
89
|
}
|
|
87
90
|
function getAppBuildAdapter(appConfig) {
|
|
88
91
|
return appConfig.runtime?.buildAdapter ?? getDefaultBuildAdapter(getAppBuildOwnership(appConfig));
|
|
89
92
|
}
|
|
90
93
|
function setAppBuildAdapter(appConfig, buildAdapter) {
|
|
91
|
-
appConfig
|
|
92
|
-
...appConfig.runtime ?? {},
|
|
94
|
+
patchAppRuntime(appConfig, {
|
|
93
95
|
buildOwnership: getBuildAdapterOwnership(buildAdapter),
|
|
94
96
|
buildAdapter
|
|
95
|
-
};
|
|
97
|
+
});
|
|
96
98
|
}
|
|
97
99
|
function getAppBuildManifest(appConfig) {
|
|
98
100
|
return appConfig.runtime?.buildManifest ?? createAppBuildManifest({
|
|
99
|
-
loaderPlugins: Array.from(appConfig.loaders
|
|
101
|
+
loaderPlugins: Array.from(appConfig.loaders?.values() ?? [])
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
function setAppBuildManifest(appConfig, buildManifest) {
|
|
103
|
-
appConfig
|
|
104
|
-
...appConfig.runtime ?? {},
|
|
105
|
-
buildManifest
|
|
106
|
-
};
|
|
105
|
+
patchAppRuntime(appConfig, { buildManifest });
|
|
107
106
|
}
|
|
108
107
|
function createConfiguredAppBuildManifest(appConfig, input) {
|
|
109
108
|
return createAppBuildManifest({
|
|
@@ -116,85 +115,22 @@ function createConfiguredAppBuildManifest(appConfig, input) {
|
|
|
116
115
|
function updateAppBuildManifest(appConfig, input) {
|
|
117
116
|
setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
for (const processor of appConfig.processors.values()) {
|
|
124
|
-
await processor.prepareBuildContributions();
|
|
125
|
-
if (processor.plugins) {
|
|
126
|
-
runtimePlugins.push(...processor.plugins);
|
|
127
|
-
}
|
|
128
|
-
if (processor.buildPlugins) {
|
|
129
|
-
browserBundlePlugins.push(...processor.buildPlugins);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
for (const integration of appConfig.integrations) {
|
|
133
|
-
integration.setConfig(appConfig);
|
|
134
|
-
await integration.prepareBuildContributions();
|
|
135
|
-
runtimePlugins.push(...integration.plugins ?? []);
|
|
136
|
-
browserBundlePlugins.push(...integration.browserBuildPlugins ?? []);
|
|
137
|
-
browserRuntimeManifests.push(integration.browserRuntimeManifest);
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
runtimePlugins,
|
|
141
|
-
browserBundlePlugins,
|
|
142
|
-
browserRuntimeManifest: mergeBrowserRuntimeManifests(...browserRuntimeManifests)
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
async function setupAppRuntimePlugins(options) {
|
|
146
|
-
for (const loader of options.appConfig.loaders.values()) {
|
|
147
|
-
options.onRuntimePlugin?.(loader);
|
|
148
|
-
}
|
|
149
|
-
for (const processor of options.appConfig.processors.values()) {
|
|
150
|
-
await processor.setup();
|
|
151
|
-
if (processor.plugins) {
|
|
152
|
-
for (const plugin of processor.plugins) {
|
|
153
|
-
options.onRuntimePlugin?.(plugin);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
for (const integration of options.appConfig.integrations) {
|
|
158
|
-
integration.setConfig(options.appConfig);
|
|
159
|
-
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
160
|
-
if (options.hmrManager) {
|
|
161
|
-
integration.setHmrManager(options.hmrManager);
|
|
162
|
-
}
|
|
163
|
-
await integration.setup();
|
|
164
|
-
for (const plugin of integration.plugins) {
|
|
165
|
-
options.onRuntimePlugin?.(plugin);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
118
|
+
import {
|
|
119
|
+
collectConfiguredAppBuildManifestContributions,
|
|
120
|
+
setupAppRuntimePlugins
|
|
121
|
+
} from "./app-build-manifest-runtime.js";
|
|
169
122
|
function getAppServerBuildPlugins(appConfig) {
|
|
170
|
-
|
|
123
|
+
const srcDir = appConfig.absolutePaths?.srcDir;
|
|
124
|
+
const aliasPlugin = srcDir ? [createAliasResolverPlugin(srcDir)] : [];
|
|
125
|
+
return [...aliasPlugin, ...getServerBuildPlugins(getAppBuildManifest(appConfig))];
|
|
171
126
|
}
|
|
172
127
|
function getAppBrowserBuildPlugins(appConfig) {
|
|
173
128
|
const manifest = getAppBuildManifest(appConfig);
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
(integration) => integration.extensions.filter((extension) => extension.endsWith(".tsx") || extension.endsWith(".jsx")).map((extension) => ({ integration, extension }))
|
|
180
|
-
).sort((left, right) => right.extension.length - left.extension.length);
|
|
181
|
-
return jsxExtensions.map(
|
|
182
|
-
({ integration, extension }) => createForeignJsxOverridePlugin({
|
|
183
|
-
hostJsxImportSource: integration.jsxImportSource,
|
|
184
|
-
foreignExtensions: [extension],
|
|
185
|
-
excludeExtensions: jsxExtensions.filter((candidate) => candidate.extension.length > extension.length).filter((candidate) => candidate.extension.endsWith(extension)).map((candidate) => candidate.extension),
|
|
186
|
-
name: `ecopages-jsx-ownership-${integration.name}-${extension.replace(/[^a-zA-Z0-9]+/g, "-")}`
|
|
187
|
-
})
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
function getAppBuildExecutor(appConfig) {
|
|
191
|
-
return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
|
|
192
|
-
}
|
|
193
|
-
function setAppBuildExecutor(appConfig, buildExecutor) {
|
|
194
|
-
appConfig.runtime = {
|
|
195
|
-
...appConfig.runtime ?? {},
|
|
196
|
-
buildExecutor
|
|
197
|
-
};
|
|
129
|
+
const sourceTransformNames = new Set(getAppSourceTransforms(appConfig).map((transform) => transform.name));
|
|
130
|
+
const browserPlugins = getBrowserBuildPlugins(manifest).filter((plugin) => !sourceTransformNames.has(plugin.name));
|
|
131
|
+
const srcDir = appConfig.absolutePaths?.srcDir;
|
|
132
|
+
const aliasPlugin = srcDir ? [createAliasResolverPlugin(srcDir)] : [];
|
|
133
|
+
return [...aliasPlugin, ...browserPlugins, ...getJsxOwnershipPlugins(appConfig)];
|
|
198
134
|
}
|
|
199
135
|
function build(options, executor = defaultRolldownBuildAdapter) {
|
|
200
136
|
return executor.build(options).then((result) => {
|
|
@@ -225,7 +161,6 @@ export {
|
|
|
225
161
|
defaultViteHostBuildAdapter,
|
|
226
162
|
getAppBrowserBuildPlugins,
|
|
227
163
|
getAppBuildAdapter,
|
|
228
|
-
getAppBuildExecutor,
|
|
229
164
|
getAppBuildManifest,
|
|
230
165
|
getAppBuildOwnership,
|
|
231
166
|
getAppServerBuildPlugins,
|
|
@@ -234,7 +169,6 @@ export {
|
|
|
234
169
|
getDefaultBuildAdapter,
|
|
235
170
|
getTranspileOptions,
|
|
236
171
|
setAppBuildAdapter,
|
|
237
|
-
setAppBuildExecutor,
|
|
238
172
|
setAppBuildManifest,
|
|
239
173
|
setAppBuildOwnership,
|
|
240
174
|
setupAppRuntimePlugins,
|