Skip to content

Commit

Permalink
Merge pull request #6984 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release @ice/[email protected]
  • Loading branch information
ClarkXia authored Oct 8, 2024
2 parents 2ea5138 + 3854f80 commit 189892e
Show file tree
Hide file tree
Showing 22 changed files with 245 additions and 93 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
12 changes: 6 additions & 6 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 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
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
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
1 change: 1 addition & 0 deletions packages/runtime/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,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
6 changes: 3 additions & 3 deletions packages/webpack-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/webpack-config",
"version": "1.1.15",
"version": "1.1.16",
"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/shared-config": "1.2.8",
"@ice/bundles": "0.2.6",
"@ice/shared-config": "1.2.9",
"@ice/bundles": "0.2.7",
"fast-glob": "^3.2.11",
"process": "^0.11.10"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/webpack-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path';
import { createRequire } from 'module';
import crypto from 'crypto';
import fg from 'fast-glob';
import ReactRefreshWebpackPlugin from '@ice/bundles/compiled/@pmmmwh/react-refresh-webpack-plugin/lib/index.js';
import bundleAnalyzer from '@ice/bundles/compiled/webpack-bundle-analyzer/index.js';
Expand All @@ -11,7 +12,7 @@ import ESlintPlugin from '@ice/bundles/compiled/eslint-webpack-plugin/index.js';
import CopyPlugin from '@ice/bundles/compiled/copy-webpack-plugin/index.js';
import type { NormalModule, Compiler, Configuration } from 'webpack';
import type webpack from 'webpack';
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot, getDevtoolValue } from '@ice/shared-config';
import { compilationPlugin, compileExcludes, getCompilerPlugins, getDefineVars, getAliasWithRoot, getDevtoolValue, getSupportedBrowsers } from '@ice/shared-config';
import type { Config, ModifyWebpackConfig } from '@ice/shared-config/types.js';
import configAssets from './config/assets.js';
import configCss from './config/css.js';
Expand Down Expand Up @@ -152,6 +153,8 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
module: true,
}, minimizerOptions);

const supportBrowsers = getSupportedBrowsers(rootDir, dev);
const browsersMD5 = supportBrowsers ? crypto.createHash('md5').update(supportBrowsers.join('')).digest('hex') : '';
const compilation = compilationPlugin({
rootDir,
cacheDir,
Expand Down Expand Up @@ -257,7 +260,7 @@ export function getWebpackConfig(options: GetWebpackConfigOptions): Configuratio
} as Configuration['optimization'],
cache: enableCache ? {
type: 'filesystem',
version: `${process.env.__ICE_VERSION__}|${userConfigHash}`,
version: `${process.env.__ICE_VERSION__}|${userConfigHash}|${browsersMD5}`,
buildDependencies: { config: [path.join(rootDir, 'package.json')] },
cacheDirectory: path.join(cacheDir, 'webpack'),
} : false,
Expand Down
Loading

0 comments on commit 189892e

Please sign in to comment.