Skip to content

Commit

Permalink
Merge pull request #6834 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.4.6
  • Loading branch information
ClarkXia authored Mar 21, 2024
2 parents 1989fc1 + 277518d commit ea7d71e
Show file tree
Hide file tree
Showing 65 changed files with 932 additions and 298 deletions.
1 change: 1 addition & 0 deletions examples/with-dynamic/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chrome 55
5 changes: 5 additions & 0 deletions examples/with-dynamic/ice.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@ice/app';

export default defineConfig(() => ({
ssr: true,
}));
23 changes: 23 additions & 0 deletions examples/with-dynamic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@examples/with-dynamic",
"private": true,
"version": "1.0.0",
"scripts": {
"start": "ice start",
"build": "ice build"
},
"description": "ICE example with dynamic",
"author": "ICE Team",
"license": "MIT",
"dependencies": {
"@ice/app": "workspace:*",
"@ice/runtime": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6"
}
}
6 changes: 6 additions & 0 deletions examples/with-dynamic/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
app: {
rootId: 'app',
type: 'browser',
},
};
6 changes: 6 additions & 0 deletions examples/with-dynamic/src/components/nonssr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default (props) => {
window.addEventListener('load', () => {
console.log('load');
});
return <div>{props.text}</div>;
};
7 changes: 7 additions & 0 deletions examples/with-dynamic/src/components/normal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default () => {
return <div>normal text</div>;
};

export function NameExportComp() {
return <div>name exported</div>;
}
22 changes: 22 additions & 0 deletions examples/with-dynamic/src/document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Meta, Title, Links, Main, Scripts } from 'ice';

function Document() {
return (
<html>
<head>
<meta charSet="utf-8" />
<meta name="description" content="ICE 3 Example for plugin request." />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Title />
<Links />
</head>
<body>
<Main />
<Scripts />
</body>
</html>
);
}

export default Document;
10 changes: 10 additions & 0 deletions examples/with-dynamic/src/pages/nonssr/no-ssr-fallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { dynamic } from '@ice/runtime';

const NonSSR = dynamic(() => import('@/components/nonssr'), {
ssr: false,
fallback: () => <div>fallback</div>,
});

export default () => {
return <NonSSR text={'hello world'} />;
};
9 changes: 9 additions & 0 deletions examples/with-dynamic/src/pages/nonssr/no-ssr-no-fallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { dynamic } from '@ice/runtime';

const NonSSR = dynamic(() => import('@/components/nonssr'), {
ssr: false,
});

export default () => {
return <NonSSR text={'hello world'} />;
};
7 changes: 7 additions & 0 deletions examples/with-dynamic/src/pages/nonssr/ssr-no-fallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { dynamic } from '@ice/runtime';

const NonSSR = dynamic(() => import('@/components/nonssr'));

export default () => {
return <NonSSR text={'hello world'} />;
};
5 changes: 5 additions & 0 deletions examples/with-dynamic/src/pages/nonssr/without-dynamic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import NonSsr from '@/components/nonssr';

export default () => {
return <NonSsr text={'without dynamic'} />;
};
9 changes: 9 additions & 0 deletions examples/with-dynamic/src/pages/normal/bare-import.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { dynamic } from '@ice/runtime';

const Normal = dynamic(import('../../components/normal'), {
fallback: () => <div>bare import fallback</div>,
});

export default () => {
return <Normal />;
};
9 changes: 9 additions & 0 deletions examples/with-dynamic/src/pages/normal/basic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { dynamic } from '@ice/runtime';

const Normal = dynamic(() => import('../../components/normal'), {
fallback: () => <div>normal fallback</div>,
});

export default () => {
return <Normal />;
};
13 changes: 13 additions & 0 deletions examples/with-dynamic/src/pages/normal/name-export.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { dynamic } from '@ice/runtime';

const Normal = dynamic(
import('../../components/normal').then((mod) => {
return {
default: mod.NameExportComp,
};
}),
);

export default () => {
return <Normal />;
};
1 change: 1 addition & 0 deletions examples/with-dynamic/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@ice/app/types" />
44 changes: 44 additions & 0 deletions examples/with-dynamic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "es6",
"jsx": "react-jsx",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"lib": [
"es6",
"dom"
],
"sourceMap": true,
"allowJs": true,
"rootDir": "./",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"importHelpers": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"paths": {
"@/*": [
"./src/*"
],
"ice": [
".ice"
]
}
},
"include": [
"src",
".ice", "src/pages/with-dynamic/.tsx",
],
"exclude": [
"build",
"public"
]
}
2 changes: 1 addition & 1 deletion examples/with-keep-alive/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function Layout() {
return (
<div>
<h2>Layout</h2>
<KeepAliveOutlet />
<KeepAliveOutlet limit={2} paths={['/home']} />
</div>
);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"@rspack/[email protected].4": "patches/@[email protected].4.patch",
"@rspack/[email protected].7": "patches/@[email protected].7.patch",
"[email protected]": "patches/[email protected]"
}
}
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.2.6

### Patch Changes

- 8275f13f: feat: upgrade icepack for new features
- 0d3cfd59: refactor: the compilation for data-loader

## 0.2.5

