@ecopages/core 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +2 -2
  2. package/package.json +14 -4
  3. package/src/adapters/node/create-app.d.ts +5 -5
  4. package/src/adapters/node/create-app.js +1 -1
  5. package/src/adapters/node/server-adapter.d.ts +1 -0
  6. package/src/adapters/node/server-adapter.js +4 -1
  7. package/src/adapters/shared/hmr/hmr-manager.d.ts +2 -0
  8. package/src/adapters/shared/hmr/hmr-manager.js +8 -4
  9. package/src/adapters/shared/http/api-request-pipeline.d.ts +16 -3
  10. package/src/adapters/shared/http/api-request-pipeline.js +23 -16
  11. package/src/adapters/shared/http/define-api-handler.d.ts +8 -8
  12. package/src/adapters/shared/http/explicit-static-route-matcher.js +8 -4
  13. package/src/adapters/shared/http/file-route-middleware-pipeline.d.ts +10 -11
  14. package/src/adapters/shared/http/file-route-middleware-pipeline.js +5 -6
  15. package/src/adapters/shared/http/fs-server-response-matcher.js +12 -4
  16. package/src/adapters/shared/http/run-middleware-chain.d.ts +29 -2
  17. package/src/adapters/shared/http/run-middleware-chain.js +108 -10
  18. package/src/adapters/shared/runtime/render-context.d.ts +2 -0
  19. package/src/adapters/shared/runtime/render-context.js +6 -21
  20. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +2 -2
  21. package/src/adapters/shared/runtime/server-request-pipeline.js +4 -3
  22. package/src/adapters/shared/runtime/server-static-builder.js +4 -1
  23. package/src/adapters/shared/runtime/unattached-scripts.d.ts +17 -0
  24. package/src/adapters/shared/runtime/unattached-scripts.js +57 -0
  25. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +3 -2
  26. package/src/adapters/shared/ws/ws-pattern-matcher.d.ts +14 -1
  27. package/src/adapters/shared/ws/ws-pattern-matcher.js +14 -13
  28. package/src/assets/app-browser-client-build.js +3 -0
  29. package/src/assets/asset-processing-service/asset-processing.service.d.ts +9 -0
  30. package/src/assets/asset-processing-service/asset-processing.service.js +19 -0
  31. package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +16 -2
  32. package/src/assets/asset-processing-service/processed-asset-ledger.js +31 -3
  33. package/src/build/build-graph.d.ts +19 -2
  34. package/src/build/build-graph.js +19 -18
  35. package/src/build/cache/pages-unified-graph-build.d.ts +4 -6
  36. package/src/build/cache/pages-unified-graph-build.js +14 -51
  37. package/src/build/cache/server-module-entries.d.ts +5 -9
  38. package/src/build/cache/server-module-entries.js +5 -58
  39. package/src/build/contracts/build-contracts.d.ts +15 -0
  40. package/src/build/contracts.d.ts +1 -1
  41. package/src/build/contracts.js +1 -1
  42. package/src/build/production-asset-ledger.d.ts +1 -1
  43. package/src/build/production-asset-ledger.js +4 -2
  44. package/src/build/rolldown/file-role-grammar-plugin.d.ts +11 -0
  45. package/src/build/rolldown/file-role-grammar-plugin.js +32 -0
  46. package/src/build/rolldown/rolldown-adapter-helpers.d.ts +11 -0
  47. package/src/build/rolldown/rolldown-adapter-helpers.js +79 -10
  48. package/src/build/rolldown/ssr-script-entries-plugin.d.ts +31 -0
  49. package/src/build/rolldown/ssr-script-entries-plugin.js +104 -0
  50. package/src/build/runtime/build-request-policy.js +4 -1
  51. package/src/build/server/server-modules-manifest.d.ts +6 -1
  52. package/src/build/server/server-modules-manifest.js +10 -1
  53. package/src/build/server/view-reference.d.ts +9 -0
  54. package/src/build/server/view-reference.js +11 -0
  55. package/src/build.d.ts +3 -1
  56. package/src/build.js +3 -1
  57. package/src/cli.d.ts +14 -0
  58. package/src/cli.js +14 -0
  59. package/src/config/assembly/app-runtime.d.ts +13 -0
  60. package/src/config/assembly/app-runtime.js +2 -0
  61. package/src/config/assembly/finalize-config.js +13 -8
  62. package/src/config/internal-types.d.ts +0 -12
  63. package/src/config/resolve-eco-config-path.d.ts +2 -0
  64. package/src/config/resolve-eco-config-path.js +2 -1
  65. package/src/config/server-config-bundle.d.ts +0 -1
  66. package/src/config/server-config-bundle.js +1 -1
  67. package/src/config/user-config-types.d.ts +0 -12
  68. package/src/declarations.d.ts +2 -0
  69. package/src/dev/invalidation/development-invalidation.service.d.ts +0 -2
  70. package/src/dev/invalidation/development-invalidation.service.js +1 -11
  71. package/src/dev/transform-server/dev-transform-vendor-registry.js +33 -19
  72. package/src/eco/discovered-dependencies.d.ts +5 -0
  73. package/src/eco/discovered-dependencies.js +9 -0
  74. package/src/eco/eco.browser.js +6 -26
  75. package/src/eco/eco.js +24 -16
  76. package/src/eco/migration-docs.d.ts +7 -0
  77. package/src/eco/migration-docs.js +7 -0
  78. package/src/eco/page-data-hooks.d.ts +27 -0
  79. package/src/eco/page-data-hooks.js +64 -0
  80. package/src/eco/page-layout-normalization.d.ts +2 -2
  81. package/src/hmr/client/hmr-runtime.js +1 -1
  82. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -2
  83. package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +2 -1
  84. package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +4 -3
  85. package/src/html/html-rewriter.d.ts +9 -7
  86. package/src/html/html-rewriter.js +26 -41
  87. package/src/html/html-transformer.service.d.ts +2 -2
  88. package/src/html/html-transformer.service.js +21 -15
  89. package/src/html-pages/html-page-module-scripts.js +2 -1
  90. package/src/html-pages/html-pages.plugin.d.ts +1 -1
  91. package/src/html-pages/html-pages.plugin.js +1 -1
  92. package/src/index.d.ts +1 -0
  93. package/src/index.js +1 -0
  94. package/src/integration.d.ts +2 -2
  95. package/src/integration.js +2 -2
  96. package/src/islands/island-host.d.ts +16 -5
  97. package/src/islands/island-host.js +8 -1
  98. package/src/middleware/create-middleware.d.ts +41 -0
  99. package/src/middleware/create-middleware.js +72 -0
  100. package/src/plugins/component-import-discovery.d.ts +14 -1
  101. package/src/plugins/component-import-discovery.js +36 -16
  102. package/src/plugins/eco-component-meta-plugin.d.ts +38 -0
  103. package/src/plugins/eco-component-meta-plugin.js +208 -44
  104. package/src/plugins/ecopages-virtual-imports.d.ts +15 -0
  105. package/src/plugins/ecopages-virtual-imports.js +25 -0
  106. package/src/plugins/integration-plugin.d.ts +1 -1
  107. package/src/plugins/integration-plugin.js +1 -1
  108. package/src/plugins/tsconfig-import-resolver.d.ts +2 -0
  109. package/src/plugins/tsconfig-import-resolver.js +7 -5
  110. package/src/route-renderer/error-pages/error-page-renderer.js +32 -3
  111. package/src/route-renderer/explicit-view-render-preparation.d.ts +28 -3
  112. package/src/route-renderer/explicit-view-render-preparation.js +63 -11
  113. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +15 -5
  114. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +27 -15
  115. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +24 -9
  116. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +73 -50
  117. package/src/route-renderer/orchestration/integration-renderer.d.ts +42 -11
  118. package/src/route-renderer/orchestration/integration-renderer.js +83 -43
  119. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +0 -3
  120. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +36 -11
  121. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +74 -62
  122. package/src/route-renderer/page-declaration.d.ts +25 -0
  123. package/src/route-renderer/page-declaration.js +39 -0
  124. package/src/route-renderer/page-loading/component-declarations.d.ts +65 -0
  125. package/src/route-renderer/page-loading/component-declarations.js +77 -0
  126. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -16
  127. package/src/route-renderer/page-loading/component-dependency-collection.js +36 -105
  128. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +19 -14
  129. package/src/route-renderer/page-loading/declared-asset-collection.js +66 -67
  130. package/src/route-renderer/page-loading/dependency-resolver.d.ts +18 -10
  131. package/src/route-renderer/page-loading/dependency-resolver.js +58 -99
  132. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +19 -26
  133. package/src/route-renderer/page-loading/lazy-entry-collection.js +53 -64
  134. package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +17 -3
  135. package/src/route-renderer/page-loading/module-declaration-aggregation.js +14 -13
  136. package/src/route-renderer/page-loading/page-module-loader.d.ts +31 -12
  137. package/src/route-renderer/page-loading/page-module-loader.js +66 -35
  138. package/src/route-renderer/page-loading/resolved-page-dependencies.js +14 -9
  139. package/src/router/server/pages-dir.d.ts +7 -0
  140. package/src/router/server/pages-dir.js +7 -0
  141. package/src/router/server/route-registry.d.ts +22 -10
  142. package/src/router/server/route-registry.js +54 -23
  143. package/src/router/server/segment-path-matcher.d.ts +29 -5
  144. package/src/router/server/segment-path-matcher.js +22 -19
  145. package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +2 -2
  146. package/src/static-site-generator/production-page-browser-graph-prebuild.js +5 -5
  147. package/src/static-site-generator/static-site-generator.d.ts +17 -2
  148. package/src/static-site-generator/static-site-generator.js +52 -18
  149. package/src/types/contracts.d.ts +216 -160
  150. package/src/types/eco-api-types.d.ts +86 -51
  151. package/src/types/locals-brand.d.ts +9 -0
  152. package/src/types/locals-brand.js +9 -0
  153. package/src/types/middleware-types.d.ts +143 -0
  154. package/src/types/middleware-types.js +1 -0
  155. package/src/types/public-types.d.ts +3 -2
  156. package/src/utils/file-roles.d.ts +48 -0
  157. package/src/utils/file-roles.js +85 -0
  158. package/src/utils/node-builtin.d.ts +10 -0
  159. package/src/utils/node-builtin.js +13 -0
  160. package/src/watchers/project-watcher.js +2 -2
  161. package/src/build/contracts/server-only-specifier.d.ts +0 -8
  162. package/src/build/contracts/server-only-specifier.js +0 -11
  163. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +0 -5
  164. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +0 -11
  165. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +0 -4
  166. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +0 -30
  167. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -12
  168. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +0 -100
  169. package/src/utils/endpoint-file-extensions.d.ts +0 -11
  170. package/src/utils/endpoint-file-extensions.js +0 -13
  171. package/src/utils/locals-utils.d.ts +0 -15
  172. package/src/utils/locals-utils.js +0 -34
