@ecopages/react 0.2.0-alpha.9 → 0.2.1-beta.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.
- package/README.md +30 -13
- package/package.json +23 -12
- package/src/eco-embed.d.ts +11 -0
- package/src/eco-embed.js +11 -0
- package/src/react-hmr-strategy.d.ts +102 -18
- package/src/react-hmr-strategy.js +427 -50
- package/src/react-renderer.d.ts +100 -92
- package/src/react-renderer.js +356 -340
- package/src/react.constants.d.ts +1 -0
- package/src/react.constants.js +4 -0
- package/src/react.plugin.d.ts +25 -107
- package/src/react.plugin.js +109 -61
- package/src/react.types.d.ts +88 -0
- package/src/react.types.js +0 -0
- package/src/router-adapter.d.ts +7 -14
- package/src/runtime/use-sync-external-store-with-selector.d.ts +3 -0
- package/src/runtime/use-sync-external-store-with-selector.js +56 -0
- package/src/services/pages-index.d.ts +64 -0
- package/src/services/pages-index.js +73 -0
- package/src/services/react-bundle.service.d.ts +24 -9
- package/src/services/react-bundle.service.js +35 -24
- package/src/services/react-hmr-page-metadata-cache.d.ts +10 -1
- package/src/services/react-hmr-page-metadata-cache.js +18 -2
- package/src/services/react-hydration-asset.service.d.ts +28 -19
- package/src/services/react-hydration-asset.service.js +83 -64
- package/src/services/react-mdx-config-dependency.service.d.ts +36 -0
- package/src/services/react-mdx-config-dependency.service.js +122 -0
- package/src/services/react-page-module.service.d.ts +8 -3
- package/src/services/react-page-module.service.js +33 -26
- package/src/services/react-page-payload.service.d.ts +46 -0
- package/src/services/react-page-payload.service.js +67 -0
- package/src/services/react-runtime-bundle.service.d.ts +9 -2
- package/src/services/react-runtime-bundle.service.js +77 -16
- package/src/utils/client-graph-boundary-cache.d.ts +108 -0
- package/src/utils/client-graph-boundary-cache.js +116 -0
- package/src/utils/client-graph-boundary-plugin.d.ts +13 -5
- package/src/utils/client-graph-boundary-plugin.js +63 -5
- package/src/utils/component-config-traversal.d.ts +36 -0
- package/src/utils/component-config-traversal.js +54 -0
- package/src/utils/declared-modules.d.ts +1 -1
- package/src/utils/declared-modules.js +7 -16
- package/src/utils/dynamic.test.browser.d.ts +1 -0
- package/src/utils/dynamic.test.browser.js +33 -0
- package/src/utils/hydration-scripts.d.ts +9 -5
- package/src/utils/hydration-scripts.js +119 -34
- package/src/utils/hydration-scripts.test.browser.d.ts +1 -0
- package/src/utils/hydration-scripts.test.browser.js +198 -0
- package/src/utils/react-dom-runtime-interop-plugin.d.ts +1 -1
- package/src/utils/react-dom-runtime-interop-plugin.js +9 -0
- package/src/utils/react-mdx-loader-plugin.d.ts +1 -1
- package/src/utils/{react-runtime-specifier-map.d.ts → react-runtime-alias-map.d.ts} +3 -1
- package/src/utils/react-runtime-alias-map.js +90 -0
- package/CHANGELOG.md +0 -27
- package/src/react-hmr-strategy.ts +0 -386
- package/src/react-renderer.ts +0 -803
- package/src/react.plugin.ts +0 -276
- package/src/router-adapter.ts +0 -95
- package/src/services/react-bundle.service.ts +0 -108
- package/src/services/react-hmr-page-metadata-cache.ts +0 -24
- package/src/services/react-hydration-asset.service.ts +0 -263
- package/src/services/react-page-module.service.ts +0 -224
- package/src/services/react-runtime-bundle.service.ts +0 -172
- package/src/utils/client-graph-boundary-plugin.ts +0 -831
- package/src/utils/client-only.ts +0 -27
- package/src/utils/declared-modules.ts +0 -99
- package/src/utils/dynamic.ts +0 -27
- package/src/utils/hmr-scripts.ts +0 -47
- package/src/utils/html-boundary.ts +0 -66
- package/src/utils/hydration-scripts.ts +0 -459
- package/src/utils/reachability-analyzer.ts +0 -593
- package/src/utils/react-dom-runtime-interop-plugin.ts +0 -33
- package/src/utils/react-mdx-loader-plugin.ts +0 -63
- package/src/utils/react-runtime-specifier-map.js +0 -37
- package/src/utils/react-runtime-specifier-map.ts +0 -45
- package/src/utils/use-sync-external-store-shim-plugin.d.ts +0 -5
- package/src/utils/use-sync-external-store-shim-plugin.js +0 -41
- package/src/utils/use-sync-external-store-shim-plugin.ts +0 -45
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const REACT_RUNTIME_SPECIFIERS = [
|
|
2
|
-
"react",
|
|
3
|
-
"react-dom",
|
|
4
|
-
"react/jsx-runtime",
|
|
5
|
-
"react/jsx-dev-runtime",
|
|
6
|
-
"react-dom/client"
|
|
7
|
-
];
|
|
8
|
-
function buildReactRuntimeSpecifierMap(runtimeImports, routerAdapter) {
|
|
9
|
-
const map = {
|
|
10
|
-
react: runtimeImports.react,
|
|
11
|
-
"react/jsx-runtime": runtimeImports.reactJsxRuntime,
|
|
12
|
-
"react/jsx-dev-runtime": runtimeImports.reactJsxDevRuntime,
|
|
13
|
-
"react-dom": runtimeImports.reactDom,
|
|
14
|
-
"react-dom/client": runtimeImports.reactDomClient
|
|
15
|
-
};
|
|
16
|
-
if (routerAdapter && runtimeImports.router) {
|
|
17
|
-
map[routerAdapter.importMapKey] = runtimeImports.router;
|
|
18
|
-
}
|
|
19
|
-
return map;
|
|
20
|
-
}
|
|
21
|
-
function getReactRuntimeExternalSpecifiers() {
|
|
22
|
-
return [...REACT_RUNTIME_SPECIFIERS];
|
|
23
|
-
}
|
|
24
|
-
function getReactClientGraphAllowSpecifiers(runtimeSpecifiers, routerAdapter) {
|
|
25
|
-
return [
|
|
26
|
-
"@ecopages/core",
|
|
27
|
-
...REACT_RUNTIME_SPECIFIERS,
|
|
28
|
-
...routerAdapter ? [routerAdapter.importMapKey] : [],
|
|
29
|
-
...Array.from(runtimeSpecifiers)
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
REACT_RUNTIME_SPECIFIERS,
|
|
34
|
-
buildReactRuntimeSpecifierMap,
|
|
35
|
-
getReactClientGraphAllowSpecifiers,
|
|
36
|
-
getReactRuntimeExternalSpecifiers
|
|
37
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ReactRouterAdapter } from '../router-adapter.ts';
|
|
2
|
-
import type { ReactRuntimeImports } from '../services/react-runtime-bundle.service.ts';
|
|
3
|
-
|
|
4
|
-
export const REACT_RUNTIME_SPECIFIERS = [
|
|
5
|
-
'react',
|
|
6
|
-
'react-dom',
|
|
7
|
-
'react/jsx-runtime',
|
|
8
|
-
'react/jsx-dev-runtime',
|
|
9
|
-
'react-dom/client',
|
|
10
|
-
] as const;
|
|
11
|
-
|
|
12
|
-
export function buildReactRuntimeSpecifierMap(
|
|
13
|
-
runtimeImports: ReactRuntimeImports,
|
|
14
|
-
routerAdapter?: ReactRouterAdapter,
|
|
15
|
-
): Record<string, string> {
|
|
16
|
-
const map: Record<string, string> = {
|
|
17
|
-
react: runtimeImports.react,
|
|
18
|
-
'react/jsx-runtime': runtimeImports.reactJsxRuntime,
|
|
19
|
-
'react/jsx-dev-runtime': runtimeImports.reactJsxDevRuntime,
|
|
20
|
-
'react-dom': runtimeImports.reactDom,
|
|
21
|
-
'react-dom/client': runtimeImports.reactDomClient,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
if (routerAdapter && runtimeImports.router) {
|
|
25
|
-
map[routerAdapter.importMapKey] = runtimeImports.router;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return map;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getReactRuntimeExternalSpecifiers(): string[] {
|
|
32
|
-
return [...REACT_RUNTIME_SPECIFIERS];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function getReactClientGraphAllowSpecifiers(
|
|
36
|
-
runtimeSpecifiers: Iterable<string>,
|
|
37
|
-
routerAdapter?: ReactRouterAdapter,
|
|
38
|
-
): string[] {
|
|
39
|
-
return [
|
|
40
|
-
'@ecopages/core',
|
|
41
|
-
...REACT_RUNTIME_SPECIFIERS,
|
|
42
|
-
...(routerAdapter ? [routerAdapter.importMapKey] : []),
|
|
43
|
-
...Array.from(runtimeSpecifiers),
|
|
44
|
-
];
|
|
45
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
function createUseSyncExternalStoreShimPlugin(options) {
|
|
2
|
-
const namespace = options?.namespace ?? "ecopages-react-use-sync-external-store-shim";
|
|
3
|
-
return {
|
|
4
|
-
name: options?.name ?? "react-use-sync-external-store-shim",
|
|
5
|
-
setup(build) {
|
|
6
|
-
build.onResolve({ filter: /^use-sync-external-store\/shim(?:\/index\.js)?$/ }, () => ({
|
|
7
|
-
path: "use-sync-external-store/shim",
|
|
8
|
-
namespace
|
|
9
|
-
}));
|
|
10
|
-
build.onLoad({ filter: /^use-sync-external-store\/shim$/, namespace }, () => ({
|
|
11
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
12
|
-
loader: "js"
|
|
13
|
-
}));
|
|
14
|
-
build.onLoad({ filter: /[\\/]use-sync-external-store[\\/]shim[\\/]index\.js$/ }, () => ({
|
|
15
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
16
|
-
loader: "js"
|
|
17
|
-
}));
|
|
18
|
-
build.onLoad(
|
|
19
|
-
{
|
|
20
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.development\.js$/
|
|
21
|
-
},
|
|
22
|
-
() => ({
|
|
23
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
24
|
-
loader: "js"
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
build.onLoad(
|
|
28
|
-
{
|
|
29
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.production\.js$/
|
|
30
|
-
},
|
|
31
|
-
() => ({
|
|
32
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
33
|
-
loader: "js"
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
createUseSyncExternalStoreShimPlugin
|
|
41
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from '@ecopages/core/build/build-types';
|
|
2
|
-
|
|
3
|
-
export function createUseSyncExternalStoreShimPlugin(options?: { name?: string; namespace?: string }): EcoBuildPlugin {
|
|
4
|
-
const namespace = options?.namespace ?? 'ecopages-react-use-sync-external-store-shim';
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
name: options?.name ?? 'react-use-sync-external-store-shim',
|
|
8
|
-
setup(build) {
|
|
9
|
-
build.onResolve({ filter: /^use-sync-external-store\/shim(?:\/index\.js)?$/ }, () => ({
|
|
10
|
-
path: 'use-sync-external-store/shim',
|
|
11
|
-
namespace,
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
build.onLoad({ filter: /^use-sync-external-store\/shim$/, namespace }, () => ({
|
|
15
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
16
|
-
loader: 'js',
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
build.onLoad({ filter: /[\\/]use-sync-external-store[\\/]shim[\\/]index\.js$/ }, () => ({
|
|
20
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
21
|
-
loader: 'js',
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
build.onLoad(
|
|
25
|
-
{
|
|
26
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.development\.js$/,
|
|
27
|
-
},
|
|
28
|
-
() => ({
|
|
29
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
30
|
-
loader: 'js',
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
build.onLoad(
|
|
35
|
-
{
|
|
36
|
-
filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.production\.js$/,
|
|
37
|
-
},
|
|
38
|
-
() => ({
|
|
39
|
-
contents: "export { useSyncExternalStore } from 'react';",
|
|
40
|
-
loader: 'js',
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|