### Patch Changes
Expand Down
10 changes: 5 additions & 5 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.5",
"version": "0.2.6",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand Down Expand Up @@ -45,13 +45,13 @@
"zod": "^3.22.3",
"zod-validation-error": "1.2.0",
"terminal-link": "^2.1.1",
"@ice/pack-binding": "0.0.11",
"@ice/pack-binding": "0.0.12",
"mime-types": "2.1.35"
},
"devDependencies": {
"@rspack/plugin-react-refresh": "0.5.4",
"@rspack/dev-server": "0.5.4",
"@rspack/core": "0.5.4",
"@rspack/plugin-react-refresh": "0.5.7",
"@rspack/dev-server": "0.5.7",
"@rspack/core": "0.5.7",
"@types/less": "^3.0.3",
"@types/lodash": "^4.14.181",
"@types/webpack-bundle-analyzer": "^4.4.1",
Expand Down
18 changes: 18 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 3.4.6

### Patch Changes

- 8275f13f: feat: upgrade icepack for new features
- 0d3cfd59: refactor: the compilation for data-loader
- ac36776f: feat: support add plugin by cli option
- Updated dependencies [ba811d72]
- Updated dependencies [a7c76b62]
- Updated dependencies [8275f13f]
- Updated dependencies [0d3cfd59]
- Updated dependencies [d0a748f6]
- @ice/runtime@1.4.3
- @ice/rspack-config@1.1.6
- @ice/bundles@0.2.6
- @ice/shared-config@1.2.6
- @ice/webpack-config@1.1.13

## 3.4.5

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions packages/ice/bin/ice-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
.option('--analyzer', 'visualize size of output files', false)
.option('--config <config>', 'use custom config')
.option('--rootDir <rootDir>', 'project root directory', cwd)
.option('--plugin <plugin>', 'add ice plugin by npm package')
.action(async ({ rootDir, ...commandArgs }, ctx) => {
renamePlatformToTarget(commandArgs);
process.env.NODE_ENV = 'production';
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.4.5",
"version": "3.4.6",
"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.5",
"@ice/bundles": "0.2.6",
"@ice/route-manifest": "1.2.2",
"@ice/runtime": "^1.4.2",
"@ice/shared-config": "1.2.5",
"@ice/webpack-config": "1.1.12",
"@ice/rspack-config": "1.1.5",
"@ice/runtime": "^1.4.3",
"@ice/shared-config": "1.2.6",
"@ice/webpack-config": "1.1.13",
"@ice/rspack-config": "1.1.6",
"@swc/helpers": "0.5.1",
"@types/express": "^4.17.14",
"address": "^1.1.2",
Expand Down Expand Up @@ -98,8 +98,8 @@
"unplugin": "^1.6.0",
"webpack": "^5.88.0",
"webpack-dev-server": "4.15.0",
"@rspack/core": "0.5.4",
"@rspack/dev-server": "0.5.4"
"@rspack/core": "0.5.7",
"@rspack/dev-server": "0.5.7"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/ice/src/bundler/config/middlewares.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Compiler } from '@rspack/core';
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';
import type { TaskConfig } from 'build-scripts';
import type { RenderMode } from '@ice/runtime';
import type { Config } from '@ice/shared-config/types';
import createMockMiddleware from '../../middlewares/mock/createMiddleware.js';
import createRenderMiddleware from '../../middlewares/renderMiddleware.js';
import createDataLoaderMiddleware from '../../middlewares/dataLoaderMiddleware.js';
import type { UserConfig } from '../../types/userConfig.js';
import type RouteManifest from '../../utils/routeManifest.js';
import type { GetAppConfig } from '../../types/plugin.js';
Expand All @@ -16,6 +18,7 @@ interface SetupOptions {
excuteServerEntry: () => Promise<any>;
mock: boolean;
rootDir: string;
dataLoaderCompiler?: Compiler;
}

function setupMiddlewares(middlewares: Parameters<DevServerConfiguration['setupMiddlewares']>[0], {
Expand All @@ -26,6 +29,7 @@ function setupMiddlewares(middlewares: Parameters<DevServerConfiguration['setupM
excuteServerEntry,
mock,
rootDir,
dataLoaderCompiler,
}: SetupOptions) {
const { ssr, ssg } = userConfig;
let renderMode: RenderMode;
Expand All @@ -46,6 +50,12 @@ function setupMiddlewares(middlewares: Parameters<DevServerConfiguration['setupM
routeManifest,
excuteServerEntry,
});

if (dataLoaderCompiler) {
const dataLoaderMiddleware = createDataLoaderMiddleware(dataLoaderCompiler);
middlewares.unshift(dataLoaderMiddleware);
}

// @ts-ignore property of name is exist.
const insertIndex = middlewares.findIndex(({ name }) => name === 'serve-index');
middlewares.splice(
Expand Down
5 changes: 3 additions & 2 deletions packages/ice/src/bundler/rspack/formatStats.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import chalk from 'chalk';
import type { Stats, MultiStats } from '@rspack/core';
import type { StatsCompilation } from 'webpack';
import formatWebpackMessages from '../../utils/formatWebpackMessages.js';

function formatStats(stats: Stats | MultiStats, showWarnings = true) {
const statsData = stats.toJson({
preset: 'errors-warnings',
});
// @ts-ignore
}) as StatsCompilation;

const { errors, warnings } = formatWebpackMessages(statsData);

if (errors.length) {
Expand Down
Loading

0 comments on commit ea7d71e

Please sign in to comment.