@ecopages/core 0.2.0-rc.6 → 0.2.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +27 -3
- package/src/adapters/abstract/segment-path-matcher.js +56 -38
- package/src/adapters/bun/create-app.d.ts +4 -0
- package/src/adapters/bun/create-app.js +46 -31
- package/src/adapters/shared/runtime/server-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/server-adapter.js +9 -22
- package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/declarations.d.ts +10 -1
- package/src/eco/README.md +3 -1
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/islands/README.md +5 -1
- package/src/plugins/component-import-discovery.js +115 -77
- package/src/plugins/eco-component-meta-plugin.js +47 -30
- package/src/route-renderer/README.md +3 -2
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +68 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +183 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +22 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +2 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +3 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +1 -1
- package/src/route-renderer/orchestration/integration-renderer.d.ts +7 -3
- package/src/route-renderer/orchestration/integration-renderer.js +34 -20
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +1 -1
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -2
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +3 -2
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +95 -74
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +0 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +37 -34
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +6 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +24 -5
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- package/src/services/module-loading/page-module-import.service.d.ts +6 -0
- package/src/services/module-loading/page-module-import.service.js +60 -27
- package/src/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/static-site-generator.d.ts +4 -0
- package/src/static-site-generator/static-site-generator.js +75 -48
- package/src/types/internal-types.d.ts +5 -1
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +5 -0
- package/src/watchers/project-watcher.js +46 -32
|
@@ -319,13 +319,7 @@ export class StaticSiteGenerator {
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
|
|
323
|
-
* Executes the full static-generation workflow for one app run.
|
|
324
|
-
*/
|
|
325
|
-
async run({ router, baseUrl, routeRendererFactory, staticRoutes, force = false, preserveExportDirectory = false, }) {
|
|
326
|
-
const skippedDynamicPages = [];
|
|
327
|
-
const activeStaticPathnames = new Set();
|
|
328
|
-
const sitemapEligiblePathnames = this.appConfig.sitemap?.enabled ? new Set() : undefined;
|
|
322
|
+
resetStaticGenerationState(force) {
|
|
329
323
|
this.forceFullStaticGeneration = force;
|
|
330
324
|
this.staticRenderCacheContext = createRouteModuleStaticRenderCacheContext(this.appConfig);
|
|
331
325
|
this.pageModuleLoader = undefined;
|
|
@@ -335,16 +329,72 @@ export class StaticSiteGenerator {
|
|
|
335
329
|
if (shouldPrebuildProductionPageBrowserGraphs() && force) {
|
|
336
330
|
clearProductionPageBrowserGraphSession(this.appConfig);
|
|
337
331
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (shouldBuildPagesUnifiedGraph()) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
332
|
+
}
|
|
333
|
+
async ensureUnifiedGraphForStaticGeneration(routes, force) {
|
|
334
|
+
if (!shouldBuildPagesUnifiedGraph()) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
await ensurePagesUnifiedGraphBuilt({
|
|
338
|
+
appConfig: this.appConfig,
|
|
339
|
+
entryPaths: routes.map((route) => route.templateRoute.filePath),
|
|
340
|
+
outdir: getServerModuleBuildCacheOutdir(this.appConfig),
|
|
341
|
+
force,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
async executeStaticGenerationBody(input) {
|
|
345
|
+
if (shouldPrebuildProductionPageBrowserGraphs() && input.routeRendererFactory) {
|
|
346
|
+
await prebuildProductionPageBrowserGraphs(input.routes.map((route) => ({
|
|
347
|
+
routeFile: route.templateRoute.filePath,
|
|
348
|
+
params: route.params,
|
|
349
|
+
})), input.routeRendererFactory);
|
|
350
|
+
}
|
|
351
|
+
this.generateRobotsTxt();
|
|
352
|
+
await this.generateStaticPages({
|
|
353
|
+
router: input.router,
|
|
354
|
+
baseUrl: input.baseUrl,
|
|
355
|
+
routeRendererFactory: input.routeRendererFactory,
|
|
356
|
+
skipped: input.skippedDynamicPages,
|
|
357
|
+
activeStaticPathnames: input.activeStaticPathnames,
|
|
358
|
+
preloadedRoutes: input.routes,
|
|
359
|
+
sitemapEligiblePathnames: input.sitemapEligiblePathnames,
|
|
360
|
+
});
|
|
361
|
+
if (input.staticRoutes && input.staticRoutes.length > 0 && input.routeRendererFactory) {
|
|
362
|
+
await this.generateExplicitStaticPages({
|
|
363
|
+
staticRoutes: input.staticRoutes,
|
|
364
|
+
routeRendererFactory: input.routeRendererFactory,
|
|
365
|
+
skipped: input.skippedDynamicPages,
|
|
366
|
+
activeStaticPathnames: input.activeStaticPathnames,
|
|
367
|
+
sitemapEligiblePathnames: input.sitemapEligiblePathnames,
|
|
346
368
|
});
|
|
347
369
|
}
|
|
370
|
+
if (input.preserveExportDirectory) {
|
|
371
|
+
this.pruneStaleStaticOutputs(input.activeStaticPathnames);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
finalizeStaticGenerationRun(input) {
|
|
375
|
+
if (this.appConfig.sitemap?.enabled && input.sitemapEligiblePathnames) {
|
|
376
|
+
const locations = resolveSitemapLocations({
|
|
377
|
+
eligiblePathnames: [...input.sitemapEligiblePathnames],
|
|
378
|
+
sitemap: this.appConfig.sitemap,
|
|
379
|
+
baseUrl: input.baseUrl,
|
|
380
|
+
});
|
|
381
|
+
this.generateSitemap(locations, this.appConfig.sitemap);
|
|
382
|
+
}
|
|
383
|
+
if (input.skippedDynamicPages.length > 0) {
|
|
384
|
+
appLogger.debug(`Skipped ${input.skippedDynamicPages.length} page(s) with cache: 'dynamic' (not supported in static generation)`, input.skippedDynamicPages);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Executes the full static-generation workflow for one app run.
|
|
389
|
+
*/
|
|
390
|
+
async run({ router, baseUrl, routeRendererFactory, staticRoutes, force = false, preserveExportDirectory = false, }) {
|
|
391
|
+
const skippedDynamicPages = [];
|
|
392
|
+
const activeStaticPathnames = new Set();
|
|
393
|
+
const sitemapEligiblePathnames = this.appConfig.sitemap?.enabled ? new Set() : undefined;
|
|
394
|
+
this.resetStaticGenerationState(force);
|
|
395
|
+
const routes = await router.listStaticGenerationRoutes({ runtimeOrigin: baseUrl });
|
|
396
|
+
const exportRoutes = routes.map((route) => toEcopagesRouteInfo(route));
|
|
397
|
+
await this.ensureUnifiedGraphForStaticGeneration(routes, force);
|
|
348
398
|
const staticExportContext = this.createStaticExportContext({
|
|
349
399
|
router,
|
|
350
400
|
baseUrl,
|
|
@@ -356,34 +406,17 @@ export class StaticSiteGenerator {
|
|
|
356
406
|
});
|
|
357
407
|
await this.invokeStaticExportHook('beforeStaticExport', staticExportContext);
|
|
358
408
|
try {
|
|
359
|
-
|
|
360
|
-
await prebuildProductionPageBrowserGraphs(routes.map((route) => ({
|
|
361
|
-
routeFile: route.templateRoute.filePath,
|
|
362
|
-
params: route.params,
|
|
363
|
-
})), routeRendererFactory);
|
|
364
|
-
}
|
|
365
|
-
this.generateRobotsTxt();
|
|
366
|
-
await this.generateStaticPages({
|
|
409
|
+
await this.executeStaticGenerationBody({
|
|
367
410
|
router,
|
|
368
411
|
baseUrl,
|
|
369
412
|
routeRendererFactory,
|
|
370
|
-
|
|
413
|
+
staticRoutes,
|
|
414
|
+
preserveExportDirectory,
|
|
415
|
+
routes,
|
|
416
|
+
skippedDynamicPages,
|
|
371
417
|
activeStaticPathnames,
|
|
372
|
-
preloadedRoutes: routes,
|
|
373
418
|
sitemapEligiblePathnames,
|
|
374
419
|
});
|
|
375
|
-
if (staticRoutes && staticRoutes.length > 0 && routeRendererFactory) {
|
|
376
|
-
await this.generateExplicitStaticPages({
|
|
377
|
-
staticRoutes,
|
|
378
|
-
routeRendererFactory,
|
|
379
|
-
skipped: skippedDynamicPages,
|
|
380
|
-
activeStaticPathnames,
|
|
381
|
-
sitemapEligiblePathnames,
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
if (preserveExportDirectory) {
|
|
385
|
-
this.pruneStaleStaticOutputs(activeStaticPathnames);
|
|
386
|
-
}
|
|
387
420
|
}
|
|
388
421
|
catch (error) {
|
|
389
422
|
if (shouldPrebuildProductionPageBrowserGraphs()) {
|
|
@@ -394,17 +427,11 @@ export class StaticSiteGenerator {
|
|
|
394
427
|
finally {
|
|
395
428
|
await this.invokeStaticExportHook('afterStaticExport', staticExportContext);
|
|
396
429
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
});
|
|
403
|
-
this.generateSitemap(locations, this.appConfig.sitemap);
|
|
404
|
-
}
|
|
405
|
-
if (skippedDynamicPages.length > 0) {
|
|
406
|
-
appLogger.debug(`Skipped ${skippedDynamicPages.length} page(s) with cache: 'dynamic' (not supported in static generation)`, skippedDynamicPages);
|
|
407
|
-
}
|
|
430
|
+
this.finalizeStaticGenerationRun({
|
|
431
|
+
baseUrl,
|
|
432
|
+
skippedDynamicPages,
|
|
433
|
+
sitemapEligiblePathnames,
|
|
434
|
+
});
|
|
408
435
|
}
|
|
409
436
|
async generateExplicitStaticPages(input) {
|
|
410
437
|
appLogger.debug('Generating explicit static routes', input.staticRoutes.map((r) => r.path));
|
|
@@ -5,7 +5,11 @@ import type { BuildRuntime } from '../build/runtime/build-runtime.js';
|
|
|
5
5
|
import type { AnyIntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
6
6
|
import type { Processor } from '../plugins/processor.js';
|
|
7
7
|
import type { EcoSourceTransform } from '../plugins/source-transform.js';
|
|
8
|
-
import type { PageMetadataProps, SitemapConfig } from './public-types.js';
|
|
8
|
+
import type { ComponentRenderInput, EcoComponent, PageMetadataProps, SitemapConfig } from './public-types.js';
|
|
9
|
+
/** Internal render input carrying route-resolved dependency roots. */
|
|
10
|
+
export type InternalComponentRenderInput = ComponentRenderInput & {
|
|
11
|
+
foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>;
|
|
12
|
+
};
|
|
9
13
|
import type { RouteRegistry } from '../router/server/route-registry.js';
|
|
10
14
|
import type { CacheConfig } from '../services/cache/cache.types.js';
|
|
11
15
|
import type { DevGraphService } from '../services/runtime-state/dev-graph.service.js';
|
|
@@ -16,6 +16,32 @@ function getEmbeddedRuntimeCommandOptions() {
|
|
|
16
16
|
}
|
|
17
17
|
const ECOPAGES_BIN_FILES = ['ecopages.ts', 'ecopages.js', 'cli.js'];
|
|
18
18
|
const ECOPAGES_AVAILABLE_COMMANDS = ['dev', 'build', 'start', 'preview'];
|
|
19
|
+
function resolveEcopagesSubcommand(runtimeArgv) {
|
|
20
|
+
const ecopagesIndex = runtimeArgv.findIndex((arg) => ECOPAGES_BIN_FILES.some((filename) => arg.endsWith(filename)));
|
|
21
|
+
if (ecopagesIndex === -1) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
if (ecopagesIndex < runtimeArgv.length - 1 &&
|
|
25
|
+
ECOPAGES_AVAILABLE_COMMANDS.some((cmd) => runtimeArgv[ecopagesIndex + 1] === cmd)) {
|
|
26
|
+
return runtimeArgv[ecopagesIndex + 1];
|
|
27
|
+
}
|
|
28
|
+
return 'start';
|
|
29
|
+
}
|
|
30
|
+
function deriveCliCommandFlags(command, values) {
|
|
31
|
+
const isStartCommand = command === 'start' || (!values.dev && !values.build && !values.preview);
|
|
32
|
+
const isDevCommand = command === 'dev' || !!values.dev;
|
|
33
|
+
const isBuildCommand = command === 'build' || !!values.build;
|
|
34
|
+
const isPreviewCommand = command === 'preview' || !!values.preview;
|
|
35
|
+
return { isStartCommand, isDevCommand, isBuildCommand, isPreviewCommand };
|
|
36
|
+
}
|
|
37
|
+
function applyNodeEnvForCliCommand(isDevCommand) {
|
|
38
|
+
if (isDevCommand) {
|
|
39
|
+
process.env.NODE_ENV ??= 'development';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
process.env.NODE_ENV = 'production';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
19
45
|
/**
|
|
20
46
|
* Parses command line arguments for the server.
|
|
21
47
|
* It returns {@link ReturnParseCliArgs}
|
|
@@ -39,22 +65,8 @@ export function parseCliArgs(options = {}) {
|
|
|
39
65
|
},
|
|
40
66
|
allowPositionals: true,
|
|
41
67
|
});
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const isAvailableCommand = ecopagesIndex !== -1;
|
|
45
|
-
if (isAvailableCommand) {
|
|
46
|
-
command =
|
|
47
|
-
ecopagesIndex < runtimeArgv.length - 1 &&
|
|
48
|
-
ECOPAGES_AVAILABLE_COMMANDS.some((cmd) => {
|
|
49
|
-
return runtimeArgv[ecopagesIndex + 1] === cmd;
|
|
50
|
-
})
|
|
51
|
-
? runtimeArgv[ecopagesIndex + 1]
|
|
52
|
-
: 'start';
|
|
53
|
-
}
|
|
54
|
-
const isStartCommand = command === 'start' || (!values.dev && !values.build && !values.preview);
|
|
55
|
-
const isDevCommand = command === 'dev' || !!values.dev;
|
|
56
|
-
const isBuildCommand = command === 'build' || !!values.build;
|
|
57
|
-
const isPreviewCommand = command === 'preview' || !!values.preview;
|
|
68
|
+
const command = resolveEcopagesSubcommand(runtimeArgv);
|
|
69
|
+
const { isStartCommand, isDevCommand, isBuildCommand, isPreviewCommand } = deriveCliCommandFlags(command, values);
|
|
58
70
|
const parsedCommandOptions = {
|
|
59
71
|
preview: isPreviewCommand,
|
|
60
72
|
build: isBuildCommand,
|
|
@@ -66,11 +78,6 @@ export function parseCliArgs(options = {}) {
|
|
|
66
78
|
hostname: values.hostname,
|
|
67
79
|
reactFastRefresh: values['react-fast-refresh'],
|
|
68
80
|
};
|
|
69
|
-
|
|
70
|
-
process.env.NODE_ENV ??= 'development';
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
process.env.NODE_ENV = 'production';
|
|
74
|
-
}
|
|
81
|
+
applyNodeEnvForCliCommand(isDevCommand);
|
|
75
82
|
return parsedCommandOptions;
|
|
76
83
|
}
|
|
@@ -92,6 +92,11 @@ export declare class ProjectWatcher {
|
|
|
92
92
|
* @param event - The type of file system event
|
|
93
93
|
*/
|
|
94
94
|
private handleFileChange;
|
|
95
|
+
private invalidatePageCachesForChange;
|
|
96
|
+
private applyRouteAndServerInvalidation;
|
|
97
|
+
private shouldDeferProcessorNotifications;
|
|
98
|
+
private handleDeferredHmrFileChange;
|
|
99
|
+
private handleStandardHmrFileChange;
|
|
95
100
|
private processFileChange;
|
|
96
101
|
/**
|
|
97
102
|
* Re-imports server modules before HMR broadcast so reload/refetch does not
|
|
@@ -155,6 +155,47 @@ export class ProjectWatcher {
|
|
|
155
155
|
this.pendingChangeEvents.set(filePath, { event, timer });
|
|
156
156
|
return Promise.resolve();
|
|
157
157
|
}
|
|
158
|
+
async invalidatePageCachesForChange(plan, resolvedFilePath) {
|
|
159
|
+
if (shouldClearAllPageHtmlCache(plan.category)) {
|
|
160
|
+
await clearAppPageCache(this.appConfig);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await invalidateAppPageCacheBySourcePaths(this.appConfig, [resolvedFilePath]);
|
|
164
|
+
}
|
|
165
|
+
async applyRouteAndServerInvalidation(plan, filePath, resolvedFilePath, event, isRegisteredDevTransformEdit) {
|
|
166
|
+
if (plan.refreshRoutes && (event === 'unlink' || event === 'add')) {
|
|
167
|
+
getAppPageBrowserGraphSession(this.appConfig).invalidateByRouteFile(resolvedFilePath);
|
|
168
|
+
}
|
|
169
|
+
if (plan.invalidateServerModules && !isRegisteredDevTransformEdit) {
|
|
170
|
+
this.invalidationService.invalidateServerModules([filePath]);
|
|
171
|
+
}
|
|
172
|
+
if (plan.refreshRoutes) {
|
|
173
|
+
await this.refreshRouterRoutesCallback();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
shouldDeferProcessorNotifications(plan, isRegisteredDevTransformEdit) {
|
|
177
|
+
return (plan.category === 'include-source' ||
|
|
178
|
+
plan.category === 'explicit-server-view' ||
|
|
179
|
+
isRegisteredDevTransformEdit);
|
|
180
|
+
}
|
|
181
|
+
async handleDeferredHmrFileChange(filePath, resolvedFilePath, event, plan, graphPreparation) {
|
|
182
|
+
await this.prewarmBeforeHmr(resolvedFilePath, plan);
|
|
183
|
+
await this.hmrManager.handleFileChange(filePath, {
|
|
184
|
+
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
185
|
+
});
|
|
186
|
+
await this.notifyProcessors(filePath, event);
|
|
187
|
+
}
|
|
188
|
+
async handleStandardHmrFileChange(filePath, event, plan, graphPreparation) {
|
|
189
|
+
await this.notifyProcessors(filePath, event);
|
|
190
|
+
if (plan.processorHandledAsset) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (plan.delegateToHmr) {
|
|
194
|
+
await this.hmrManager.handleFileChange(filePath, {
|
|
195
|
+
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
158
199
|
async processFileChange(filePath, event) {
|
|
159
200
|
try {
|
|
160
201
|
const plan = this.invalidationService.planFileChange(filePath);
|
|
@@ -164,50 +205,23 @@ export class ProjectWatcher {
|
|
|
164
205
|
}
|
|
165
206
|
this.uncacheModules();
|
|
166
207
|
const resolvedFilePath = path.resolve(filePath);
|
|
167
|
-
|
|
168
|
-
await clearAppPageCache(this.appConfig);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
await invalidateAppPageCacheBySourcePaths(this.appConfig, [resolvedFilePath]);
|
|
172
|
-
}
|
|
208
|
+
await this.invalidatePageCachesForChange(plan, resolvedFilePath);
|
|
173
209
|
const graphPreparation = this.hmrManager.isEnabled()
|
|
174
210
|
? prepareHmrFileChange(this.appConfig, resolvedFilePath)
|
|
175
211
|
: undefined;
|
|
176
|
-
if (plan.refreshRoutes && (event === 'unlink' || event === 'add')) {
|
|
177
|
-
getAppPageBrowserGraphSession(this.appConfig).invalidateByRouteFile(resolvedFilePath);
|
|
178
|
-
}
|
|
179
212
|
const isRegisteredDevTransformEdit = isRegisteredDevTransformEntrypoint(this.hmrManager.getRegisteredEntrypoints(), resolvedFilePath);
|
|
180
|
-
|
|
181
|
-
this.invalidationService.invalidateServerModules([filePath]);
|
|
182
|
-
}
|
|
183
|
-
if (plan.refreshRoutes) {
|
|
184
|
-
await this.refreshRouterRoutesCallback();
|
|
185
|
-
}
|
|
213
|
+
await this.applyRouteAndServerInvalidation(plan, filePath, resolvedFilePath, event, isRegisteredDevTransformEdit);
|
|
186
214
|
if (plan.reloadBrowser) {
|
|
187
215
|
await this.notifyProcessors(filePath, event);
|
|
188
216
|
this.requestBrowserReload();
|
|
189
217
|
return;
|
|
190
218
|
}
|
|
191
|
-
const deferProcessorNotifications = plan
|
|
192
|
-
plan.category === 'explicit-server-view' ||
|
|
193
|
-
isRegisteredDevTransformEdit;
|
|
219
|
+
const deferProcessorNotifications = this.shouldDeferProcessorNotifications(plan, isRegisteredDevTransformEdit);
|
|
194
220
|
if (deferProcessorNotifications && plan.delegateToHmr) {
|
|
195
|
-
await this.
|
|
196
|
-
await this.hmrManager.handleFileChange(filePath, {
|
|
197
|
-
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
198
|
-
});
|
|
199
|
-
await this.notifyProcessors(filePath, event);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
await this.notifyProcessors(filePath, event);
|
|
203
|
-
if (plan.processorHandledAsset) {
|
|
221
|
+
await this.handleDeferredHmrFileChange(filePath, resolvedFilePath, event, plan, graphPreparation);
|
|
204
222
|
return;
|
|
205
223
|
}
|
|
206
|
-
|
|
207
|
-
await this.hmrManager.handleFileChange(filePath, {
|
|
208
|
-
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
224
|
+
await this.handleStandardHmrFileChange(filePath, event, plan, graphPreparation);
|
|
211
225
|
}
|
|
212
226
|
catch (error) {
|
|
213
227
|
if (error instanceof Error) {
|