Skip to content

Commit 42718fd

Browse files
authored
Merge pull request #6486 from alibaba/release/next
Release 3.3.1
2 parents d8f238a + 9dec009 commit 42718fd

File tree

37 files changed

+448
-333
lines changed

37 files changed

+448
-333
lines changed

examples/basic-project/src/document.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
import { Meta, Title, Links, Main, Scripts, useAppData } from 'ice';
1+
// eslint-disable-next-line
2+
import { Meta, Title, Links, Main, Scripts, useAppData, defineDataLoader, unstable_useDocumentData } from 'ice';
23
import type { AppData } from '@/types';
34

5+
export const dataLoader = defineDataLoader(() => {
6+
return new Promise((resolve) => {
7+
setTimeout(() => {
8+
resolve({
9+
title: 'documentData',
10+
});
11+
// ATTENTION: This async call will pause rendering document.
12+
}, 1000);
13+
});
14+
});
15+
416
function Document() {
517
const appData = useAppData<AppData>();
18+
// Get document data when fallback to document only.
19+
const documentData = unstable_useDocumentData();
20+
21+
console.log('document data', documentData);
622

723
return (
824
<html>
@@ -21,6 +37,12 @@ function Document() {
2137
</head>
2238
<body>
2339
<Main />
40+
<div>
41+
<h1>Document Data</h1>
42+
<code>
43+
<pre>{JSON.stringify(documentData, null, 2)}</pre>
44+
</code>
45+
</div>
2446
<Scripts />
2547
</body>
2648
</html>

packages/bundles/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.1.15
4+
5+
### Patch Changes
6+
7+
- 2875b544: fix: bump @swc/core version
8+
- 1fa826b0: chore: bump rspack version for more hook and plugin support
9+
310
## 0.1.14
411

512
### Patch Changes

packages/bundles/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/bundles",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"license": "MIT",
55
"author": "ICE",
66
"description": "Basic dependencies for ice.",
@@ -15,7 +15,7 @@
1515
"main": "./esm/index.js",
1616
"type": "module",
1717
"dependencies": {
18-
"@swc/core": "1.3.77",
18+
"@swc/core": "1.3.80",
1919
"@ice/swc-plugin-remove-export": "0.2.0",
2020
"@ice/swc-plugin-keep-export": "0.2.0",
2121
"@ice/swc-plugin-node-transform": "0.2.0",
@@ -33,8 +33,8 @@
3333
"react-refresh": "0.14.0",
3434
"core-js-pure": "^3.8.1",
3535
"error-stack-parser": "^2.0.6",
36-
"@rspack/core": "0.2.12",
37-
"@rspack/dev-server": "0.2.12",
36+
"@rspack/core": "0.3.0",
37+
"@rspack/dev-server": "0.3.0",
3838
"@ice/css-modules-hash": "0.0.6"
3939
},
4040
"devDependencies": {

packages/ice/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## 3.3.1
4+
5+
### Patch Changes
6+
7+
- 69e68633: feat: support API useDocumentData
8+
- 41bc1440: fix: ignore static resource when render server entry
9+
- 1fa826b0: chore: bump rspack version for more hook and plugin support
10+
- Updated dependencies [47ba84d3]
11+
- Updated dependencies [477d14cc]
12+
- Updated dependencies [2875b544]
13+
- Updated dependencies [69e68633]
14+
- Updated dependencies [e3e1f27c]
15+
- Updated dependencies [99c0dd26]
16+
- Updated dependencies [101eadea]
17+
- Updated dependencies [d4904e92]
18+
- Updated dependencies [1fa826b0]
19+
- @ice/runtime@1.2.8
20+
- @ice/bundles@0.1.15
21+
- @ice/rspack-config@1.0.2
22+
- @ice/shared-config@1.0.2
23+
- @ice/webpack-config@1.1.1
24+
325
## 3.3.0
426

527
### Minor Changes

packages/ice/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/app",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"description": "provide scripts and configuration used by web framework ice",
55
"type": "module",
66
"main": "./esm/index.js",
@@ -37,12 +37,12 @@
3737
"bugs": "https://github.com/alibaba/ice/issues",
3838
"homepage": "https://v3.ice.work",
3939
"dependencies": {
40-
"@ice/bundles": "0.1.14",
40+
"@ice/bundles": "0.1.15",
4141
"@ice/route-manifest": "1.2.1",
42-
"@ice/runtime": "^1.2.7",
43-
"@ice/shared-config": "1.0.1",
44-
"@ice/webpack-config": "1.1.0",
45-
"@ice/rspack-config": "1.0.1",
42+
"@ice/runtime": "^1.2.8",
43+
"@ice/shared-config": "1.0.2",
44+
"@ice/webpack-config": "1.1.1",
45+
"@ice/rspack-config": "1.0.2",
4646
"@swc/helpers": "0.5.1",
4747
"@types/express": "^4.17.14",
4848
"address": "^1.1.2",
@@ -88,8 +88,8 @@
8888
"unplugin": "^0.9.0",
8989
"webpack": "^5.88.0",
9090
"webpack-dev-server": "^4.7.4",
91-
"@rspack/core": "0.2.12",
92-
"@rspack/dev-server": "0.2.12"
91+
"@rspack/core": "0.3.0",
92+
"@rspack/dev-server": "0.3.0"
9393
},
9494
"peerDependencies": {
9595
"react": ">=18.0.0",

packages/ice/src/bundler/rspack/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type { MultiStats } from '@rspack/core';
12
import { logger } from '../../utils/logger.js';
23
import { getOutputPaths, removeServerOutput } from '../config/output.js';
3-
import type { BuildOptions, CompileResults, MultiStats } from '../types.js';
4+
import type { BuildOptions, CompileResults } from '../types.js';
45
import formatStats from './formatStats.js';
56

67
async function build(options: BuildOptions) {

packages/ice/src/bundler/rspack/formatStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk';
2+
import type { Stats, MultiStats } from '@rspack/core';
23
import formatWebpackMessages from '../../utils/formatWebpackMessages.js';
3-
import type { Stats, MultiStats } from '../types.js';
44

55
function formatStats(stats: Stats | MultiStats, showWarnings = true) {
66
const statsData = stats.toJson({

packages/ice/src/bundler/types.ts

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Config } from '@ice/shared-config/types';
22
import type ora from '@ice/bundles/compiled/ora/index.js';
33
import type { Stats as WebpackStats } from '@ice/bundles/compiled/webpack/index.js';
44
import type { AppConfig } from '@ice/runtime/types';
5-
import type { Configuration, MultiCompiler } from '@rspack/core';
5+
import type { Configuration, MultiCompiler, MultiStats } from '@rspack/core';
66
import type { Context as DefaultContext, TaskConfig } from 'build-scripts';
77
import type { ServerCompiler, GetAppConfig, GetRoutesConfig, GetDataloaderConfig, ExtendsPluginAPI } from '../types/plugin.js';
88
import type { UserConfig } from '../types/userConfig.js';
@@ -45,98 +45,3 @@ export type CompileResults = {
4545
isSuccessful: boolean;
4646
messages: { errors: string[]; warnings: string[] };
4747
};
48-
49-
interface StatsOptionsObj {
50-
all?: boolean;
51-
preset?: 'normal' | 'none' | 'verbose' | 'errors-only' | 'errors-warnings';
52-
assets?: boolean;
53-
chunks?: boolean;
54-
modules?: boolean;
55-
entrypoints?: boolean;
56-
warnings?: boolean;
57-
warningsCount?: boolean;
58-
errors?: boolean;
59-
errorsCount?: boolean;
60-
colors?: boolean;
61-
timings?: boolean;
62-
63-
/** Rspack not support below opts */
64-
cachedAssets?: boolean;
65-
groupAssetsByInfo?: boolean;
66-
groupAssetsByPath?: boolean;
67-
groupAssetsByChunk?: boolean;
68-
groupAssetsByExtension?: boolean;
69-
groupAssetsByEmitStatus?: boolean;
70-
}
71-
72-
/** webpack not support boolean or string */
73-
type StatsOptions = StatsOptionsObj;
74-
75-
interface StatsAssetInfo {
76-
development?: boolean;
77-
}
78-
79-
export interface StatsAsset {
80-
type: string;
81-
name: string;
82-
size: number;
83-
chunks?: Array<string | number>;
84-
chunkNames?: Array<string | number>;
85-
info: StatsAssetInfo;
86-
}
87-
88-
interface StatsError {
89-
message: string;
90-
formatted?: string;
91-
}
92-
93-
interface StatsModule {
94-
type?: string;
95-
moduleType?: string;
96-
identifier?: string;
97-
name?: string;
98-
id?: string;
99-
chunks?: Array<string>;
100-
size?: number;
101-
}
102-
103-
interface StatsCompilation {
104-
assets?: Array<StatsAsset>;
105-
modules?: Array<StatsModule>;
106-
chunks?: Array<StatsChunk>;
107-
// entrypoints?: Array<StatsEntrypoint>;
108-
errors?: Array<StatsError>;
109-
errorsCount?: number;
110-
warnings?: Array<StatsError>;
111-
warningsCount?: number;
112-
time?: number;
113-
name?: string;
114-
children?: StatsCompilation[];
115-
}
116-
117-
interface StatsChunk {
118-
type?: string;
119-
files?: Array<string>;
120-
id?: string | number;
121-
entry: boolean;
122-
initial: boolean;
123-
names?: Array<string>;
124-
size: number;
125-
}
126-
127-
export declare class Stats {
128-
constructor(statsJson: any);
129-
hasErrors(): boolean;
130-
hasWarnings(): boolean;
131-
toJson(opts?: StatsOptions): StatsCompilation;
132-
toString(opts?: StatsOptions): string;
133-
}
134-
135-
export declare class MultiStats {
136-
stats: Stats[];
137-
hasErrors(): boolean;
138-
hasWarnings(): boolean;
139-
toJson(options?: StatsOptions): StatsCompilation;
140-
toString(options?: StatsOptions): string;
141-
}
142-

packages/ice/src/constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const RUNTIME_EXPORTS = [
6767
'defineServerDataLoader',
6868
'defineStaticDataLoader',
6969
'usePageLifecycle',
70+
'unstable_useDocumentData',
7071
],
7172
alias: {
7273
usePublicAppContext: 'useAppContext',

packages/ice/src/middlewares/renderMiddleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export default function createRenderMiddleware(options: Options): Middleware {
3939
const matches = matchRoutes(routes, req.path, basename);
4040
const isStaticResources = /\.(js|mjs|map|json|png|jpg|jpeg|gif|svg|eot|woff2|ttf)$/;
4141
// When documentOnly is true, it means that the app is CSR and it should return the html.
42-
if (matches.length || documentOnly || !isStaticResources) {
42+
if ((matches.length || documentOnly) &&
43+
// Ignore static resources.
44+
!isStaticResources.test(req.path)) {
4345
const serverModule = await excuteServerEntry();
4446
if (serverModule) {
4547
const requestContext: ServerContext = {

0 commit comments

Comments
 (0)