Skip to content

Commit

Permalink
Merge pull request #6486 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.3.1
  • Loading branch information
ClarkXia authored Aug 31, 2023
2 parents d8f238a + 9dec009 commit 42718fd
Show file tree
Hide file tree
Showing 37 changed files with 448 additions and 333 deletions.
24 changes: 23 additions & 1 deletion examples/basic-project/src/document.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { Meta, Title, Links, Main, Scripts, useAppData } from 'ice';
// eslint-disable-next-line
import { Meta, Title, Links, Main, Scripts, useAppData, defineDataLoader, unstable_useDocumentData } from 'ice';
import type { AppData } from '@/types';

export const dataLoader = defineDataLoader(() => {
return new Promise((resolve) => {
setTimeout(() => {
resolve({
title: 'documentData',
});
// ATTENTION: This async call will pause rendering document.
}, 1000);
});
});

function Document() {
const appData = useAppData<AppData>();
// Get document data when fallback to document only.
const documentData = unstable_useDocumentData();

console.log('document data', documentData);

return (
<html>
Expand All @@ -21,6 +37,12 @@ function Document() {
</head>
<body>
<Main />
<div>
<h1>Document Data</h1>
<code>
<pre>{JSON.stringify(documentData, null, 2)}</pre>
</code>
</div>
<Scripts />
</body>
</html>
Expand Down
7 changes: 7 additions & 0 deletions packages/bundles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.1.15

### Patch Changes

- 2875b544: fix: bump @swc/core version
- 1fa826b0: chore: bump rspack version for more hook and plugin support

## 0.1.14

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/bundles",
"version": "0.1.14",
"version": "0.1.15",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand All @@ -15,7 +15,7 @@
"main": "./esm/index.js",
"type": "module",
"dependencies": {
"@swc/core": "1.3.77",
"@swc/core": "1.3.80",
"@ice/swc-plugin-remove-export": "0.2.0",
"@ice/swc-plugin-keep-export": "0.2.0",
"@ice/swc-plugin-node-transform": "0.2.0",
Expand All @@ -33,8 +33,8 @@
"react-refresh": "0.14.0",
"core-js-pure": "^3.8.1",
"error-stack-parser": "^2.0.6",
"@rspack/core": "0.2.12",
"@rspack/dev-server": "0.2.12",
"@rspack/core": "0.3.0",
"@rspack/dev-server": "0.3.0",
"@ice/css-modules-hash": "0.0.6"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 3.3.1

### Patch Changes

- 69e68633: feat: support API useDocumentData
- 41bc1440: fix: ignore static resource when render server entry
- 1fa826b0: chore: bump rspack version for more hook and plugin support
- Updated dependencies [47ba84d3]
- Updated dependencies [477d14cc]
- Updated dependencies [2875b544]
- Updated dependencies [69e68633]
- Updated dependencies [e3e1f27c]
- Updated dependencies [99c0dd26]
- Updated dependencies [101eadea]
- Updated dependencies [d4904e92]
- Updated dependencies [1fa826b0]
- @ice/runtime@1.2.8
- @ice/bundles@0.1.15
- @ice/rspack-config@1.0.2
- @ice/shared-config@1.0.2
- @ice/webpack-config@1.1.1

## 3.3.0

### Minor Changes
Expand Down
16 changes: 8 additions & 8 deletions packages/ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.3.0",
"version": "3.3.1",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand Down Expand Up @@ -37,12 +37,12 @@
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
"dependencies": {
"@ice/bundles": "0.1.14",
"@ice/bundles": "0.1.15",
"@ice/route-manifest": "1.2.1",
"@ice/runtime": "^1.2.7",
"@ice/shared-config": "1.0.1",
"@ice/webpack-config": "1.1.0",
"@ice/rspack-config": "1.0.1",
"@ice/runtime": "^1.2.8",
"@ice/shared-config": "1.0.2",
"@ice/webpack-config": "1.1.1",
"@ice/rspack-config": "1.0.2",
"@swc/helpers": "0.5.1",
"@types/express": "^4.17.14",
"address": "^1.1.2",
Expand Down Expand Up @@ -88,8 +88,8 @@
"unplugin": "^0.9.0",
"webpack": "^5.88.0",
"webpack-dev-server": "^4.7.4",
"@rspack/core": "0.2.12",
"@rspack/dev-server": "0.2.12"
"@rspack/core": "0.3.0",
"@rspack/dev-server": "0.3.0"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/ice/src/bundler/rspack/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { MultiStats } from '@rspack/core';
import { logger } from '../../utils/logger.js';
import { getOutputPaths, removeServerOutput } from '../config/output.js';
import type { BuildOptions, CompileResults, MultiStats } from '../types.js';
import type { BuildOptions, CompileResults } from '../types.js';
import formatStats from './formatStats.js';

async function build(options: BuildOptions) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/bundler/rspack/formatStats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from 'chalk';
import type { Stats, MultiStats } from '@rspack/core';
import formatWebpackMessages from '../../utils/formatWebpackMessages.js';
import type { Stats, MultiStats } from '../types.js';

function formatStats(stats: Stats | MultiStats, showWarnings = true) {
const statsData = stats.toJson({
Expand Down
97 changes: 1 addition & 96 deletions packages/ice/src/bundler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Config } from '@ice/shared-config/types';
import type ora from '@ice/bundles/compiled/ora/index.js';
import type { Stats as WebpackStats } from '@ice/bundles/compiled/webpack/index.js';
import type { AppConfig } from '@ice/runtime/types';
import type { Configuration, MultiCompiler } from '@rspack/core';
import type { Configuration, MultiCompiler, MultiStats } from '@rspack/core';
import type { Context as DefaultContext, TaskConfig } from 'build-scripts';
import type { ServerCompiler, GetAppConfig, GetRoutesConfig, GetDataloaderConfig, ExtendsPluginAPI } from '../types/plugin.js';
import type { UserConfig } from '../types/userConfig.js';
Expand Down Expand Up @@ -45,98 +45,3 @@ export type CompileResults = {
isSuccessful: boolean;
messages: { errors: string[]; warnings: string[] };
};

interface StatsOptionsObj {
all?: boolean;
preset?: 'normal' | 'none' | 'verbose' | 'errors-only' | 'errors-warnings';
assets?: boolean;
chunks?: boolean;
modules?: boolean;
entrypoints?: boolean;
warnings?: boolean;
warningsCount?: boolean;
errors?: boolean;
errorsCount?: boolean;
colors?: boolean;
timings?: boolean;

/** Rspack not support below opts */
cachedAssets?: boolean;
groupAssetsByInfo?: boolean;
groupAssetsByPath?: boolean;
groupAssetsByChunk?: boolean;
groupAssetsByExtension?: boolean;
groupAssetsByEmitStatus?: boolean;
}

/** webpack not support boolean or string */
type StatsOptions = StatsOptionsObj;

interface StatsAssetInfo {
development?: boolean;
}

export interface StatsAsset {
type: string;
name: string;
size: number;
chunks?: Array<string | number>;
chunkNames?: Array<string | number>;
info: StatsAssetInfo;
}

interface StatsError {
message: string;
formatted?: string;
}

interface StatsModule {
type?: string;
moduleType?: string;
identifier?: string;
name?: string;
id?: string;
chunks?: Array<string>;
size?: number;
}

interface StatsCompilation {
assets?: Array<StatsAsset>;
modules?: Array<StatsModule>;
chunks?: Array<StatsChunk>;
// entrypoints?: Array<StatsEntrypoint>;
errors?: Array<StatsError>;
errorsCount?: number;
warnings?: Array<StatsError>;
warningsCount?: number;
time?: number;
name?: string;
children?: StatsCompilation[];
}

interface StatsChunk {
type?: string;
files?: Array<string>;
id?: string | number;
entry: boolean;
initial: boolean;
names?: Array<string>;
size: number;
}

export declare class Stats {
constructor(statsJson: any);
hasErrors(): boolean;
hasWarnings(): boolean;
toJson(opts?: StatsOptions): StatsCompilation;
toString(opts?: StatsOptions): string;
}

export declare class MultiStats {
stats: Stats[];
hasErrors(): boolean;
hasWarnings(): boolean;
toJson(options?: StatsOptions): StatsCompilation;
toString(options?: StatsOptions): string;
}

1 change: 1 addition & 0 deletions packages/ice/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const RUNTIME_EXPORTS = [
'defineServerDataLoader',
'defineStaticDataLoader',
'usePageLifecycle',
'unstable_useDocumentData',
],
alias: {
usePublicAppContext: 'useAppContext',
Expand Down
4 changes: 3 additions & 1 deletion packages/ice/src/middlewares/renderMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default function createRenderMiddleware(options: Options): Middleware {
const matches = matchRoutes(routes, req.path, basename);
const isStaticResources = /\.(js|mjs|map|json|png|jpg|jpeg|gif|svg|eot|woff2|ttf)$/;
// When documentOnly is true, it means that the app is CSR and it should return the html.
if (matches.length || documentOnly || !isStaticResources) {
if ((matches.length || documentOnly) &&
// Ignore static resources.
!isStaticResources.test(req.path)) {
const serverModule = await excuteServerEntry();
if (serverModule) {
const requestContext: ServerContext = {
Expand Down
5 changes: 3 additions & 2 deletions packages/ice/templates/core/entry.server.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as runtime from '@ice/runtime/server';
import { commons, statics } from './runtimeModules';
<% }-%>
import * as app from '@/app';
import Document from '@/document';
import * as Document from '@/document';
import type { RenderMode, DistType } from '@ice/runtime';
import type { RenderToPipeableStreamOptions } from 'react-dom/server';
// @ts-ignore
Expand Down Expand Up @@ -85,7 +85,8 @@ function mergeOptions(options) {
assetsManifest,
createRoutes,
runtimeModules,
Document,
documentDataLoader: Document.dataLoader,
Document: Document.default,
basename: basename || getRouterBasename(),
renderMode,
routesConfig,
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
],
"dependencies": {
"@ice/jsx-runtime": "^0.2.0",
"@swc/helpers": "^0.4.14",
"@swc/helpers": "^0.5.1",
"accept-language-parser": "^1.5.0",
"universal-cookie": "^4.0.4",
"url-join": "^5.0.0"
Expand All @@ -50,13 +50,13 @@
"@ice/app": "workspace:^",
"@ice/runtime": "workspace:^",
"@remix-run/router": "^1.6.1",
"@types/react": "^18.0.33",
"@types/accept-language-parser": "^1.5.3",
"@types/react": "^18.0.33",
"webpack-dev-server": "^4.13.2"
},
"peerDependencies": {
"@ice/app": "^3.3.0",
"@ice/runtime": "^1.2.7"
"@ice/app": "^3.3.1",
"@ice/runtime": "^1.2.8"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-jsx-plus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dependencies": {
"@babel/core": "^7.19.1",
"babel-plugin-transform-jsx-class": "^0.1.3",
"babel-plugin-transform-jsx-condition": "^0.1.2",
"babel-plugin-transform-jsx-condition": "^0.1.3",
"babel-plugin-transform-jsx-fragment": "^0.1.4",
"babel-plugin-transform-jsx-list": "^0.1.2",
"babel-plugin-transform-jsx-memo": "^0.1.4",
Expand Down
23 changes: 22 additions & 1 deletion packages/plugin-jsx-plus/tests/jsxplus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,26 @@ describe('JSX Plus Plugin', () => {
expect(ret.code).toBe(`import { createCondition as __create_condition__ } from "babel-runtime-jsx-plus";
__create_condition__([[() => false, () => <div />]]);`);
});

it('transformer w/ parent element is a <></>', () => {
const plugin = jsxPlus({
include: ['foo'],
});
const fakeConfig = {};
function onGetConfig(fn) {
fn(fakeConfig);
}
const context = {
rootDir: '/foo/bar',
};
// @ts-ignore
plugin.setup({ onGetConfig, context });

const transformer = fakeConfig['transforms'][0];
const ret = transformer('<><div x-if={true} /></>', '/foo/bar/a.tsx');
expect(ret.code).toBe(`import { createCondition as __create_condition__ } from "babel-runtime-jsx-plus";
import { Fragment } from "react";
<>{__create_condition__([[() => true, () => <div />]])}</>;`);
});
});
});
});
12 changes: 12 additions & 0 deletions packages/rspack-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @ice/rspack-config

## 1.0.2

### Patch Changes

- e3e1f27c: fix: compatible with win32 when enable --speedup
- 1fa826b0: chore: bump rspack version for more hook and plugin support
- Updated dependencies [2875b544]
- Updated dependencies [101eadea]
- Updated dependencies [1fa826b0]
- @ice/bundles@0.1.15
- @ice/shared-config@1.0.2

## 1.0.1

### Patch Changes
Expand Down
Loading

0 comments on commit 42718fd

Please sign in to comment.