@ecopages/react 0.6.1 → 0.7.1
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 +50 -87
- package/package.json +32 -14
- package/src/bundling/bootstrap-package-paths.d.ts +13 -1
- package/src/bundling/bootstrap-package-paths.js +25 -3
- package/src/bundling/bundle.d.ts +8 -36
- package/src/bundling/bundle.js +42 -73
- package/src/client-graph/ast-transform-eco-page.d.ts +10 -6
- package/src/client-graph/ast-transform-eco-page.js +56 -35
- package/src/client-graph/ast-transform-import-edits.d.ts +10 -2
- package/src/client-graph/ast-transform-import-edits.js +36 -6
- package/src/client-graph/ast-transform-stripped-imports.d.ts +37 -0
- package/src/client-graph/ast-transform-stripped-imports.js +191 -0
- package/src/client-graph/ast-transform-walk-imports.d.ts +4 -0
- package/src/client-graph/ast-transform-walk-imports.js +15 -1
- package/src/client-graph/ast-transform.d.ts +12 -3
- package/src/client-graph/ast-transform.js +41 -56
- package/src/client-graph/boundary-plugin-read-file-inline.d.ts +3 -0
- package/src/client-graph/boundary-plugin-read-file-inline.js +14 -10
- package/src/client-graph/boundary-plugin-transform.d.ts +5 -4
- package/src/client-graph/boundary-plugin-transform.js +6 -13
- package/src/client-graph/boundary-plugin.d.ts +47 -1
- package/src/client-graph/boundary-plugin.js +267 -53
- package/src/client-graph/foreign-boundary-rewrite.d.ts +31 -0
- package/src/client-graph/foreign-boundary-rewrite.js +360 -0
- package/src/client-graph/foreign-jsx-reach.d.ts +25 -0
- package/src/client-graph/foreign-jsx-reach.js +68 -0
- package/src/client-graph/module-classification.js +3 -10
- package/src/client-graph/reachability-traverse.js +35 -105
- package/src/client-graph/requested-exports-plan.d.ts +62 -0
- package/src/client-graph/requested-exports-plan.js +125 -0
- package/src/client-graph/scope-walk.d.ts +37 -0
- package/src/client-graph/scope-walk.js +407 -0
- package/src/client-graph/specifier-classification.d.ts +2 -1
- package/src/client-graph/specifier-classification.js +9 -7
- package/src/contracts/router-adapter.d.ts +9 -24
- package/src/dev-transform/react-dev-transform-contributor.d.ts +4 -4
- package/src/dev-transform/react-dev-transform-contributor.js +6 -7
- package/src/hmr/hmr-strategy-process.d.ts +7 -5
- package/src/hmr/hmr-strategy-process.js +21 -16
- package/src/hmr/hmr-strategy.d.ts +11 -10
- package/src/hmr/hmr-strategy.js +32 -53
- package/src/hmr/page-metadata-cache.js +1 -1
- package/src/hydration/browser/foreign-boundary.d.ts +29 -0
- package/src/hydration/browser/foreign-boundary.js +128 -0
- package/src/hydration/browser/island-hydration.d.ts +3 -4
- package/src/hydration/browser/island-hydration.js +3 -4
- package/src/hydration/browser/page-hydration-hmr.d.ts +8 -7
- package/src/hydration/browser/page-hydration-hmr.js +53 -10
- package/src/hydration/browser/page-hydration.d.ts +6 -5
- package/src/hydration/browser/page-hydration.js +8 -6
- package/src/hydration/foreign-subtree.d.ts +27 -0
- package/src/hydration/foreign-subtree.js +69 -0
- package/src/hydration/hydration-asset.d.ts +37 -29
- package/src/hydration/hydration-asset.js +74 -138
- package/src/hydration/hydration-island-entry-source.d.ts +17 -0
- package/src/hydration/hydration-island-entry-source.js +32 -0
- package/src/hydration/hydration-page-entry-source.d.ts +20 -2
- package/src/hydration/hydration-page-entry-source.js +17 -12
- package/src/hydration/page-data-reader.d.ts +4 -7
- package/src/hydration/page-data-reader.js +5 -10
- package/src/mdx/mdx-config-dependency.d.ts +10 -15
- package/src/mdx/mdx-config-dependency.js +9 -22
- package/src/mdx/mdx-loader-plugin.d.ts +2 -0
- package/src/mdx/mdx-loader-plugin.js +1 -0
- package/src/page/page-module.js +1 -1
- package/src/plugin/react.plugin.d.ts +0 -7
- package/src/plugin/react.plugin.js +4 -33
- package/src/plugin/react.types.d.ts +0 -29
- package/src/render/component-ssr.d.ts +18 -0
- package/src/render/component-ssr.js +37 -0
- package/src/render/layout-compose.d.ts +4 -2
- package/src/render/layout-compose.js +13 -6
- package/src/render/layout-render-tracker.d.ts +20 -0
- package/src/render/layout-render-tracker.js +33 -0
- package/src/render/react-renderer.d.ts +28 -10
- package/src/render/react-renderer.js +103 -38
- package/src/render/react-runtime.js +2 -2
- package/src/bundling/runtime-alias-map.d.ts +0 -12
- package/src/bundling/runtime-alias-map.js +0 -110
- package/src/bundling/runtime-bundle.d.ts +0 -70
- package/src/bundling/runtime-bundle.js +0 -233
- package/src/bundling/runtime-interop-plugin.d.ts +0 -5
- package/src/bundling/runtime-interop-plugin.js +0 -32
- package/src/bundling/runtime-mode.d.ts +0 -1
- package/src/bundling/runtime-mode.js +0 -10
- package/src/bundling/runtime-modules.d.ts +0 -21
- package/src/bundling/runtime-modules.js +0 -28
- package/src/hydration/bootstrap-imports.d.ts +0 -25
- package/src/hydration/bootstrap-imports.js +0 -33
- package/src/hydration/compiled-page-hydration-options.d.ts +0 -19
- package/src/hydration/compiled-page-hydration-options.js +0 -1
- package/src/hydration/hydration-script-compiler.d.ts +0 -47
- package/src/hydration/hydration-script-compiler.js +0 -213
- package/src/runtime/use-sync-external-store-with-selector.d.ts +0 -3
- package/src/runtime/use-sync-external-store-with-selector.js +0 -54
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AST transforms for the client graph boundary plugin.
|
|
3
3
|
*/
|
|
4
|
+
import type { ParseResult } from 'oxc-parser';
|
|
4
5
|
import { type RequestedExportRules } from './specifier-classification.js';
|
|
5
6
|
/**
|
|
6
|
-
* Parses a module using Oxc AST and
|
|
7
|
-
*
|
|
7
|
+
* Parses a module using Oxc AST and removes what must not reach the browser: forbidden imports,
|
|
8
|
+
* named imports outside the declared rules, server-only Page options, and the top-level code the
|
|
9
|
+
* browser module does not need that only removed code used or that uses a removed import.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Every edit is planned on the one parse of `source`, so error positions point into it. Throws
|
|
13
|
+
* when code the browser module needs still references a binding whose import is removed.
|
|
14
|
+
*
|
|
15
|
+
* @param requestedExports - The exports this module's importers use; `undefined` keeps every export.
|
|
16
|
+
* @param parsed - The parse of `source`, when the caller already has it.
|
|
8
17
|
*/
|
|
9
|
-
export declare function transformModuleImports(source: string, filename: string, globallyAllowed: Map<string, Set<string> | '*'>, requestedExports:
|
|
18
|
+
export declare function transformModuleImports(source: string, filename: string, globallyAllowed: Map<string, Set<string> | '*'>, requestedExports: RequestedExportRules | undefined, preserveUnreachableSideEffectImports?: boolean, parsed?: ParseResult['program']): {
|
|
10
19
|
transformed: string;
|
|
11
20
|
modified: boolean;
|
|
12
21
|
};
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { parseModuleSource } from '@ecopages/core/build';
|
|
5
5
|
import { analyzeReachability } from './reachability-analyzer.js';
|
|
6
|
-
import {
|
|
6
|
+
import { collectServerOnlyPageCode } from './ast-transform-eco-page.js';
|
|
7
7
|
import { collectImportTransformEdits } from './ast-transform-walk-imports.js';
|
|
8
8
|
import { walkAstNodes } from './ast-walk.js';
|
|
9
|
+
import { planStrippedImportCleanup } from './ast-transform-stripped-imports.js';
|
|
9
10
|
import { applySourceEdits } from './ast-transform-import-edits.js';
|
|
10
|
-
import { mergeDeclaredModulesMap,
|
|
11
|
+
import { mergeDeclaredModulesMap, parseDeclaredModules, } from './specifier-classification.js';
|
|
11
12
|
function collectLocalDeclaredModules(program) {
|
|
12
13
|
const localDeclared = [];
|
|
13
14
|
walkAstNodes(program, (node) => {
|
|
@@ -21,71 +22,55 @@ function collectLocalDeclaredModules(program) {
|
|
|
21
22
|
});
|
|
22
23
|
return localDeclared;
|
|
23
24
|
}
|
|
24
|
-
function getImportedOrReexportedSource(statement) {
|
|
25
|
-
if (statement.type === 'ImportDeclaration') {
|
|
26
|
-
return statement.source.value;
|
|
27
|
-
}
|
|
28
|
-
if ((statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportAllDeclaration') &&
|
|
29
|
-
statement.source) {
|
|
30
|
-
return statement.source.value;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
function propagateRequestedExportRules(program, filename, reachability, requestedExports) {
|
|
35
|
-
for (const statement of program.body) {
|
|
36
|
-
const source = getImportedOrReexportedSource(statement);
|
|
37
|
-
if (!source)
|
|
38
|
-
continue;
|
|
39
|
-
const reachableRules = reachability.reachableImports.get(source);
|
|
40
|
-
const requestedModuleKey = resolveRequestedExportsKey(filename, source);
|
|
41
|
-
if (!requestedModuleKey || !reachableRules)
|
|
42
|
-
continue;
|
|
43
|
-
mergeRequestedExportRules(requestedExports, requestedModuleKey, reachableRules);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
25
|
/**
|
|
47
|
-
* Parses a module using Oxc AST and
|
|
48
|
-
*
|
|
26
|
+
* Parses a module using Oxc AST and removes what must not reach the browser: forbidden imports,
|
|
27
|
+
* named imports outside the declared rules, server-only Page options, and the top-level code the
|
|
28
|
+
* browser module does not need that only removed code used or that uses a removed import.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Every edit is planned on the one parse of `source`, so error positions point into it. Throws
|
|
32
|
+
* when code the browser module needs still references a binding whose import is removed.
|
|
33
|
+
*
|
|
34
|
+
* @param requestedExports - The exports this module's importers use; `undefined` keeps every export.
|
|
35
|
+
* @param parsed - The parse of `source`, when the caller already has it.
|
|
49
36
|
*/
|
|
50
|
-
export function transformModuleImports(source, filename, globallyAllowed, requestedExports,
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
export function transformModuleImports(source, filename, globallyAllowed, requestedExports, preserveUnreachableSideEffectImports = false, parsed) {
|
|
38
|
+
let program = parsed;
|
|
39
|
+
if (!program) {
|
|
40
|
+
try {
|
|
41
|
+
program = parseModuleSource(filename, source).program;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return { transformed: source, modified: false };
|
|
45
|
+
}
|
|
57
46
|
}
|
|
58
|
-
const { program } = result;
|
|
59
47
|
const localDeclared = collectLocalDeclaredModules(program);
|
|
60
48
|
const locallyAllowed = parseDeclaredModules(localDeclared);
|
|
61
49
|
const allowedMap = mergeDeclaredModulesMap(globallyAllowed, locallyAllowed);
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
50
|
+
const reachability = analyzeReachability(source, filename, program, requestedExports);
|
|
51
|
+
const strippedBindings = new Map();
|
|
52
|
+
const editedImports = new Set();
|
|
53
|
+
const importEdits = collectImportTransformEdits(program, {
|
|
66
54
|
filename,
|
|
67
55
|
reachability,
|
|
68
56
|
allowedMap,
|
|
69
57
|
preserveUnreachableSideEffectImports,
|
|
58
|
+
strippedBindings,
|
|
59
|
+
editedImports,
|
|
60
|
+
});
|
|
61
|
+
const pageCode = collectServerOnlyPageCode(program);
|
|
62
|
+
const cleanupEdits = planStrippedImportCleanup({
|
|
63
|
+
program,
|
|
64
|
+
source,
|
|
65
|
+
filename,
|
|
66
|
+
strippedNodes: pageCode.strippedNodes,
|
|
67
|
+
strippedBindings,
|
|
68
|
+
editedImports,
|
|
69
|
+
requestedExports,
|
|
70
70
|
});
|
|
71
|
+
const edits = [...importEdits, ...pageCode.edits, ...cleanupEdits];
|
|
71
72
|
if (edits.length === 0) {
|
|
72
|
-
return
|
|
73
|
-
? stripServerOnlyEcoPageOptions(source, program)
|
|
74
|
-
: { transformed: source, modified: false };
|
|
75
|
-
}
|
|
76
|
-
const transformed = applySourceEdits(source, edits);
|
|
77
|
-
let reparsedResult;
|
|
78
|
-
try {
|
|
79
|
-
reparsedResult = parseModuleSource(filename, transformed);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return { transformed, modified: true };
|
|
83
|
-
}
|
|
84
|
-
const strippedPageOptions = stripServerOnlyPageOptions
|
|
85
|
-
? stripServerOnlyEcoPageOptions(transformed, reparsedResult.program)
|
|
86
|
-
: { transformed, modified: false };
|
|
87
|
-
if (strippedPageOptions.modified) {
|
|
88
|
-
return strippedPageOptions;
|
|
73
|
+
return { transformed: source, modified: false };
|
|
89
74
|
}
|
|
90
|
-
return { transformed, modified: true };
|
|
75
|
+
return { transformed: applySourceEdits(source, edits), modified: true };
|
|
91
76
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inlines `fs.readFileSync(path.resolve(...), 'utf8')` calls when the target file exists.
|
|
3
|
+
*
|
|
4
|
+
* @returns The rewritten source, whether it changed, and the files it inlined.
|
|
3
5
|
*/
|
|
4
6
|
export declare function inlineReadFileSyncCalls(source: string, sourcePath: string, absWorkingDir: string): {
|
|
5
7
|
transformed: string;
|
|
6
8
|
modified: boolean;
|
|
9
|
+
inlinedFiles: string[];
|
|
7
10
|
};
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import { fileSystem } from '@ecopages/file-system';
|
|
2
|
-
import {
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
const READ_FILE_SYNC_PATTERN = /\bfs\.readFileSync\s*\(\s*path\.resolve\s*\(\s*(['"`])([^'"`\n]+)\1\s*\)\s*,\s*['"`]utf-?8['"`]\s*\)/g;
|
|
4
4
|
function inferProjectRootFromSourcePath(filePath) {
|
|
5
|
-
const parts = filePath.split(/
|
|
5
|
+
const parts = filePath.split('/');
|
|
6
6
|
const srcIndex = parts.lastIndexOf('src');
|
|
7
7
|
if (srcIndex <= 0)
|
|
8
8
|
return undefined;
|
|
9
|
-
return parts.slice(0, srcIndex).join(
|
|
9
|
+
return parts.slice(0, srcIndex).join('/');
|
|
10
10
|
}
|
|
11
11
|
function resolveReadFileCandidate(relPath, sourcePath, absWorkingDir) {
|
|
12
|
-
const sourceDir = dirname(sourcePath);
|
|
12
|
+
const sourceDir = path.dirname(sourcePath);
|
|
13
13
|
const inferredProjectRoot = inferProjectRootFromSourcePath(sourcePath);
|
|
14
14
|
const candidates = [
|
|
15
|
-
resolve(absWorkingDir, relPath),
|
|
16
|
-
resolve(
|
|
17
|
-
resolve(sourceDir, relPath),
|
|
18
|
-
...(inferredProjectRoot ? [resolve(inferredProjectRoot, relPath)] : []),
|
|
15
|
+
path.resolve(absWorkingDir, relPath),
|
|
16
|
+
path.resolve(path.cwd(), relPath),
|
|
17
|
+
path.resolve(sourceDir, relPath),
|
|
18
|
+
...(inferredProjectRoot ? [path.resolve(inferredProjectRoot, relPath)] : []),
|
|
19
19
|
];
|
|
20
20
|
return candidates.find((candidate) => fileSystem.exists(candidate));
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Inlines `fs.readFileSync(path.resolve(...), 'utf8')` calls when the target file exists.
|
|
24
|
+
*
|
|
25
|
+
* @returns The rewritten source, whether it changed, and the files it inlined.
|
|
24
26
|
*/
|
|
25
27
|
export function inlineReadFileSyncCalls(source, sourcePath, absWorkingDir) {
|
|
28
|
+
const inlinedFiles = [];
|
|
26
29
|
if (!source.includes('readFileSync')) {
|
|
27
|
-
return { transformed: source, modified: false };
|
|
30
|
+
return { transformed: source, modified: false, inlinedFiles };
|
|
28
31
|
}
|
|
29
32
|
let modified = false;
|
|
30
33
|
const transformed = source.replace(READ_FILE_SYNC_PATTERN, (_match, _q, relPath) => {
|
|
@@ -33,11 +36,12 @@ export function inlineReadFileSyncCalls(source, sourcePath, absWorkingDir) {
|
|
|
33
36
|
const absolutePath = resolveReadFileCandidate(relPath, sourcePath, absWorkingDir);
|
|
34
37
|
if (!absolutePath)
|
|
35
38
|
return '""';
|
|
39
|
+
inlinedFiles.push(absolutePath);
|
|
36
40
|
return JSON.stringify(fileSystem.readFileSync(absolutePath));
|
|
37
41
|
}
|
|
38
42
|
catch {
|
|
39
43
|
return '""';
|
|
40
44
|
}
|
|
41
45
|
});
|
|
42
|
-
return { transformed, modified };
|
|
46
|
+
return { transformed, modified, inlinedFiles };
|
|
43
47
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { EcoBuildOnLoadResult } from '@ecopages/core/integration';
|
|
2
2
|
import type { ClientGraphModuleKind } from './module-classification.js';
|
|
3
3
|
import type { RequestedExportRules } from './specifier-classification.js';
|
|
4
|
+
import type { PlannedModule } from './requested-exports-plan.js';
|
|
4
5
|
export type TransformClientGraphModuleOptions = {
|
|
5
6
|
filePath: string;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/** The module after read-file inlining, with its parse when the caller has one. */
|
|
8
|
+
module: PlannedModule;
|
|
8
9
|
category: ClientGraphModuleKind;
|
|
9
10
|
globallyDeclaredSources: Map<string, Set<string> | '*'>;
|
|
10
|
-
requestedExports:
|
|
11
|
+
requestedExports: RequestedExportRules | undefined;
|
|
11
12
|
preserveUnreachableSideEffectImports?: boolean;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
|
-
* Applies
|
|
15
|
+
* Applies import transforms to one client-graph module whose read-file calls are already inlined.
|
|
15
16
|
*/
|
|
16
17
|
export declare function transformClientGraphModule(options: TransformClientGraphModuleOptions): EcoBuildOnLoadResult | undefined;
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { recordModuleTransformProfile } from '@ecopages/core/build';
|
|
3
|
-
import { inlineReadFileSyncCalls } from './boundary-plugin-read-file-inline.js';
|
|
4
3
|
import { transformModuleImports } from './ast-transform.js';
|
|
5
4
|
import { isPageOrLayoutEntry } from './module-classification.js';
|
|
6
5
|
function toLoaderResult(filePath, contents) {
|
|
7
|
-
const ext = extname(filePath).slice(1);
|
|
6
|
+
const ext = path.extname(filePath).slice(1);
|
|
8
7
|
return { contents, loader: ext };
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
|
-
* Applies
|
|
10
|
+
* Applies import transforms to one client-graph module whose read-file calls are already inlined.
|
|
12
11
|
*/
|
|
13
12
|
export function transformClientGraphModule(options) {
|
|
14
|
-
const
|
|
15
|
-
let transformed = readFileInlining.transformed;
|
|
16
|
-
let modified = readFileInlining.modified;
|
|
13
|
+
const { module } = options;
|
|
17
14
|
const analysisStartedAt = performance.now();
|
|
18
|
-
const { transformed
|
|
15
|
+
const { transformed, modified } = transformModuleImports(module.source, options.filePath, options.globallyDeclaredSources, options.requestedExports, Boolean(options.preserveUnreachableSideEffectImports) && !isPageOrLayoutEntry(options.filePath), module.program);
|
|
19
16
|
recordModuleTransformProfile({
|
|
20
17
|
category: options.category,
|
|
21
18
|
phase: 'analysis',
|
|
22
19
|
ms: performance.now() - analysisStartedAt,
|
|
23
20
|
});
|
|
24
|
-
if (
|
|
25
|
-
modified = true;
|
|
26
|
-
transformed = oxcTransformed;
|
|
27
|
-
}
|
|
28
|
-
if (!modified)
|
|
21
|
+
if (!modified && !module.inlined)
|
|
29
22
|
return undefined;
|
|
30
23
|
return toLoaderResult(options.filePath, transformed);
|
|
31
24
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Build plugin securing the Ecopages isomorphic compilation pipeline.
|
|
5
5
|
*/
|
|
6
|
-
import type { EcoBuildPlugin } from '@ecopages/core/integration';
|
|
6
|
+
import type { EcoBuildPlugin, EcoBuildPluginBuilder } from '@ecopages/core/integration';
|
|
7
7
|
/**
|
|
8
8
|
* Configuration options for the Client Graph Boundary build plugin.
|
|
9
9
|
*/
|
|
@@ -16,8 +16,54 @@ type ClientGraphBoundaryOptions = {
|
|
|
16
16
|
declaredModules?: readonly string[];
|
|
17
17
|
alwaysAllowSpecifiers?: string[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Scope for React's foreign-JSX override: a file another JSX Integration owns gets React's JSX runtime only when
|
|
21
|
+
* a React entry file reaches it.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Reach comes from a static import scan of the build's entry files before any module loads, so it does not
|
|
25
|
+
* depend on load order. A foreign file only another Integration's entry reaches keeps its owner's runtime. One
|
|
26
|
+
* that both reach fails the build, since it has one URL and so one compiled form. A build without boundary
|
|
27
|
+
* plugins, and a file the scan does not find, keep the override, as in a React-only build.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createForeignJsxScope(options: {
|
|
30
|
+
projectRoot: string;
|
|
31
|
+
hostIntegrationName: string;
|
|
32
|
+
/** Name of the other JSX Integration that owns `filePath`; `undefined` when the file is not foreign. */
|
|
33
|
+
findForeignOwner: (filePath: string) => string | undefined;
|
|
34
|
+
}): (build: EcoBuildPluginBuilder) => (sourcePath: string) => boolean;
|
|
19
35
|
/**
|
|
20
36
|
* Instantiates the client graph boundary build plugin.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* In a build shared with other Integrations it decides by file, never by the entry that reached a module: it
|
|
40
|
+
* leaves an entry file no boundary instance declares to its own Integration and transforms every other source
|
|
41
|
+
* module the same way, since a module has one URL and so one compiled form. The instances of one build share
|
|
42
|
+
* their options through the build's `entrypoints`, and only the first registers a handler, so each module is
|
|
43
|
+
* read and analysed once whatever the number of React entries.
|
|
44
|
+
*
|
|
45
|
+
* A boundary without entry options, or in a build without `entrypoints`, works alone and starts its plan
|
|
46
|
+
* from the build's entries, or from its own entry files.
|
|
21
47
|
*/
|
|
22
48
|
export declare function createClientGraphBoundaryPlugin(options?: ClientGraphBoundaryOptions): EcoBuildPlugin;
|
|
49
|
+
/**
|
|
50
|
+
* Instantiates the build plugin that gives React modules the boundary of every Eco Component another Integration
|
|
51
|
+
* owns, in the production bundle and the development transform alike.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* It rewrites the imports of foreign-owned Components in a module's source after it loads, so MDX, which
|
|
55
|
+
* compiles to such imports, is covered too. A module that imports none is left untouched.
|
|
56
|
+
*
|
|
57
|
+
* A module has one compiled form per id, so a module that another entry also reaches and that imports a foreign
|
|
58
|
+
* Component gets two: React's graph imports it under the id `<path>?eco-variant=react-boundary`, which this plugin
|
|
59
|
+
* rewrites, and the other graph keeps the plain id, which it leaves alone. The variant's own imports follow the
|
|
60
|
+
* same rule. In a build without entries to compare, `isSharedFile` says which modules another graph uses.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createForeignBoundaryPlugin(options: {
|
|
63
|
+
projectRoot: string;
|
|
64
|
+
/** Whether `filePath` belongs to an Integration other than React. */
|
|
65
|
+
isForeignFile: (filePath: string) => boolean;
|
|
66
|
+
/** Whether another module graph uses `filePath`, in a build whose entries cannot say. */
|
|
67
|
+
isSharedFile?: (filePath: string) => boolean;
|
|
68
|
+
}): EcoBuildPlugin;
|
|
23
69
|
export {};
|