@ecopages/react 0.2.0-beta.29 → 0.2.0-beta.30
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/react",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.30",
|
|
4
4
|
"description": "React integration for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -93,16 +93,16 @@
|
|
|
93
93
|
"directory": "packages/integrations/react"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@ecopages/core": "0.2.0-beta.
|
|
96
|
+
"@ecopages/core": "0.2.0-beta.30",
|
|
97
97
|
"@types/react": "^19",
|
|
98
98
|
"@types/react-dom": "^19",
|
|
99
99
|
"react": "^19",
|
|
100
100
|
"react-dom": "^19"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@ecopages/file-system": "0.2.0-beta.
|
|
103
|
+
"@ecopages/file-system": "0.2.0-beta.30",
|
|
104
104
|
"@ecopages/logger": "^0.2.3",
|
|
105
|
-
"@ecopages/mdx": "0.2.0-beta.
|
|
105
|
+
"@ecopages/mdx": "0.2.0-beta.30",
|
|
106
106
|
"@mdx-js/mdx": "^3.1.1",
|
|
107
107
|
"oxc-parser": "^0.124.0",
|
|
108
108
|
"oxc-transform": "^0.124.0",
|
package/src/bundling/bundle.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import type { EcoPagesAppConfig } from '@ecopages/core';
|
|
10
|
+
import type { AssetProcessingService } from '@ecopages/core/services/asset-processing-service';
|
|
10
11
|
import type { ReactRouterAdapter } from '../contracts/router-adapter.js';
|
|
11
12
|
import type { CompileOptions } from '@mdx-js/mdx';
|
|
12
13
|
import { type ReactRuntimeImports } from './runtime-bundle.js';
|
|
@@ -42,11 +43,20 @@ export interface ReactClientBundleOptions {
|
|
|
42
43
|
export declare class BundleService {
|
|
43
44
|
private readonly runtimeBundleService;
|
|
44
45
|
private readonly config;
|
|
46
|
+
private pageLayoutNormalizationVendorPromise;
|
|
45
47
|
constructor(config: BundleServiceConfig);
|
|
46
48
|
/**
|
|
47
49
|
* Returns resolved runtime import paths for the React runtime.
|
|
48
50
|
*/
|
|
49
51
|
getRuntimeImports(): ReactRuntimeImports;
|
|
52
|
+
/**
|
|
53
|
+
* Processes the MDX-only page-layout-normalization vendor once per BundleService instance.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Concurrent callers share the same in-flight promise. Asset processing itself caches
|
|
57
|
+
* by dependency key, so repeats after success remain cheap.
|
|
58
|
+
*/
|
|
59
|
+
ensurePageLayoutNormalizationVendorProcessed(assetProcessingService: Pick<AssetProcessingService, 'processDependencies'>): Promise<void>;
|
|
50
60
|
/**
|
|
51
61
|
* Creates bundle options for a page or component entry.
|
|
52
62
|
*
|
package/src/bundling/bundle.js
CHANGED
|
@@ -8,6 +8,7 @@ import { isReactProductionRuntime } from "./runtime-mode.js";
|
|
|
8
8
|
class BundleService {
|
|
9
9
|
runtimeBundleService;
|
|
10
10
|
config;
|
|
11
|
+
pageLayoutNormalizationVendorPromise;
|
|
11
12
|
constructor(config) {
|
|
12
13
|
this.config = config;
|
|
13
14
|
this.runtimeBundleService = new RuntimeBundleService({
|
|
@@ -22,6 +23,25 @@ class BundleService {
|
|
|
22
23
|
getRuntimeImports() {
|
|
23
24
|
return this.runtimeBundleService.getRuntimeImports();
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Processes the MDX-only page-layout-normalization vendor once per BundleService instance.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* Concurrent callers share the same in-flight promise. Asset processing itself caches
|
|
31
|
+
* by dependency key, so repeats after success remain cheap.
|
|
32
|
+
*/
|
|
33
|
+
async ensurePageLayoutNormalizationVendorProcessed(assetProcessingService) {
|
|
34
|
+
if (!this.pageLayoutNormalizationVendorPromise) {
|
|
35
|
+
this.pageLayoutNormalizationVendorPromise = assetProcessingService.processDependencies(
|
|
36
|
+
this.runtimeBundleService.getPageLayoutNormalizationDependencies(),
|
|
37
|
+
"react:page-layout-normalization"
|
|
38
|
+
).then(() => void 0).catch((error) => {
|
|
39
|
+
this.pageLayoutNormalizationVendorPromise = void 0;
|
|
40
|
+
throw error;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
await this.pageLayoutNormalizationVendorPromise;
|
|
44
|
+
}
|
|
25
45
|
/**
|
|
26
46
|
* Creates bundle options for a page or component entry.
|
|
27
47
|
*
|
|
@@ -55,6 +55,16 @@ export declare class RuntimeBundleService {
|
|
|
55
55
|
getDependencies(options?: {
|
|
56
56
|
modes?: RuntimeMode[];
|
|
57
57
|
}): AssetDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Declares the MDX-only page-layout-normalization vendor for the current runtime mode.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Kept out of {@link getDependencies} so non-MDX pages do not pay for this vendor during
|
|
63
|
+
* integration setup. Callers process these assets once when an MDX page graph is prepared.
|
|
64
|
+
*/
|
|
65
|
+
getPageLayoutNormalizationDependencies(options?: {
|
|
66
|
+
modes?: RuntimeMode[];
|
|
67
|
+
}): AssetDefinition[];
|
|
58
68
|
createRuntimeAliasPlugin(mode?: RuntimeMode): EcoBuildPlugin;
|
|
59
69
|
}
|
|
60
70
|
export {};
|
|
@@ -187,15 +187,6 @@ class RuntimeBundleService {
|
|
|
187
187
|
plugins: [reactVendorImportRewritePlugin]
|
|
188
188
|
}
|
|
189
189
|
}),
|
|
190
|
-
createBrowserRuntimeScriptAsset({
|
|
191
|
-
importPath: PAGE_LAYOUT_NORMALIZATION_PACKAGE,
|
|
192
|
-
name: "page-layout-normalization",
|
|
193
|
-
fileName: this.getPageLayoutNormalizationVendorFileName(mode),
|
|
194
|
-
bundleOptions: {
|
|
195
|
-
define: this.createRuntimeDefines(mode),
|
|
196
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME]
|
|
197
|
-
}
|
|
198
|
-
}),
|
|
199
190
|
createBrowserRuntimeScriptAsset({
|
|
200
191
|
importPath: LAYOUT_COMPOSE_PACKAGE,
|
|
201
192
|
name: "layout-compose",
|
|
@@ -245,6 +236,31 @@ class RuntimeBundleService {
|
|
|
245
236
|
}
|
|
246
237
|
return dependencies;
|
|
247
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Declares the MDX-only page-layout-normalization vendor for the current runtime mode.
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* Kept out of {@link getDependencies} so non-MDX pages do not pay for this vendor during
|
|
244
|
+
* integration setup. Callers process these assets once when an MDX page graph is prepared.
|
|
245
|
+
*/
|
|
246
|
+
getPageLayoutNormalizationDependencies(options) {
|
|
247
|
+
const dependencies = [];
|
|
248
|
+
const modes = options?.modes ?? [this.getCurrentRuntimeMode()];
|
|
249
|
+
for (const mode of modes) {
|
|
250
|
+
dependencies.push(
|
|
251
|
+
createBrowserRuntimeScriptAsset({
|
|
252
|
+
importPath: PAGE_LAYOUT_NORMALIZATION_PACKAGE,
|
|
253
|
+
name: "page-layout-normalization",
|
|
254
|
+
fileName: this.getPageLayoutNormalizationVendorFileName(mode),
|
|
255
|
+
bundleOptions: {
|
|
256
|
+
define: this.createRuntimeDefines(mode),
|
|
257
|
+
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME]
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return dependencies;
|
|
263
|
+
}
|
|
248
264
|
createRuntimeAliasPlugin(mode = this.getCurrentRuntimeMode()) {
|
|
249
265
|
const aliasMap = this.getRuntimeAliasMap(mode);
|
|
250
266
|
const manifest = createBrowserRuntimeManifest(
|
|
@@ -247,20 +247,19 @@ class ReactRenderer extends IntegrationRenderer {
|
|
|
247
247
|
}
|
|
248
248
|
const isMdx = this.pageModuleService.isMdxFile(pagePath);
|
|
249
249
|
const declaredModules = this.pageModuleService.collectPageDeclaredModules(pageModule);
|
|
250
|
+
if (isMdx) {
|
|
251
|
+
await this.bundleService.ensurePageLayoutNormalizationVendorProcessed(this.assetProcessingService);
|
|
252
|
+
}
|
|
250
253
|
const dependencies = await this.hydrationAssetService.createPageBrowserGraphDependencies(
|
|
251
254
|
pagePath,
|
|
252
255
|
isMdx,
|
|
253
256
|
declaredModules
|
|
254
257
|
);
|
|
255
|
-
const assets =
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
processComponentDependencies: async (components) => await this.processComponentDependencies(components)
|
|
261
|
-
});
|
|
262
|
-
assets.push(...mdxConfigAssets);
|
|
263
|
-
}
|
|
258
|
+
const assets = isMdx ? await this.mdxConfigDependencyService.processMdxConfigDependencies({
|
|
259
|
+
pagePath,
|
|
260
|
+
config: pageModule.config,
|
|
261
|
+
processComponentDependencies: async (components) => await this.processComponentDependencies(components)
|
|
262
|
+
}) : [];
|
|
264
263
|
return { dependencies, assets };
|
|
265
264
|
} catch (error) {
|
|
266
265
|
if (error instanceof BundleError) {
|