@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
|
@@ -2,7 +2,12 @@ import path from "node:path";
|
|
|
2
2
|
import chokidar, {} from "chokidar";
|
|
3
3
|
import { fileSystem } from "@ecopages/file-system";
|
|
4
4
|
import { appLogger } from "../global/app-logger.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
DevelopmentInvalidationService
|
|
7
|
+
} from "../services/invalidation/development-invalidation.service.js";
|
|
8
|
+
import { isRegisteredScriptEntrypoint } from "../hmr/hmr-entrypoint-output.js";
|
|
9
|
+
import { resolveInternalExecutionDir } from "../utils/resolve-work-dir.js";
|
|
10
|
+
import { createProjectWatcherIgnorePredicate } from "./project-watcher-ignore.js";
|
|
6
11
|
class ProjectWatcher {
|
|
7
12
|
/**
|
|
8
13
|
* Duplicate identical watcher events within this window are ignored.
|
|
@@ -16,19 +21,33 @@ class ProjectWatcher {
|
|
|
16
21
|
refreshRouterRoutesCallback;
|
|
17
22
|
hmrManager;
|
|
18
23
|
bridge;
|
|
24
|
+
hostOwnsDevClient;
|
|
19
25
|
invalidationService;
|
|
26
|
+
changeDebounceMs;
|
|
20
27
|
watcher = null;
|
|
21
|
-
|
|
28
|
+
closed = false;
|
|
29
|
+
pendingChangeEvents = /* @__PURE__ */ new Map();
|
|
22
30
|
changeQueue = Promise.resolve();
|
|
23
|
-
constructor({
|
|
31
|
+
constructor({
|
|
32
|
+
config,
|
|
33
|
+
refreshRouterRoutesCallback,
|
|
34
|
+
hmrManager,
|
|
35
|
+
bridge,
|
|
36
|
+
hostOwnsDevClient,
|
|
37
|
+
changeDebounceMs
|
|
38
|
+
}) {
|
|
24
39
|
this.appConfig = config;
|
|
25
40
|
this.refreshRouterRoutesCallback = refreshRouterRoutesCallback;
|
|
26
41
|
this.hmrManager = hmrManager;
|
|
27
42
|
this.bridge = bridge;
|
|
43
|
+
this.hostOwnsDevClient = hostOwnsDevClient === true;
|
|
44
|
+
const envDebounceMs = process.env.ECOPAGES_WATCH_CHANGE_DEBOUNCE_MS;
|
|
45
|
+
this.changeDebounceMs = changeDebounceMs ?? (envDebounceMs !== void 0 && envDebounceMs !== "" ? Number(envDebounceMs) : void 0) ?? ProjectWatcher.duplicateChangeWindowMs;
|
|
28
46
|
this.invalidationService = new DevelopmentInvalidationService(config);
|
|
29
47
|
this.triggerRouterRefresh = this.triggerRouterRefresh.bind(this);
|
|
30
48
|
this.handleError = this.handleError.bind(this);
|
|
31
49
|
this.handleFileChange = this.handleFileChange.bind(this);
|
|
50
|
+
this.processFileChange = this.processFileChange.bind(this);
|
|
32
51
|
}
|
|
33
52
|
/**
|
|
34
53
|
* Uncaches modules in the source directory to ensure fresh imports.
|
|
@@ -51,6 +70,12 @@ class ProjectWatcher {
|
|
|
51
70
|
isIncludeSourceFile(filePath) {
|
|
52
71
|
return this.invalidationService.isIncludeSourceFile(filePath);
|
|
53
72
|
}
|
|
73
|
+
requestBrowserReload() {
|
|
74
|
+
if (this.hostOwnsDevClient) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.bridge.reload();
|
|
78
|
+
}
|
|
54
79
|
/**
|
|
55
80
|
* Handles public directory file changes by copying only the changed file.
|
|
56
81
|
* @param filePath - Absolute path of the changed file
|
|
@@ -64,10 +89,10 @@ class ProjectWatcher {
|
|
|
64
89
|
fileSystem.ensureDir(destDir);
|
|
65
90
|
await fileSystem.copyFileAsync(filePath, destPath);
|
|
66
91
|
}
|
|
67
|
-
this.
|
|
92
|
+
this.requestBrowserReload();
|
|
68
93
|
} catch (error) {
|
|
69
94
|
appLogger.error(`Failed to copy public file: ${error instanceof Error ? error.message : String(error)}`);
|
|
70
|
-
this.
|
|
95
|
+
this.requestBrowserReload();
|
|
71
96
|
}
|
|
72
97
|
}
|
|
73
98
|
/**
|
|
@@ -77,13 +102,14 @@ class ProjectWatcher {
|
|
|
77
102
|
enqueueChange(task) {
|
|
78
103
|
const queuedTask = this.changeQueue.then(task, task);
|
|
79
104
|
this.changeQueue = queuedTask.catch(() => void 0);
|
|
105
|
+
return queuedTask;
|
|
80
106
|
}
|
|
81
107
|
/**
|
|
82
108
|
* Handles file changes by uncaching modules, refreshing routes, and delegating appropriately.
|
|
83
109
|
* Follows 5-rule priority:
|
|
84
110
|
* 0. Public directory match? -> copy file and reload
|
|
85
111
|
* 1. additionalWatchPaths match? -> reload
|
|
86
|
-
* 2. Include template source? ->
|
|
112
|
+
* 2. Include template source? -> current-page refresh via HMR after processor notifications are deferred
|
|
87
113
|
* 3. Processor-owned asset? -> processor already handled it via notification, skip HMR
|
|
88
114
|
* 4. Otherwise -> HMR strategies
|
|
89
115
|
*
|
|
@@ -96,14 +122,26 @@ class ProjectWatcher {
|
|
|
96
122
|
* @param rawPath - Path of the changed file
|
|
97
123
|
* @param event - The type of file system event
|
|
98
124
|
*/
|
|
99
|
-
|
|
125
|
+
handleFileChange(rawPath, event = "change") {
|
|
126
|
+
if (this.closed) {
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
100
129
|
const filePath = path.resolve(rawPath);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
if (this.changeDebounceMs === 0) {
|
|
131
|
+
return this.enqueueChange(() => this.processFileChange(filePath, event));
|
|
132
|
+
}
|
|
133
|
+
const existing = this.pendingChangeEvents.get(filePath);
|
|
134
|
+
if (existing) {
|
|
135
|
+
clearTimeout(existing.timer);
|
|
105
136
|
}
|
|
106
|
-
|
|
137
|
+
const timer = setTimeout(() => {
|
|
138
|
+
this.pendingChangeEvents.delete(filePath);
|
|
139
|
+
void this.enqueueChange(() => this.processFileChange(filePath, event));
|
|
140
|
+
}, this.changeDebounceMs);
|
|
141
|
+
this.pendingChangeEvents.set(filePath, { event, timer });
|
|
142
|
+
return Promise.resolve();
|
|
143
|
+
}
|
|
144
|
+
async processFileChange(filePath, event) {
|
|
107
145
|
try {
|
|
108
146
|
const plan = this.invalidationService.planFileChange(filePath);
|
|
109
147
|
if (plan.category === "public-asset") {
|
|
@@ -111,21 +149,29 @@ class ProjectWatcher {
|
|
|
111
149
|
return;
|
|
112
150
|
}
|
|
113
151
|
this.uncacheModules();
|
|
114
|
-
|
|
152
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
153
|
+
const isRegisteredScriptEdit = isRegisteredScriptEntrypoint(
|
|
154
|
+
this.hmrManager.getWatchedFiles(),
|
|
155
|
+
resolvedFilePath
|
|
156
|
+
);
|
|
157
|
+
if (plan.invalidateServerModules && !isRegisteredScriptEdit) {
|
|
115
158
|
this.invalidationService.invalidateServerModules([filePath]);
|
|
116
159
|
}
|
|
117
160
|
if (plan.refreshRoutes) {
|
|
118
161
|
await this.refreshRouterRoutesCallback();
|
|
119
162
|
}
|
|
120
|
-
if (plan.
|
|
121
|
-
this.
|
|
163
|
+
if (plan.reloadBrowser) {
|
|
164
|
+
this.requestBrowserReload();
|
|
122
165
|
return;
|
|
123
166
|
}
|
|
124
|
-
|
|
125
|
-
if (plan.
|
|
126
|
-
this.
|
|
167
|
+
const deferProcessorNotifications = plan.category === "include-source" || plan.category === "explicit-server-view" || isRegisteredScriptEdit;
|
|
168
|
+
if (deferProcessorNotifications && plan.delegateToHmr) {
|
|
169
|
+
await this.prewarmBeforeHmr(resolvedFilePath, plan);
|
|
170
|
+
await this.hmrManager.handleFileChange(filePath);
|
|
171
|
+
await this.notifyProcessors(filePath, event);
|
|
127
172
|
return;
|
|
128
173
|
}
|
|
174
|
+
await this.notifyProcessors(filePath, event);
|
|
129
175
|
if (plan.processorHandledAsset) {
|
|
130
176
|
return;
|
|
131
177
|
}
|
|
@@ -139,6 +185,42 @@ class ProjectWatcher {
|
|
|
139
185
|
}
|
|
140
186
|
}
|
|
141
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Re-imports server modules before HMR broadcast so reload/refetch does not
|
|
190
|
+
* race stale in-memory imports or custom-element registry state.
|
|
191
|
+
*/
|
|
192
|
+
async prewarmBeforeHmr(filePath, plan) {
|
|
193
|
+
if (plan.category !== "include-source" && plan.category !== "explicit-server-view") {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const modulePaths = plan.category === "include-source" ? [this.appConfig.absolutePaths.htmlTemplatePath] : [path.resolve(filePath)];
|
|
197
|
+
await this.prewarmServerModuleImports(modulePaths, { scope: "server template" });
|
|
198
|
+
}
|
|
199
|
+
async prewarmServerModuleImports(modulePaths, options) {
|
|
200
|
+
const appModuleLoader = this.appConfig.runtime?.appModuleLoader;
|
|
201
|
+
if (!appModuleLoader) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const outdir = path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules");
|
|
205
|
+
for (const modulePath of modulePaths) {
|
|
206
|
+
if (!modulePath) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
await appModuleLoader.importModule({
|
|
211
|
+
filePath: modulePath,
|
|
212
|
+
rootDir: this.appConfig.rootDir,
|
|
213
|
+
outdir,
|
|
214
|
+
externalPackages: true,
|
|
215
|
+
bypassCache: options.bypassCache
|
|
216
|
+
});
|
|
217
|
+
} catch (error) {
|
|
218
|
+
appLogger.error(
|
|
219
|
+
`Failed to prewarm ${options.scope} ${modulePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
142
224
|
/**
|
|
143
225
|
* Notifies all processors whose watch config matches the given file extension.
|
|
144
226
|
* This is called before checking processor ownership so that dependency-only
|
|
@@ -231,36 +313,37 @@ class ProjectWatcher {
|
|
|
231
313
|
if (this.watcher) {
|
|
232
314
|
return this.watcher;
|
|
233
315
|
}
|
|
234
|
-
const processorPaths =
|
|
316
|
+
const processorPaths = /* @__PURE__ */ new Set();
|
|
235
317
|
for (const processor of this.appConfig.processors.values()) {
|
|
236
318
|
const watchConfig = processor.getWatchConfig();
|
|
237
319
|
if (!watchConfig) continue;
|
|
238
|
-
|
|
320
|
+
for (const watchPath of watchConfig.paths) {
|
|
321
|
+
processorPaths.add(watchPath);
|
|
322
|
+
}
|
|
239
323
|
}
|
|
240
324
|
if (fileSystem.exists(this.appConfig.absolutePaths.includesDir)) {
|
|
241
|
-
processorPaths.
|
|
325
|
+
processorPaths.add(this.appConfig.absolutePaths.includesDir);
|
|
242
326
|
}
|
|
243
327
|
if (fileSystem.exists(this.appConfig.absolutePaths.srcDir)) {
|
|
244
|
-
processorPaths.
|
|
245
|
-
}
|
|
246
|
-
if (fileSystem.exists(this.appConfig.absolutePaths.pagesDir)) {
|
|
247
|
-
processorPaths.push(this.appConfig.absolutePaths.pagesDir);
|
|
328
|
+
processorPaths.add(this.appConfig.absolutePaths.srcDir);
|
|
248
329
|
}
|
|
249
330
|
if (fileSystem.exists(this.appConfig.absolutePaths.publicDir)) {
|
|
250
|
-
processorPaths.
|
|
331
|
+
processorPaths.add(this.appConfig.absolutePaths.publicDir);
|
|
251
332
|
}
|
|
252
|
-
|
|
253
|
-
processorPaths.
|
|
333
|
+
for (const watchPath of this.appConfig.additionalWatchPaths) {
|
|
334
|
+
processorPaths.add(watchPath);
|
|
254
335
|
}
|
|
255
|
-
|
|
336
|
+
const ignored = createProjectWatcherIgnorePredicate(this.appConfig.absolutePaths);
|
|
337
|
+
this.watcher = chokidar.watch(Array.from(processorPaths), {
|
|
256
338
|
ignoreInitial: true,
|
|
257
339
|
ignorePermissionErrors: true,
|
|
340
|
+
ignored,
|
|
258
341
|
awaitWriteFinish: {
|
|
259
342
|
stabilityThreshold: 50,
|
|
260
343
|
pollInterval: 50
|
|
261
344
|
}
|
|
262
345
|
});
|
|
263
|
-
this.watcher.on("change", (p) => this.
|
|
346
|
+
this.watcher.on("change", (p) => this.handleFileChange(p, "change")).on("add", (p) => this.handleFileChange(p, "add")).on("addDir", (p) => this.enqueueChange(() => this.triggerRouterRefresh(p))).on("unlink", (p) => this.handleFileChange(p, "unlink")).on("unlinkDir", (p) => this.enqueueChange(() => this.triggerRouterRefresh(p))).on("error", (error) => this.handleError(error));
|
|
264
347
|
for (const processor of this.appConfig.processors.values()) {
|
|
265
348
|
const watchConfig = processor.getWatchConfig();
|
|
266
349
|
if (watchConfig?.onError) {
|
|
@@ -269,6 +352,25 @@ class ProjectWatcher {
|
|
|
269
352
|
}
|
|
270
353
|
return this.watcher;
|
|
271
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Closes the active filesystem watcher subscription.
|
|
357
|
+
*
|
|
358
|
+
* @remarks
|
|
359
|
+
* Safe to call multiple times. Used when tearing down dev servers in tests
|
|
360
|
+
* and other short-lived Ecopages runtimes.
|
|
361
|
+
*/
|
|
362
|
+
async close() {
|
|
363
|
+
this.closed = true;
|
|
364
|
+
for (const pending of this.pendingChangeEvents.values()) {
|
|
365
|
+
clearTimeout(pending.timer);
|
|
366
|
+
}
|
|
367
|
+
this.pendingChangeEvents.clear();
|
|
368
|
+
if (this.watcher) {
|
|
369
|
+
await this.watcher.close();
|
|
370
|
+
this.watcher = null;
|
|
371
|
+
}
|
|
372
|
+
await this.changeQueue.catch(() => void 0);
|
|
373
|
+
}
|
|
272
374
|
}
|
|
273
375
|
export {
|
|
274
376
|
ProjectWatcher
|
|
@@ -6,21 +6,21 @@ const createMockHmrManager = () => ({
|
|
|
6
6
|
}),
|
|
7
7
|
setEnabled: vi.fn(() => {
|
|
8
8
|
}),
|
|
9
|
-
setPlugins: vi.fn(() => {
|
|
10
|
-
}),
|
|
11
9
|
registerEntrypoint: vi.fn(async () => ""),
|
|
12
|
-
registerScriptEntrypoint: vi.fn(async () =>
|
|
10
|
+
registerScriptEntrypoint: vi.fn(async () => ({
|
|
11
|
+
sourcePath: "",
|
|
12
|
+
outputPath: "",
|
|
13
|
+
outputUrl: ""
|
|
14
|
+
})),
|
|
13
15
|
registerStrategy: vi.fn(() => {
|
|
14
16
|
}),
|
|
15
17
|
isEnabled: vi.fn(() => true),
|
|
16
18
|
getOutputUrl: vi.fn(() => void 0),
|
|
17
19
|
getWatchedFiles: vi.fn(() => /* @__PURE__ */ new Map()),
|
|
18
20
|
getDistDir: vi.fn(() => ""),
|
|
19
|
-
getPlugins: vi.fn(() => []),
|
|
20
21
|
getDefaultContext: vi.fn(() => ({
|
|
21
22
|
getWatchedFiles: () => /* @__PURE__ */ new Map(),
|
|
22
23
|
getDistDir: () => "",
|
|
23
|
-
getPlugins: () => [],
|
|
24
24
|
getSrcDir: () => "",
|
|
25
25
|
getLayoutsDir: () => "",
|
|
26
26
|
getPagesDir: () => "",
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DevEngine-backed build adapter for cached incremental rebuilds.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Wraps Rolldown's experimental `DevEngine` to provide cached incremental
|
|
6
|
-
* rebuilds. Unlike the standard `RolldownBuildAdapter` which creates a new
|
|
7
|
-
* bundler for every build, this adapter keeps a `DevEngine` instance alive
|
|
8
|
-
* and reuses the internal module graph, resolver cache, and transform cache
|
|
9
|
-
* across builds.
|
|
10
|
-
*
|
|
11
|
-
* The adapter is designed for the HMR rebuild path where the same entrypoints
|
|
12
|
-
* are rebuilt repeatedly with small changes. For one-off production builds,
|
|
13
|
-
* use `RolldownBuildAdapter` instead.
|
|
14
|
-
*
|
|
15
|
-
* The first build creates the engine and runs it. Subsequent builds with the
|
|
16
|
-
* same plugin/target/format triple reuse the cached engine and call
|
|
17
|
-
* `triggerFullBuild()`. The cache key incorporates the context root, plugin
|
|
18
|
-
* names, target, and format; when any of those change, the cached engine is
|
|
19
|
-
* closed and a new one is created.
|
|
20
|
-
*
|
|
21
|
-
* Call `close()` to release the cached engine and free resources.
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
import type { BuildAdapter, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from './build-adapter.js';
|
|
26
|
-
/**
|
|
27
|
-
* Build adapter backed by Rolldown's DevEngine for cached incremental rebuilds.
|
|
28
|
-
*/
|
|
29
|
-
export declare class RolldownDevBuildAdapter implements BuildAdapter {
|
|
30
|
-
/**
|
|
31
|
-
* `'rolldown-dev'` (not `'rolldown'`) so {@link getBuildAdapterOwnership}
|
|
32
|
-
* round-trips correctly and `createBuildAdapter({ ownership })` can
|
|
33
|
-
* re-select this class.
|
|
34
|
-
*/
|
|
35
|
-
readonly ownership: "rolldown-dev";
|
|
36
|
-
private cachedEngine;
|
|
37
|
-
private engineInstanceCount;
|
|
38
|
-
private readonly pendingBuilds;
|
|
39
|
-
private readonly appRootRequireCache;
|
|
40
|
-
/**
|
|
41
|
-
* Stable key over the inputs that affect the engine configuration.
|
|
42
|
-
* Plugin order is intentionally not part of the key: two plugin
|
|
43
|
-
* sets with the same names are interchangeable for caching.
|
|
44
|
-
*/
|
|
45
|
-
private getCacheKey;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the cached engine, creating a new one when the cache
|
|
48
|
-
* key changes. On a cache miss the prior engine is closed and
|
|
49
|
-
* {@link engineInstanceCount} is incremented.
|
|
50
|
-
*/
|
|
51
|
-
private getOrCreateEngine;
|
|
52
|
-
/**
|
|
53
|
-
* Triggers a build on the cached engine and returns the next
|
|
54
|
-
* `RolldownOutput` delivered to `onOutput`.
|
|
55
|
-
*
|
|
56
|
-
* First call after engine creation invokes `engine.run`; subsequent
|
|
57
|
-
* calls invoke `engine.triggerFullBuild` and reuse the cached
|
|
58
|
-
* module graph, resolver, and transform caches.
|
|
59
|
-
*
|
|
60
|
-
* If the trigger itself throws, the queued build is removed so
|
|
61
|
-
* the next `build()` does not consume a stale slot.
|
|
62
|
-
*/
|
|
63
|
-
private runBuild;
|
|
64
|
-
/** Throws on error; see {@link build} for the no-throw variant. */
|
|
65
|
-
buildOrThrow(options: BuildOptions): Promise<BuildResult>;
|
|
66
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
67
|
-
resolve(importPath: string, rootDir: string): string;
|
|
68
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
69
|
-
/**
|
|
70
|
-
* Closes the cached DevEngine and rejects any in-flight builds
|
|
71
|
-
* with `'DevBuildAdapter closed'`.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Not on the {@link BuildAdapter} interface, so it is only
|
|
75
|
-
* reachable through the concrete class. The adapter is meant to
|
|
76
|
-
* live for the process lifetime; this is for explicit teardown.
|
|
77
|
-
*/
|
|
78
|
-
close(): Promise<void>;
|
|
79
|
-
/** Test-only: number of engines created over the adapter's lifetime. */
|
|
80
|
-
getEngineInstanceCountForTests(): number;
|
|
81
|
-
}
|
|
82
|
-
export declare function createRolldownDevBuildAdapter(): RolldownDevBuildAdapter;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { dev } from "rolldown/experimental";
|
|
4
|
-
import {
|
|
5
|
-
buildResultFromRolldownOutput,
|
|
6
|
-
resolveRolldownOptions,
|
|
7
|
-
rewriteBrowserRuntimeImportsInOutputs,
|
|
8
|
-
toBuildLogs,
|
|
9
|
-
transpileProfileToOptions
|
|
10
|
-
} from "./rolldown-adapter-helpers.js";
|
|
11
|
-
const moduleRequire = createRequire(import.meta.url);
|
|
12
|
-
class RolldownDevBuildAdapter {
|
|
13
|
-
/**
|
|
14
|
-
* `'rolldown-dev'` (not `'rolldown'`) so {@link getBuildAdapterOwnership}
|
|
15
|
-
* round-trips correctly and `createBuildAdapter({ ownership })` can
|
|
16
|
-
* re-select this class.
|
|
17
|
-
*/
|
|
18
|
-
ownership = "rolldown-dev";
|
|
19
|
-
cachedEngine;
|
|
20
|
-
engineInstanceCount = 0;
|
|
21
|
-
pendingBuilds = [];
|
|
22
|
-
appRootRequireCache = /* @__PURE__ */ new Map();
|
|
23
|
-
/**
|
|
24
|
-
* Stable key over the inputs that affect the engine configuration.
|
|
25
|
-
* Plugin order is intentionally not part of the key: two plugin
|
|
26
|
-
* sets with the same names are interchangeable for caching.
|
|
27
|
-
*/
|
|
28
|
-
getCacheKey(plugins, contextRoot, target, format) {
|
|
29
|
-
const pluginNames = plugins.map((p) => p.name).join(":");
|
|
30
|
-
return `${contextRoot}::${pluginNames}::${target ?? "default"}::${format ?? "esm"}`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Returns the cached engine, creating a new one when the cache
|
|
34
|
-
* key changes. On a cache miss the prior engine is closed and
|
|
35
|
-
* {@link engineInstanceCount} is incremented.
|
|
36
|
-
*/
|
|
37
|
-
async getOrCreateEngine(options, contextRoot) {
|
|
38
|
-
const bundlePlugins = options.plugins ?? [];
|
|
39
|
-
const cacheKey = this.getCacheKey(bundlePlugins, contextRoot, options.target, options.format);
|
|
40
|
-
if (this.cachedEngine) {
|
|
41
|
-
const existingKey = this.getCacheKey(
|
|
42
|
-
this.cachedEngine.bundlePlugins,
|
|
43
|
-
this.cachedEngine.contextRoot,
|
|
44
|
-
options.target,
|
|
45
|
-
options.format
|
|
46
|
-
);
|
|
47
|
-
if (existingKey === cacheKey) {
|
|
48
|
-
return this.cachedEngine;
|
|
49
|
-
}
|
|
50
|
-
await this.cachedEngine.engine.close();
|
|
51
|
-
this.cachedEngine = void 0;
|
|
52
|
-
}
|
|
53
|
-
const outdir = path.resolve(options.outdir ?? "dist/assets");
|
|
54
|
-
const { inputOptions, outputOptions } = resolveRolldownOptions(
|
|
55
|
-
options,
|
|
56
|
-
contextRoot,
|
|
57
|
-
outdir,
|
|
58
|
-
this.appRootRequireCache
|
|
59
|
-
);
|
|
60
|
-
const engine = await dev(inputOptions, outputOptions, {
|
|
61
|
-
rebuildStrategy: "never",
|
|
62
|
-
onOutput: (result) => {
|
|
63
|
-
if (result instanceof Error) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const next = this.pendingBuilds.shift();
|
|
67
|
-
if (next) {
|
|
68
|
-
next.resolve(result);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
this.cachedEngine = {
|
|
73
|
-
engine,
|
|
74
|
-
engineStarted: false,
|
|
75
|
-
contextRoot,
|
|
76
|
-
bundlePlugins
|
|
77
|
-
};
|
|
78
|
-
this.engineInstanceCount += 1;
|
|
79
|
-
return this.cachedEngine;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Triggers a build on the cached engine and returns the next
|
|
83
|
-
* `RolldownOutput` delivered to `onOutput`.
|
|
84
|
-
*
|
|
85
|
-
* First call after engine creation invokes `engine.run`; subsequent
|
|
86
|
-
* calls invoke `engine.triggerFullBuild` and reuse the cached
|
|
87
|
-
* module graph, resolver, and transform caches.
|
|
88
|
-
*
|
|
89
|
-
* If the trigger itself throws, the queued build is removed so
|
|
90
|
-
* the next `build()` does not consume a stale slot.
|
|
91
|
-
*/
|
|
92
|
-
async runBuild(cached) {
|
|
93
|
-
const outputPromise = new Promise((resolve, reject) => {
|
|
94
|
-
this.pendingBuilds.push({ resolve, reject });
|
|
95
|
-
});
|
|
96
|
-
try {
|
|
97
|
-
if (!cached.engineStarted) {
|
|
98
|
-
cached.engineStarted = true;
|
|
99
|
-
await cached.engine.run();
|
|
100
|
-
} else {
|
|
101
|
-
cached.engine.triggerFullBuild();
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
this.pendingBuilds.shift();
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
return outputPromise;
|
|
108
|
-
}
|
|
109
|
-
/** Throws on error; see {@link build} for the no-throw variant. */
|
|
110
|
-
async buildOrThrow(options) {
|
|
111
|
-
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
112
|
-
const outdir = path.resolve(options.outdir ?? "dist/assets");
|
|
113
|
-
const plugins = options.plugins ?? [];
|
|
114
|
-
const cached = await this.getOrCreateEngine(options, contextRoot);
|
|
115
|
-
const output = await this.runBuild(cached);
|
|
116
|
-
const baseResult = buildResultFromRolldownOutput(output, outdir, contextRoot);
|
|
117
|
-
return rewriteBrowserRuntimeImportsInOutputs(baseResult, contextRoot, plugins);
|
|
118
|
-
}
|
|
119
|
-
async build(options) {
|
|
120
|
-
try {
|
|
121
|
-
return await this.buildOrThrow(options);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
logs: toBuildLogs(error),
|
|
126
|
-
outputs: []
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
resolve(importPath, rootDir) {
|
|
131
|
-
return moduleRequire.resolve(importPath, { paths: [rootDir] });
|
|
132
|
-
}
|
|
133
|
-
getTranspileOptions(profile) {
|
|
134
|
-
return transpileProfileToOptions(profile);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Closes the cached DevEngine and rejects any in-flight builds
|
|
138
|
-
* with `'DevBuildAdapter closed'`.
|
|
139
|
-
*
|
|
140
|
-
* @remarks
|
|
141
|
-
* Not on the {@link BuildAdapter} interface, so it is only
|
|
142
|
-
* reachable through the concrete class. The adapter is meant to
|
|
143
|
-
* live for the process lifetime; this is for explicit teardown.
|
|
144
|
-
*/
|
|
145
|
-
async close() {
|
|
146
|
-
if (this.cachedEngine) {
|
|
147
|
-
await this.cachedEngine.engine.close();
|
|
148
|
-
this.cachedEngine = void 0;
|
|
149
|
-
}
|
|
150
|
-
while (this.pendingBuilds.length > 0) {
|
|
151
|
-
const pending = this.pendingBuilds.shift();
|
|
152
|
-
pending?.reject(new Error("DevBuildAdapter closed"));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/** Test-only: number of engines created over the adapter's lifetime. */
|
|
156
|
-
getEngineInstanceCountForTests() {
|
|
157
|
-
return this.engineInstanceCount;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function createRolldownDevBuildAdapter() {
|
|
161
|
-
return new RolldownDevBuildAdapter();
|
|
162
|
-
}
|
|
163
|
-
export {
|
|
164
|
-
RolldownDevBuildAdapter,
|
|
165
|
-
createRolldownDevBuildAdapter
|
|
166
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
const FIXTURE_DIR = resolve(process.cwd(), "packages/core/__fixtures__/app");
|
|
6
|
-
const TEST_CSS_FILE = resolve(FIXTURE_DIR, "src/pages/postcss-hmr.css");
|
|
7
|
-
test.describe("HMR E2E PostCSS", () => {
|
|
8
|
-
test("should hot-update processor-owned CSS without a full page reload", async ({ page }) => {
|
|
9
|
-
const originalCss = readFileSync(TEST_CSS_FILE, "utf-8");
|
|
10
|
-
const title = page.locator(".postcss-title").first();
|
|
11
|
-
try {
|
|
12
|
-
await page.goto("/postcss-hmr", { waitUntil: "networkidle" });
|
|
13
|
-
await expect(title).toBeVisible();
|
|
14
|
-
const initialColor = await title.evaluate((el) => getComputedStyle(el).color);
|
|
15
|
-
expect(initialColor).toBeTruthy();
|
|
16
|
-
await page.evaluate(() => {
|
|
17
|
-
window.__postcssReloadProbe = "before-change";
|
|
18
|
-
});
|
|
19
|
-
const modifiedCss = originalCss.replace(".postcss-title {", ".postcss-title {\n color: rgb(255, 0, 0);");
|
|
20
|
-
await writeFile(TEST_CSS_FILE, modifiedCss, { flush: true });
|
|
21
|
-
await expect.poll(async () => title.evaluate((el) => getComputedStyle(el).color), { timeout: 1e4 }).toBe("rgb(255, 0, 0)");
|
|
22
|
-
await expect(
|
|
23
|
-
page.evaluate(
|
|
24
|
-
() => window.__postcssReloadProbe ?? null
|
|
25
|
-
)
|
|
26
|
-
).resolves.toBe("before-change");
|
|
27
|
-
} finally {
|
|
28
|
-
await writeFile(TEST_CSS_FILE, originalCss, { flush: true });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
package/src/hmr/hmr.test.e2e.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
const FIXTURE_DIR = resolve(process.cwd(), "packages/core/__fixtures__/app");
|
|
6
|
-
const TEST_CSS_FILE = resolve(FIXTURE_DIR, "src/pages/index.css");
|
|
7
|
-
test.describe("HMR E2E", () => {
|
|
8
|
-
test("should load page with .main-title element", async ({ page }) => {
|
|
9
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
10
|
-
const title = page.locator(".main-title").first();
|
|
11
|
-
await expect(title).toBeVisible();
|
|
12
|
-
});
|
|
13
|
-
test("should connect to HMR WebSocket", async ({ page }) => {
|
|
14
|
-
const socketPromise = page.waitForEvent("websocket", {
|
|
15
|
-
predicate: (socket2) => socket2.url().endsWith("/_hmr"),
|
|
16
|
-
timeout: 1e4
|
|
17
|
-
});
|
|
18
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
19
|
-
const socket = await socketPromise;
|
|
20
|
-
expect(socket.url()).toMatch(/\/_hmr$/);
|
|
21
|
-
});
|
|
22
|
-
test("should fall back to a full page reload when raw CSS file changes", async ({ page }) => {
|
|
23
|
-
const originalCss = readFileSync(TEST_CSS_FILE, "utf-8");
|
|
24
|
-
const title = page.locator(".main-title").first();
|
|
25
|
-
try {
|
|
26
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
27
|
-
await expect(title).toBeVisible();
|
|
28
|
-
const initialColor = await title.evaluate((el) => getComputedStyle(el).color);
|
|
29
|
-
expect(initialColor).toBeTruthy();
|
|
30
|
-
const modifiedCss = originalCss.replace(".main-title {", ".main-title {\n color: rgb(255, 0, 0);");
|
|
31
|
-
const reloadPromise = page.waitForEvent("framenavigated", {
|
|
32
|
-
predicate: (frame) => frame === page.mainFrame(),
|
|
33
|
-
timeout: 1e4
|
|
34
|
-
});
|
|
35
|
-
await writeFile(TEST_CSS_FILE, modifiedCss, { flush: true });
|
|
36
|
-
await reloadPromise;
|
|
37
|
-
await page.waitForLoadState("networkidle");
|
|
38
|
-
await expect.poll(async () => title.evaluate((el) => getComputedStyle(el).color), { timeout: 1e4 }).toBe("rgb(255, 0, 0)");
|
|
39
|
-
} finally {
|
|
40
|
-
await writeFile(TEST_CSS_FILE, originalCss, { flush: true });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { OwnershipPlan, OwnershipValidationError, EcoComponent } from '../../types/public-types.js';
|
|
2
|
-
type OwnershipPlanBuildInput = {
|
|
3
|
-
routeFile: string;
|
|
4
|
-
currentIntegrationName: string;
|
|
5
|
-
HtmlTemplate: EcoComponent;
|
|
6
|
-
Layout?: EcoComponent;
|
|
7
|
-
Page: EcoComponent;
|
|
8
|
-
validationErrors?: OwnershipValidationError[];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Builds a declared ownership plan from the component dependency graph.
|
|
12
|
-
*
|
|
13
|
-
* The plan reflects the declared component dependency graph for one route after
|
|
14
|
-
* route-root ownership validation has already run. It records ownership shape,
|
|
15
|
-
* foreign-edge counts, and any validation errors supplied by an earlier
|
|
16
|
-
* validation pass.
|
|
17
|
-
*/
|
|
18
|
-
export declare class OwnershipPlanningService {
|
|
19
|
-
/**
|
|
20
|
-
* Builds the structural ownership plan for one route render.
|
|
21
|
-
*/
|
|
22
|
-
buildPlan(input: OwnershipPlanBuildInput): OwnershipPlan;
|
|
23
|
-
}
|
|
24
|
-
export {};
|