Skip to content

Commit

Permalink
Merge branch 'release/next' into feat/dynamic-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Oct 30, 2024
2 parents b03194e + 9e7615b commit 8bc00a2
Show file tree
Hide file tree
Showing 25 changed files with 271 additions and 102 deletions.
1 change: 1 addition & 0 deletions examples/with-suspense-ssr/src/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function Document() {
</head>
<body>
<Main />
<script dangerouslySetInnerHTML={{ __html: 'window.addEventListener(\'suspense\', (d) => console.log(\'suspence event=\', d))' }} />
<Scripts async />
</body>
</html>
Expand Down
6 changes: 6 additions & 0 deletions packages/bundles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.2.7

### Patch Changes

- 0b4e0ccd: fix: support more platforms

## 0.2.6

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/bundles",
"version": "0.2.6",
"version": "0.2.7",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand Down Expand Up @@ -33,7 +33,7 @@
"react-refresh": "0.14.0",
"core-js-pure": "^3.8.1",
"error-stack-parser": "^2.0.6",
"@ice/css-modules-hash": "0.0.8",
"@ice/css-modules-hash": "0.0.10",
"browserslist": "^4.21.3",
"compare-versions": "6.0.0-rc.1",
"enhanced-resolve": "5.12.0",
Expand All @@ -45,7 +45,7 @@
"zod": "^3.22.3",
"zod-validation-error": "1.2.0",
"terminal-link": "^2.1.1",
"@ice/pack-binding": "0.0.12",
"@ice/pack-binding": "0.0.13",
"mime-types": "2.1.35"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 3.4.12

### Patch Changes

- Updated dependencies [a4755e43]
- Updated dependencies [f50fe55d]
- Updated dependencies [b0eb09d5]
- Updated dependencies [31706030]
- Updated dependencies [0b4e0ccd]
- @ice/runtime@1.4.13
- @ice/webpack-config@1.1.16
- @ice/shared-config@1.2.9
- @ice/bundles@0.2.7
- @ice/rspack-config@1.1.10

## 3.4.11

### Patch Changes
Expand Down
14 changes: 7 additions & 7 deletions packages/ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.4.11",
"version": "3.4.12",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand Down Expand Up @@ -47,12 +47,12 @@
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
"dependencies": {
"@ice/bundles": "0.2.6",
"@ice/bundles": "0.2.7",
"@ice/route-manifest": "1.2.2",
"@ice/runtime": "^1.4.10",
"@ice/shared-config": "1.2.8",
"@ice/webpack-config": "1.1.15",
"@ice/rspack-config": "1.1.9",
"@ice/runtime": "^1.4.13",
"@ice/shared-config": "1.2.9",
"@ice/webpack-config": "1.1.16",
"@ice/rspack-config": "1.1.10",
"@swc/helpers": "0.5.1",
"@types/express": "^4.17.14",
"address": "^1.1.2",
Expand All @@ -72,7 +72,7 @@
"mlly": "^1.1.0",
"mrmime": "^1.0.0",
"open": "^8.4.0",
"path-to-regexp": "^6.2.0",
"path-to-regexp": "^6.3.0",
"regenerator-runtime": "^0.13.0",
"resolve.exports": "^1.1.0",
"semver": "^7.3.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"webpack-dev-server": "4.15.0"
},
"peerDependencies": {
"@ice/app": "^3.4.11",
"@ice/runtime": "^1.4.11"
"@ice/app": "^3.4.12",
"@ice/runtime": "^1.4.13"
},
"publishConfig": {
"access": "public"
Expand Down
8 changes: 7 additions & 1 deletion packages/plugin-stream-error/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@

### Patch Change

- feat: plugin export head stream error recover component
- 2928447c: plugin export head stream error recover component

## 1.0.2

### Patch Change

- 069579a3: add head stream error types exports
9 changes: 8 additions & 1 deletion packages/plugin-stream-error/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/plugin-stream-error",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"license": "MIT",
"type": "module",
Expand All @@ -12,6 +12,13 @@
},
"./head-stream-error": "./esm/components/headStreamErrorRecoverScript.js"
},
"typesVersions": {
"*": {
"head-stream-error": [
"./esm/components/headStreamErrorRecoverScript.d.ts"
]
}
},
"main": "./esm/index.js",
"types": "./esm/index.d.ts",
"files": [
Expand Down
9 changes: 9 additions & 0 deletions packages/rspack-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @ice/rspack-config

## 1.1.10

### Patch Changes

- Updated dependencies [b0eb09d5]
- Updated dependencies [0b4e0ccd]
- @ice/shared-config@1.2.9
- @ice/bundles@0.2.7

## 1.1.9

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/rspack-config",
"version": "1.1.9",
"version": "1.1.10",
"repository": "alibaba/ice",
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
Expand All @@ -15,8 +15,8 @@
"*.d.ts"
],
"dependencies": {
"@ice/bundles": "0.2.6",
"@ice/shared-config": "1.2.8"
"@ice/bundles": "0.2.7",
"@ice/shared-config": "1.2.9"
},
"devDependencies": {
"@rspack/core": "0.5.7"
Expand Down
15 changes: 15 additions & 0 deletions packages/runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @ice/runtime

## 1.4.13

### Patch Changes

- a4755e43: feat: support onShellReady options
- f50fe55d: revert: revert suspence event
- 31706030: fix: avoid infinite setOutlets loop when config keepAlivePaths

## 1.4.12

### Patch Changes

- c5b43d5e: feat: support getAssets for onShellReady
- 9c3d9c58: feat: support suspense event

## 1.4.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/runtime",
"version": "1.4.11",
"version": "1.4.13",
"description": "Runtime module for ice.js",
"type": "module",
"types": "./esm/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/src/KeepAliveOutlet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ export default function KeepAliveOutlet(props: OutletProps) {
if (outlets.length !== 0 ||
outletRef.current?.pathname !== location.pathname) {
let currentOutlets = outletRef.current ? [outletRef.current] : outlets;
// Check current path if exsist before filter, to avoid infinite setOutlets loop.
const result = currentOutlets.some(o => o.pathname === location.pathname);
if (keepAlivePaths && keepAlivePaths.length > 0) {
currentOutlets = currentOutlets.filter(o => keepAlivePaths.includes(o.pathname));
}
const result = currentOutlets.some(o => o.pathname === location.pathname);
if (!result) {
setOutlets([
...currentOutlets,
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime/src/runClientApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export default async function runClientApp(options: RunClientAppOptions) {
reportRecoverableError(error, errorInfo, { ignoreRuntimeWarning: revalidate });
}),
};
if (appConfig?.app?.onBeforeHydrate) {
appConfig?.app?.onBeforeHydrate();
}
return ReactDOM.hydrateRoot(container, element, hydrateOptions);
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/runServerApp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import type { Location } from 'history';
import type { OnAllReadyParams } from './server/streamRender.js';
import type { OnAllReadyParams, OnShellReadyParams } from './server/streamRender.js';
import type {
AppContext,
ServerContext,
Expand Down Expand Up @@ -86,8 +86,8 @@ export async function renderToResponse(requestContext: ServerContext, renderOpti
return new Promise<void>((resolve, reject) => {
// Send stream result to ServerResponse.
pipe(res, {
onShellReady: () => {
onShellReady && onShellReady();
onShellReady: (params: OnShellReadyParams) => {
onShellReady && onShellReady(params);
},
onShellError: async (err) => {
onShellError && onShellError(err);
Expand Down
26 changes: 24 additions & 2 deletions packages/runtime/src/server/streamRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export interface OnAllReadyParams {
renderAssets: string[];
}
export type OnAllReady = (OnAllReadyParams) => void;
export interface OnShellReadyParams {
renderAssets: string[];
}
export type OnShellReady = (OnShellReadyParams) => void;
export interface RenderToPipeableStreamOptions {
onShellReady?: () => void;
onShellReady?: OnShellReady;
onShellError?: (error: unknown) => void;
onAllReady?: OnAllReady;
onError?: (error: unknown) => void;
Expand All @@ -36,6 +40,7 @@ export function renderToNodeStream(
} = renderToNodeStreamOptions;
const {
preRender = false,
getAssets = false,
} = renderOptions;

const { pipe } = ReactDOMServer.renderToPipeableStream(element, {
Expand All @@ -44,7 +49,24 @@ export function renderToNodeStream(
if (!preRender) {
pipe(res);
}
options?.onShellReady && options.onShellReady();

const {
renderOptions,
routerContext,
} = renderToNodeStreamOptions;

const {
assetsManifest,
} = renderOptions;

const {
matches,
loaderData,
} = routerContext;

options?.onShellReady && options.onShellReady({
renderAssets: getAssets ? getAllAssets(loaderData, matches, assetsManifest) : [],
});
},
onShellError(error) {
options?.onShellError && options?.onShellError(error);
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type App = Partial<{
strict: boolean;
errorBoundary: boolean;
onRecoverableError: (error: unknown, errorInfo: ErrorStack) => void;
onBeforeHydrate: () => void;
} & Record<AppLifecycle, VoidFunction>>;

export interface ErrorStack {
Expand Down Expand Up @@ -323,6 +324,7 @@ export interface RenderOptions {
Document?: DocumentComponent;
documentOnly?: boolean;
preRender?: boolean;
getAssets?: boolean;
renderMode?: RenderMode;
// basename is used both for server and client, once set, it will be sync to client.
basename?: string;
Expand Down
8 changes: 8 additions & 0 deletions packages/shared-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ice/shared-config

## 1.2.9

### Patch Changes

- b0eb09d5: fix: mark browserslist config to cache key
- Updated dependencies [0b4e0ccd]
- @ice/bundles@0.2.7

## 1.2.8

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/shared-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/shared-config",
"version": "1.2.8",
"version": "1.2.9",
"repository": "alibaba/ice",
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
Expand All @@ -17,7 +17,7 @@
"*.d.ts"
],
"dependencies": {
"@ice/bundles": "0.2.6",
"@ice/bundles": "0.2.7",
"@rollup/pluginutils": "^4.2.0",
"browserslist": "^4.22.1",
"consola": "^2.15.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/shared-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import compilationPlugin, { isSupportedFeature, getJsxTransformOptions } from './unPlugins/compilation.js';
import compilationPlugin, { isSupportedFeature, getJsxTransformOptions, getSupportedBrowsers } from './unPlugins/compilation.js';
import compileExcludes, { SKIP_COMPILE as skipCompilePackages } from './compileExcludes.js';
import getCompilerPlugins from './getCompilerPlugins.js';
import getDefineVars from './getDefineVars.js';
Expand All @@ -19,4 +19,5 @@ export {
getPostcssOpts,
getAliasWithRoot,
getDevtoolValue,
getSupportedBrowsers,
};
4 changes: 2 additions & 2 deletions packages/shared-config/src/unPlugins/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ export function getJsxTransformOptions({
return commonOptions;
}

function getSupportedBrowsers(
export function getSupportedBrowsers(
dir: string,
isDevelopment: boolean,
): string[] | undefined {
let browsers: any;
let browsers: string[];
try {
browsers = browserslist.loadConfig({
path: dir,
Expand Down
10 changes: 10 additions & 0 deletions packages/webpack-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.1.16

### Patch Changes

- b0eb09d5: fix: mark browserslist config to cache key
- Updated dependencies [b0eb09d5]
- Updated dependencies [0b4e0ccd]
- @ice/shared-config@1.2.9
- @ice/bundles@0.2.7

## 1.1.15

### Patch Changes
Expand Down
Loading

0 comments on commit 8bc00a2

Please sign in to comment.