@@ -0,0 +1,31 @@
1
+ import type { RolldownPlugin } from 'rolldown';
2
+ declare const PARSER_LANGUAGES: readonly ["js", "jsx", "ts", "tsx"];
3
+ /** A script a declaration lists with a literal `src`. */
4
+ export type DeclaredScript = {
5
+ src: string;
6
+ ssr: boolean;
7
+ };
8
+ /**
9
+ * Lists the scripts a module's declarations name with a literal `src`, relative to that module.
10
+ *
11
+ * @remarks
12
+ * Finds each string or `{ src }` entry of a literal `scripts: [...]` array, and any `{ src, ssr: true }` object.
13
+ * A `src` that is computed at runtime is not found.
14
+ */
15
+ export declare function findDeclaredScripts(file: string, code: string, lang: (typeof PARSER_LANGUAGES)[number]): DeclaredScript[];
16
+ /**
17
+ * The parser language for a file name, or `undefined` when it is not a script module.
18
+ */
19
+ export declare function scriptModuleLanguage(file: string): (typeof PARSER_LANGUAGES)[number] | undefined;
20
+ /**
21
+ * Emits each `ssr: true` script a declaration lists as an entry of the server build that bundles the declaration.
22
+ *
23
+ * @remarks
24
+ * A custom element script that the server also evaluates is not imported by the component that lists it, so only
25
+ * the declaration names it: `dependencies.scripts: [{ src: './x.script.js', ssr: true }]`, with `src` relative to the
26
+ * declaring module. The script then shares chunks with the rest of the build and keeps its exports like any
27
+ * entry, so no second build is needed to add it. Only a literal `src` beside a literal `ssr: true` is found; a
28
+ * script path computed at runtime is not.
29
+ */
30
+ export declare function createSsrScriptEntriesPlugin(): RolldownPlugin;
31
+ export {};
@@ -0,0 +1,104 @@
1
+ import { fileSystem } from '@ecopages/file-system';
2
+ import { path } from '@ecopages/file-system/path';
3
+ import { parseModuleSource } from '../../cache/module-parse-cache.js';
4
+ import { fromRolldownModuleId } from './rolldown-module-id.js';
5
+ const SSR_SCRIPT_PATTERN = /\bssr\s*:\s*(?:true|!0)/u;
6
+ const PARSER_LANGUAGES = ['js', 'jsx', 'ts', 'tsx'];
7
+ function isNode(value) {
8
+ return typeof value === 'object' && value !== null;
9
+ }
10
+ function propertyValue(object, name) {
11
+ for (const property of Array.isArray(object.properties) ? object.properties : []) {
12
+ if (!isNode(property) || (property.type !== 'ObjectProperty' && property.type !== 'Property'))
13
+ continue;
14
+ const key = property.key;
15
+ if (isNode(key) && (key.name === name || key.value === name))
16
+ return property.value;
17
+ }
18
+ return undefined;
19
+ }
20
+ function declaredScriptOf(value) {
21
+ if (isNode(value) && typeof value.value === 'string')
22
+ return { src: value.value, ssr: false };
23
+ if (!isNode(value) || value.type !== 'ObjectExpression')
24
+ return undefined;
25
+ const src = propertyValue(value, 'src');
26
+ const ssr = propertyValue(value, 'ssr');
27
+ if (!isNode(src) || typeof src.value !== 'string')
28
+ return undefined;
29
+ return { src: src.value, ssr: isNode(ssr) && ssr.value === true };
30
+ }
31
+ function collectDeclaredScripts(value, scripts) {
32
+ if (Array.isArray(value)) {
33
+ for (const child of value)
34
+ collectDeclaredScripts(child, scripts);
35
+ return;
36
+ }
37
+ if (!isNode(value))
38
+ return;
39
+ if (value.type === 'ObjectExpression') {
40
+ const listed = propertyValue(value, 'scripts');
41
+ if (isNode(listed) && listed.type === 'ArrayExpression' && Array.isArray(listed.elements)) {
42
+ for (const element of listed.elements) {
43
+ const script = declaredScriptOf(element);
44
+ if (script)
45
+ scripts.push(script);
46
+ }
47
+ }
48
+ const own = declaredScriptOf(value);
49
+ if (own?.ssr)
50
+ scripts.push(own);
51
+ }
52
+ for (const [key, child] of Object.entries(value)) {
53
+ if (key !== 'type' && typeof child === 'object')
54
+ collectDeclaredScripts(child, scripts);
55
+ }
56
+ }
57
+ /**
58
+ * Lists the scripts a module's declarations name with a literal `src`, relative to that module.
59
+ *
60
+ * @remarks
61
+ * Finds each string or `{ src }` entry of a literal `scripts: [...]` array, and any `{ src, ssr: true }` object.
62
+ * A `src` that is computed at runtime is not found.
63
+ */
64
+ export function findDeclaredScripts(file, code, lang) {
65
+ const scripts = [];
66
+ collectDeclaredScripts(parseModuleSource(file, code, { sourceType: 'module', lang }).program, scripts);
67
+ return scripts;
68
+ }
69
+ /**
70
+ * The parser language for a file name, or `undefined` when it is not a script module.
71
+ */
72
+ export function scriptModuleLanguage(file) {
73
+ return PARSER_LANGUAGES.find((language) => file.endsWith(`.${language}`));
74
+ }
75
+ /**
76
+ * Emits each `ssr: true` script a declaration lists as an entry of the server build that bundles the declaration.
77
+ *
78
+ * @remarks
79
+ * A custom element script that the server also evaluates is not imported by the component that lists it, so only
80
+ * the declaration names it: `dependencies.scripts: [{ src: './x.script.js', ssr: true }]`, with `src` relative to the
81
+ * declaring module. The script then shares chunks with the rest of the build and keeps its exports like any
82
+ * entry, so no second build is needed to add it. Only a literal `src` beside a literal `ssr: true` is found; a
83
+ * script path computed at runtime is not.
84
+ */
85
+ export function createSsrScriptEntriesPlugin() {
86
+ return {
87
+ name: 'ecopages:ssr-script-entries',
88
+ transform: {
89
+ filter: { code: SSR_SCRIPT_PATTERN },
90
+ handler(code, id, meta) {
91
+ const file = fromRolldownModuleId(id);
92
+ const lang = PARSER_LANGUAGES.find((language) => language === meta.moduleType) ?? 'js';
93
+ for (const { src, ssr } of findDeclaredScripts(file, code, lang)) {
94
+ if (!ssr)
95
+ continue;
96
+ const script = path.resolve(path.dirname(file), src);
97
+ if (fileSystem.exists(script))
98
+ this.emitFile({ type: 'chunk', id: script });
99
+ }
100
+ return null;
101
+ },
102
+ },
103
+ };
104
+ }
@@ -66,7 +66,10 @@ export function resolveBuildPluginOrder(appConfig, environment, options) {
66
66
  const excluded = new Set(options.excludeAppBuildPlugins);
67
67
  const appPlugins = resolveAppBuildPlugins(appConfig, environment).filter((plugin) => !excluded.has(plugin.name));
68
68
  const plugins = mergeCallerBuildPlugins(appPlugins, options.callerPlugins, environment);
69
- const coreTransforms = [createEcoComponentMetaPlugin({ config: appConfig }), ...(options.coreTransforms ?? [])];
69
+ const coreTransforms = [
70
+ createEcoComponentMetaPlugin({ config: appConfig, environment }),
71
+ ...(options.coreTransforms ?? []),
72
+ ];
70
73
  const names = new Set(plugins.map((plugin) => plugin.name));
71
74
  for (const transform of coreTransforms) {
72
75
  if (names.has(transform.name)) {
@@ -34,7 +34,12 @@ export declare function requireProductionServerModules(appConfig: EcoPagesAppCon
34
34
  * Names the source file and tells the operator to run `ecopages build`. It is
35
35
  * never a compile fallback.
36
36
  */
37
- export declare function missingProductionServerModuleError(sourceKey: string): Error;
37
+ /** The production server build holds no module for a source the app imports. */
38
+ export declare class MissingProductionServerModuleError extends Error {
39
+ readonly sourceKey: string;
40
+ constructor(sourceKey: string);
41
+ }
42
+ export declare function missingProductionServerModuleError(sourceKey: string): MissingProductionServerModuleError;
38
43
  /**
39
44
  * Finds the production map key for `filePath`: its path relative to `rootDir`, when the map records it.
40
45
  *
@@ -81,8 +81,17 @@ export function requireProductionServerModules(appConfig) {
81
81
  * Names the source file and tells the operator to run `ecopages build`. It is
82
82
  * never a compile fallback.
83
83
  */
84
+ /** The production server build holds no module for a source the app imports. */
85
+ export class MissingProductionServerModuleError extends Error {
86
+ sourceKey;
87
+ constructor(sourceKey) {
88
+ super(`No compiled server module for ${sourceKey}. Run \`ecopages build\`.`);
89
+ this.name = 'MissingProductionServerModuleError';
90
+ this.sourceKey = sourceKey;
91
+ }
92
+ }
84
93
  export function missingProductionServerModuleError(sourceKey) {
85
- return new Error(`No compiled server module for ${sourceKey}. Run \`ecopages build\`.`);
94
+ return new MissingProductionServerModuleError(sourceKey);
86
95
  }
87
96
  function modulePathWithoutQuery(filePath) {
88
97
  const query = filePath.indexOf('?');
@@ -37,6 +37,15 @@ export declare function viewExtensionFilter(extensions: readonly string[]): RegE
37
37
  * when it renders the view.
38
38
  */
39
39
  export declare function createViewReference<P = Record<string, unknown>>(filePath: string, integration?: string | null): ViewReference<P>;
40
+ /**
41
+ * True when `filePath` is a view the server entry imported, so a View Reference exists for it.
42
+ *
43
+ * @remarks
44
+ * The registry is the module-level set `createViewReference` fills, in development by the preload and in
45
+ * production by the imported-view plugin. The preload names a view by its absolute path, which is what this
46
+ * checks, so it answers for the development server; a production bundle names views relative to the app root.
47
+ */
48
+ export declare function isViewReferencePath(filePath: string): boolean;
40
49
  /**
41
50
  * Synthetic ESM source the CLI hook and server-entry plugin evaluate instead of the view.
42
51
  *
@@ -101,6 +101,17 @@ export function createViewReference(filePath, integration) {
101
101
  viewReferences.set(filePath, reference);
102
102
  return reference;
103
103
  }
104
+ /**
105
+ * True when `filePath` is a view the server entry imported, so a View Reference exists for it.
106
+ *
107
+ * @remarks
108
+ * The registry is the module-level set `createViewReference` fills, in development by the preload and in
109
+ * production by the imported-view plugin. The preload names a view by its absolute path, which is what this
110
+ * checks, so it answers for the development server; a production bundle names views relative to the app root.
111
+ */
112
+ export function isViewReferencePath(filePath) {
113
+ return viewReferences.has(path.resolve(filePath));
114
+ }
104
115
  /**
105
116
  * Synthetic ESM source the CLI hook and server-entry plugin evaluate instead of the view.
106
117
  *
package/src/build.d.ts CHANGED
@@ -3,7 +3,8 @@ export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render
3
3
  export { restoreProductionBrowserBuild } from './static-site-generator/production-page-browser-graph-prebuild.js';
4
4
  export { type BuildAdapter, type BuildExecutor, type BuildOptions, type BuildResult, resolveIntegrationDependencies, setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
5
5
  export { CONTENT_COMPONENT_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, type ParsedCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
6
- export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
6
+ export { isServerOnlyModuleSpecifier } from './utils/file-roles.js';
7
+ export { isNodeBuiltinSpecifier } from './utils/node-builtin.js';
7
8
  export { shouldBuildPagesUnifiedGraph } from './build/cache/pages-unified-graph-build.js';
8
9
  export { BuildQueue } from './build/runtime/build-queue.js';
9
10
  export { buildServerModule } from './build/server-module.js';
@@ -12,6 +13,7 @@ export { parseModuleSource, recordModuleTransformProfile } from './cache/index.j
12
13
  export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
13
14
  export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
14
15
  export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, type RequestPipelineMetricsState, } from './diagnostics/request-pipeline-metrics.js';
16
+ export { readExportedComponentIdentities } from './plugins/eco-component-meta-plugin.js';
15
17
  export { findIntegrationForFile } from './plugins/find-integration-for-file.js';
16
18
  export { toPackageRootSpecifier } from './plugins/package-specifier.js';
17
19
  export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './plugins/tsconfig-import-resolver.js';
package/src/build.js CHANGED
@@ -3,7 +3,8 @@ export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render
3
3
  export { restoreProductionBrowserBuild } from './static-site-generator/production-page-browser-graph-prebuild.js';
4
4
  export { resolveIntegrationDependencies, setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
5
5
  export { CONTENT_COMPONENT_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
6
- export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
6
+ export { isServerOnlyModuleSpecifier } from './utils/file-roles.js';
7
+ export { isNodeBuiltinSpecifier } from './utils/node-builtin.js';
7
8
  export { shouldBuildPagesUnifiedGraph } from './build/cache/pages-unified-graph-build.js';
8
9
  export { BuildQueue } from './build/runtime/build-queue.js';
9
10
  export { buildServerModule } from './build/server-module.js';
@@ -12,6 +13,7 @@ export { parseModuleSource, recordModuleTransformProfile } from './cache/index.j
12
13
  export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
13
14
  export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
14
15
  export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, } from './diagnostics/request-pipeline-metrics.js';
16
+ export { readExportedComponentIdentities } from './plugins/eco-component-meta-plugin.js';
15
17
  export { findIntegrationForFile } from './plugins/find-integration-for-file.js';
16
18
  export { toPackageRootSpecifier } from './plugins/package-specifier.js';
17
19
  export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './plugins/tsconfig-import-resolver.js';
package/src/cli.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What the `ecopages` CLI reads before it starts an app process.
3
+ *
4
+ * @remarks
5
+ * The CLI parent process only plans the launch and spawns the app, which loads the build and config modules
6
+ * itself. This entry keeps the parent off the `build` and `config` barrels, so each command starts without
7
+ * loading the bundler.
8
+ * @module
9
+ */
10
+ export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
11
+ export { ENTRY_COMMAND_FLAGS, getEntryCommandFlagNames } from './utils/entry-command-flags.js';
12
+ export { getEcopagesEnv, isEcopagesEnvEnabled } from './env.js';
13
+ export { resolveEcoConfigPath, resolveEmittedEcoConfigPath } from './config/resolve-eco-config-path.js';
14
+ export { assertProductionConfigIdentity, resolveProductionDistDir, resolveProductionServerEntry, } from './build/server-bundle-deploy-manifest.js';
package/src/cli.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What the `ecopages` CLI reads before it starts an app process.
3
+ *
4
+ * @remarks
5
+ * The CLI parent process only plans the launch and spawns the app, which loads the build and config modules
6
+ * itself. This entry keeps the parent off the `build` and `config` barrels, so each command starts without
7
+ * loading the bundler.
8
+ * @module
9
+ */
10
+ export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
11
+ export { ENTRY_COMMAND_FLAGS, getEntryCommandFlagNames } from './utils/entry-command-flags.js';
12
+ export { getEcopagesEnv, isEcopagesEnvEnabled } from './env.js';
13
+ export { resolveEcoConfigPath, resolveEmittedEcoConfigPath } from './config/resolve-eco-config-path.js';
14
+ export { assertProductionConfigIdentity, resolveProductionDistDir, resolveProductionServerEntry, } from './build/server-bundle-deploy-manifest.js';
@@ -16,6 +16,7 @@ import type { CustomElementScriptPreloadScopeState } from '../../route-renderer/
16
16
  import type { DevelopmentInvalidationService } from '../../dev/invalidation/development-invalidation.service.js';
17
17
  import type { DevelopmentStylesheetService } from '../../dev/stylesheets/development-stylesheet.service.js';
18
18
  import type { PageCacheService } from '../../page-cache/page-cache-service.js';
19
+ import type { RouteRegistry } from '../../router/server/route-registry.js';
19
20
  import type { IHmrManager } from '../../types/contracts.js';
20
21
  export { requireAppRuntime } from '../../utils/app-runtime.js';
21
22
  export type { RegisteredScriptEntrypointChangeHandler } from '../../types/contracts.js';
@@ -94,6 +95,18 @@ export interface AppRuntime {
94
95
  requestPipelineMetrics: RequestPipelineMetricsState;
95
96
  origin: string;
96
97
  hmr: IHmrManager | null;
98
+ /**
99
+ * The Route Registry of the running server, `null` until the server creates it.
100
+ */
101
+ router: RouteRegistry | null;
102
+ /**
103
+ * Absolute source paths of the modules a rendered Page references as a Layout.
104
+ *
105
+ * @remarks
106
+ * Filled during route preparation, so it only grows within a session and holds the Layouts that were
107
+ * rendered. A Layout is whatever a Page passes as `eco.page({ layout })`, never a folder.
108
+ */
109
+ layoutFiles: Set<string>;
97
110
  /**
98
111
  * Processed and bundled dependencies of the production build, by dependency key, shared by every
99
112
  * asset-processing service.
@@ -77,6 +77,8 @@ export function createAppRuntime(appConfig, options = {}) {
77
77
  requestPipelineMetrics: createRequestPipelineMetricsState(),
78
78
  origin: appConfig.baseUrl,
79
79
  hmr: null,
80
+ router: null,
81
+ layoutFiles: new Set(),
80
82
  processedAssets: new ProcessedAssetLedger(appConfig.rootDir),
81
83
  processedStylesheets: new ProcessedStylesheetCache(),
82
84
  staticGenerationActive: false,
@@ -7,7 +7,7 @@ import { appLogger } from '../../global/app-logger.js';
7
7
  import { HTML_PAGES_INTEGRATION_NAME } from '../../html-pages/html-page-module.js';
8
8
  import { HtmlPagesPlugin } from '../../html-pages/html-pages.plugin.js';
9
9
  import { invariant } from '../../utils/invariant.js';
10
- import { ENDPOINT_FILE_EXTENSIONS, findEndpointFileExtension } from '../../utils/endpoint-file-extensions.js';
10
+ import { FILE_ROLE_SUFFIXES, matchRoleSuffix } from '../../utils/file-roles.js';
11
11
  import { DEFAULT_ECOPAGES_DIST_DIR, DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, DEFAULT_ECOPAGES_WORK_DIR, } from '../../constants.js';
12
12
  import { assertResponseHeaderRules } from '../../adapters/shared/http/response-headers.js';
13
13
  import { collectConfigModuleFiles } from '../config-module-files.js';
@@ -16,7 +16,10 @@ import { listProductionServerModuleKeysFromDist } from '../../build/server/serve
16
16
  import { findStylesheetProcessor } from '../../plugins/stylesheet-kinds.js';
17
17
  import { toRootRelativePath } from '../../utils/root-relative-path.js';
18
18
  import { CLIENT_OUTPUT_DIR, SERVER_BUNDLE_DIR } from '../../utils/resolve-entry-file.js';
19
+ import { DEFAULT_PAGES_DIR } from '../../router/server/pages-dir.js';
19
20
  const finalizedPluginInstances = new WeakSet();
21
+ /** Options that named a folder the framework used to treat as a role. */
22
+ const REMOVED_DIRECTORY_OPTIONS = ['layoutsDir', 'componentsDir'];
20
23
  /**
21
24
  * Rejects values that are not a `defineConfig(...)` object.
22
25
  *
@@ -30,6 +33,12 @@ function assertUserConfig(userConfig, configFilePath) {
30
33
  const source = configFilePath ? ` from ${configFilePath}` : '';
31
34
  throw new Error(`Expected a defineConfig(...) object but received an already finalized app config${source}. Export defineConfig(...) from eco.config.ts and let createApp() finalize it.`);
32
35
  }
36
+ for (const option of REMOVED_DIRECTORY_OPTIONS) {
37
+ if (option in userConfig) {
38
+ const source = configFilePath ? ` in ${configFilePath}` : '';
39
+ throw new Error(`The ${option} option${source} was removed. Layouts and components are found from the files that reference them, so no folder carries meaning. Delete ${option} from the config; src/layouts and src/components stay as conventions, and any folder works.`);
40
+ }
41
+ }
33
42
  if ('configFilePath' in userConfig) {
34
43
  throw new Error('finalizeEcoPagesConfig() takes the user config first: finalizeEcoPagesConfig(userConfig, { configFilePath }).');
35
44
  }
@@ -69,10 +78,8 @@ function resolveEmittedConfigRootDir(rootDir, configFilePath, distDirName, cwd)
69
78
  function resolveDirectories(userConfig) {
70
79
  return {
71
80
  srcDir: userConfig.srcDir || 'src',
72
- pagesDir: userConfig.pagesDir || 'pages',
81
+ pagesDir: userConfig.pagesDir || DEFAULT_PAGES_DIR,
73
82
  includesDir: userConfig.includesDir || 'includes',
74
- componentsDir: userConfig.componentsDir || 'components',
75
- layoutsDir: userConfig.layoutsDir || 'layouts',
76
83
  publicDir: userConfig.publicDir || 'public',
77
84
  distDir: userConfig.distDir || DEFAULT_ECOPAGES_DIST_DIR,
78
85
  workDir: userConfig.workDir || DEFAULT_ECOPAGES_WORK_DIR,
@@ -122,8 +129,8 @@ function collectTemplateExtensions(integrations) {
122
129
  appLogger.debug('Both kitajs and react integrations are enabled. Use per-file JSX import source/pragma consistently (e.g. `/** @jsxImportSource react */` for React files and `/** @jsxImportSource @kitajs/html */` for Kita files).');
123
130
  }
124
131
  for (const integration of integrations) {
125
- const reserved = integration.extensions.find((extension) => findEndpointFileExtension(extension));
126
- invariant(reserved === undefined, `Integration "${integration.name}" registers "${reserved}", which is reserved for endpoint files: ${ENDPOINT_FILE_EXTENSIONS.join(', ')}.`);
132
+ const reserved = integration.extensions.find((extension) => matchRoleSuffix(extension));
133
+ invariant(reserved === undefined, `Integration "${integration.name}" registers "${reserved}", which is reserved for role files: ${FILE_ROLE_SUFFIXES.join(', ')}.`);
127
134
  }
128
135
  const extensions = integrations.flatMap((integration) => integration.extensions);
129
136
  const duplicateExtension = findDuplicate(extensions);
@@ -214,9 +221,7 @@ function createAbsolutePaths(config, configFilePath, configModuleFiles) {
214
221
  srcDir,
215
222
  distDir: path.resolve(config.rootDir, config.distDir, CLIENT_OUTPUT_DIR),
216
223
  workDir: path.resolve(config.rootDir, config.workDir),
217
- componentsDir: path.join(srcDir, config.componentsDir),
218
224
  includesDir,
219
- layoutsDir: path.join(srcDir, config.layoutsDir),
220
225
  pagesDir,
221
226
  publicDir: path.join(srcDir, config.publicDir),
222
227
  htmlTemplatePath: resolveSemanticTemplatePath(includesDir, 'html', config.templatesExt, config.rootDir, config.distDir),
@@ -49,11 +49,6 @@ export type EcoPagesAppConfig = {
49
49
  * @default "includes"
50
50
  */
51
51
  includesDir: string;
52
- /**
53
- * The directory where the layouts are located
54
- * @default "layouts"
55
- */
56
- layoutsDir: string;
57
52
  /**
58
53
  * The directory where the output will be located
59
54
  * @default "dist"
@@ -74,11 +69,6 @@ export type EcoPagesAppConfig = {
74
69
  * The templates extensions based on the integrations
75
70
  */
76
71
  templatesExt: string[];
77
- /**
78
- * The directory where the components are located
79
- * @default "components"
80
- */
81
- componentsDir: string;
82
72
  /**
83
73
  * The robots.txt configuration
84
74
  */
@@ -131,12 +121,10 @@ export type EcoPagesAppConfig = {
131
121
  * restarts on the same set.
132
122
  */
133
123
  configModuleFiles: string[];
134
- componentsDir: string;
135
124
  /** Public output directory served by the runtime (`<distDir>/client`). */
136
125
  distDir: string;
137
126
  workDir: string;
138
127
  includesDir: string;
139
- layoutsDir: string;
140
128
  pagesDir: string;
141
129
  projectDir: string;
142
130
  publicDir: string;
@@ -1,5 +1,7 @@
1
1
  export declare const DEFAULT_ECO_CONFIG_FILENAME = "eco.config.ts";
2
2
  export declare const ECOPAGES_CONFIG_FILE_ENV = "ECOPAGES_CONFIG_FILE";
3
+ /** The file name of the config module `ecopages build` emits into the server bundle. */
4
+ export declare const EMITTED_ECO_CONFIG_FILENAME = "eco.config.mjs";
3
5
  /**
4
6
  * Resolves the project root used when `EcoPagesUserConfig.rootDir` is omitted.
5
7
  *
@@ -3,9 +3,10 @@ import { getEcopagesEnv } from '../env.js';
3
3
  import { fileSystem } from '@ecopages/file-system';
4
4
  import { SERVER_BUNDLE_DIR } from '../utils/resolve-entry-file.js';
5
5
  import { getProductionServerBundleDir } from '../utils/server-bundle-context.js';
6
- import { EMITTED_ECO_CONFIG_FILENAME } from './server-config-bundle.js';
7
6
  export const DEFAULT_ECO_CONFIG_FILENAME = 'eco.config.ts';
8
7
  export const ECOPAGES_CONFIG_FILE_ENV = 'ECOPAGES_CONFIG_FILE';
8
+ /** The file name of the config module `ecopages build` emits into the server bundle. */
9
+ export const EMITTED_ECO_CONFIG_FILENAME = 'eco.config.mjs';
9
10
  /**
10
11
  * Resolves the project root used when `EcoPagesUserConfig.rootDir` is omitted.
11
12
  *
@@ -1,6 +1,5 @@
1
1
  import type { BuildSuccess } from '../build/contracts/build-contracts.js';
2
2
  import type { EcoPagesAppConfig } from '../config/internal-types.js';
3
- export declare const EMITTED_ECO_CONFIG_FILENAME = "eco.config.mjs";
4
3
  export interface BundleEcoConfigModuleResult {
5
4
  emittedConfigPath: string;
6
5
  buildResult: BuildSuccess;
@@ -3,7 +3,7 @@ import { fileSystem } from '@ecopages/file-system';
3
3
  import { createServerBuildRequest } from '../build/runtime/build-request-policy.js';
4
4
  import { buildOrThrow } from '../build/runtime/build-queue.js';
5
5
  import { getServerBundleOutputPaths } from '../build/server-bundle-deploy-manifest.js';
6
- export const EMITTED_ECO_CONFIG_FILENAME = 'eco.config.mjs';
6
+ import { EMITTED_ECO_CONFIG_FILENAME } from './resolve-eco-config-path.js';
7
7
  /**
8
8
  * Compiles the selected Ecopages config module for production server startup.
9
9
  */
@@ -72,12 +72,6 @@ export type EcoPagesUserConfig = {
72
72
  * @default 'includes'
73
73
  */
74
74
  includesDir?: string;
75
- /**
76
- * Directory containing layout components, relative to `srcDir`.
77
- *
78
- * @default 'layouts'
79
- */
80
- layoutsDir?: string;
81
75
  /**
82
76
  * Output root for the production build, relative to `rootDir`. Public files are written to `client/` and private server output to `server/` beneath it.
83
77
  *
@@ -90,12 +84,6 @@ export type EcoPagesUserConfig = {
90
84
  * @default '.eco'
91
85
  */
92
86
  workDir?: string;
93
- /**
94
- * Directory containing island and client components, relative to `srcDir`.
95
- *
96
- * @default 'components'
97
- */
98
- componentsDir?: string;
99
87
  /**
100
88
  * Configuration for automatic `robots.txt` generation.
101
89
  */
@@ -15,6 +15,8 @@ type EcoIslandRuntime = {
15
15
  type EcoPageData = {
16
16
  module: string;
17
17
  props: Record<string, unknown>;
18
+ /** The props each layout tier renders with, resolved on the server; absent when the document carries none. */
19
+ tiers?: readonly Record<string, unknown>[];
18
20
  /** Set by a react-router navigation to the document it fetched; absent otherwise. */
19
21
  document?: Document;
20
22
  };
@@ -131,8 +131,6 @@ export declare class DevelopmentInvalidationService {
131
131
  matchesAdditionalWatchPaths(filePath: string): boolean;
132
132
  /** Returns whether a file is an include or template source. */
133
133
  isIncludeSourceFile(filePath: string): boolean;
134
- /** Returns whether a file is an explicit server-rendered view module. */
135
- isExplicitServerViewFile(filePath: string): boolean;
136
134
  /** Returns whether a file under the source directory has an integration template extension. */
137
135
  isTemplateSourceFile(filePath: string): boolean;
138
136
  /**
@@ -290,12 +290,6 @@ export class DevelopmentInvalidationService {
290
290
  const resolvedPath = path.resolve(filePath);
291
291
  return isPathInside(resolvedPath, this.appConfig.absolutePaths.includesDir) && this.isSourceFile(resolvedPath);
292
292
  }
293
- /** Returns whether a file is an explicit server-rendered view module. */
294
- isExplicitServerViewFile(filePath) {
295
- const resolvedPath = path.resolve(filePath);
296
- const viewsDir = path.join(this.appConfig.absolutePaths.srcDir, 'views');
297
- return isPathInside(resolvedPath, viewsDir) && this.isSourceFile(resolvedPath);
298
- }
299
293
  /** Returns whether a file under the source directory has an integration template extension. */
300
294
  isTemplateSourceFile(filePath) {
301
295
  const resolvedPath = path.resolve(filePath);
@@ -314,11 +308,7 @@ export class DevelopmentInvalidationService {
314
308
  */
315
309
  isServerModuleSourceFile(filePath) {
316
310
  const resolvedPath = path.resolve(filePath);
317
- const sourceRoots = [
318
- this.appConfig.absolutePaths.srcDir,
319
- this.appConfig.absolutePaths.includesDir,
320
- path.join(this.appConfig.absolutePaths.srcDir, 'views'),
321
- ];
311
+ const sourceRoots = [this.appConfig.absolutePaths.srcDir, this.appConfig.absolutePaths.includesDir];
322
312
  return sourceRoots.some((root) => isPathInside(resolvedPath, root)) && this.isSourceFile(resolvedPath);
323
313
  }
324
314
  isSourceFile(filePath) {
@@ -30,36 +30,49 @@ const BROWSER_FIRST_SPECIFIER = new RegExp(`^${escapeRegExp(BROWSER_FIRST_PACKAG
30
30
  const PIN_ENTRY_NAME = '__eco_vendor_pin';
31
31
  const PIN_SPECIFIER = 'ecopages:vendor-pin';
32
32
  const PIN_MODULE_ID = '\0ecopages-vendor-pin';
33
+ const RUNTIME_PIN_ENTRY_NAME = '__eco_vendor_runtime_pin';
34
+ const RUNTIME_PIN_SPECIFIER = 'ecopages:vendor-runtime-pin';
35
+ const RUNTIME_PIN_MODULE_ID = '\0ecopages-vendor-runtime-pin';
36
+ function exactly(value) {
37
+ return new RegExp(`^${escapeRegExp(value)}$`, 'u');
38
+ }
33
39
  /**
34
- * Adds an entry to each vendor build that keeps the shape of the other entries the same from one build to the next.
40
+ * Adds two entries to each vendor build that keep the shape of the other entries the same from one build to the next.
35
41
  *
36
42
  * @remarks
37
43
  * A browser that loaded a vendor file keeps its module, so a later build of the graph must not change a file it
38
- * already served; when it does, the page reloads. Two things would change one as packages arrive. Rolldown puts the
39
- * helpers its CommonJS interop needs in one shared runtime chunk, keeps only the ones the build uses and names the
40
- * chunk after its content, so a package that needs one more helper renames it in every entry that imports it. And a
41
- * CommonJS entry exports its module's `require` function only once another entry imports it, so a package that
42
- * imports `react/jsx-runtime` adds an export to that entry. The pin re-exports every helper and the namespace of every
43
- * entry whose file has no `import` or `export` statement, so each runtime helper and each CommonJS `require` export is
44
- * there from the first build. It leaves ES module entries alone: importing one would move its code into a shared
45
- * chunk behind the entry. Nothing requests the pin's own output.
44
+ * already served; when it does, the page reloads. Two things would change one as packages arrive.
45
+ *
46
+ * Rolldown puts the helpers its CommonJS interop needs in one runtime module. It merges that module into the one
47
+ * chunk that needs it, and splits it into a `rolldown-runtime-*` chunk once a second chunk needs it, so the first
48
+ * ES module that needs a helper moves the helpers out of every CommonJS package's chunk and changes that chunk and
49
+ * its entry. The runtime pin re-exports the module from an entry of its own, so the runtime is always a chunk of
50
+ * its own, with every helper kept, from the first build; its name and content no longer depend on the packages
51
+ * that use it.
52
+ *
53
+ * A CommonJS entry exports its module's `require` function only once another entry imports it, so a package that
54
+ * imports `react/jsx-runtime` adds an export to that entry. The pin re-exports the namespace of every entry whose
55
+ * file has no `import` or `export` statement, so each `require` export is there from the first build. It leaves ES
56
+ * module entries alone: importing one would move its code into a shared chunk behind the entry. Nothing requests
57
+ * the output of either pin.
46
58
  */
47
- function exactly(value) {
48
- return new RegExp(`^${escapeRegExp(value)}$`, 'u');
49
- }
50
59
  function createVendorPinPlugin(entries) {
51
- const contents = [
52
- 'export * from "\\0rolldown/runtime.js";',
53
- ...entries
54
- .filter((entry) => !hasModuleSyntax(entry.entryPath))
55
- .map((entry, index) => `export * as __eco_pin_${index} from ${JSON.stringify(entry.entryPath)};`),
56
- ].join('\n');
60
+ const contents = entries
61
+ .filter((entry) => !hasModuleSyntax(entry.entryPath))
62
+ .map((entry, index) => `export * as __eco_pin_${index} from ${JSON.stringify(entry.entryPath)};`)
63
+ .join('\n');
64
+ const runtimeContents = 'export * from "\\0rolldown/runtime.js";';
57
65
  return {
58
66
  name: 'ecopages-dev-vendor-pin',
59
- cacheKey: contents,
67
+ cacheKey: `${contents}\n${runtimeContents}`,
60
68
  setup(build) {
61
69
  build.onResolve({ filter: exactly(PIN_SPECIFIER) }, () => ({ path: PIN_MODULE_ID }));
62
70
  build.onLoad({ filter: exactly(PIN_MODULE_ID) }, () => ({ contents, loader: 'js' }));
71
+ build.onResolve({ filter: exactly(RUNTIME_PIN_SPECIFIER) }, () => ({ path: RUNTIME_PIN_MODULE_ID }));
72
+ build.onLoad({ filter: exactly(RUNTIME_PIN_MODULE_ID) }, () => ({
73
+ contents: runtimeContents,
74
+ loader: 'js',
75
+ }));
63
76
  },
64
77
  };
65
78
  }
@@ -508,6 +521,7 @@ export class DevTransformVendorRegistry {
508
521
  entrypoints: {
509
522
  ...Object.fromEntries(entries.map((entry) => [path.basename(entry.url, '.js'), entry.entryPath])),
510
523
  [PIN_ENTRY_NAME]: PIN_SPECIFIER,
524
+ [RUNTIME_PIN_ENTRY_NAME]: RUNTIME_PIN_SPECIFIER,
511
525
  },
512
526
  outdir: this.resolveOutdir(),
513
527
  naming: '[name]',