Skip to content

Commit

Permalink
Merge pull request #6481 from alibaba/release/next
Browse files Browse the repository at this point in the history
Release 3.3.0
  • Loading branch information
ClarkXia authored Aug 22, 2023
2 parents dd81060 + 48e3d8b commit 3236acd
Show file tree
Hide file tree
Showing 127 changed files with 4,063 additions and 1,312 deletions.
2 changes: 1 addition & 1 deletion examples/app-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/basic-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/cavans-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/csr-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/disable-data-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/miniapp-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"@types/react-dom": "^18.0.2",
"browserslist": "^4.19.3",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/rax-inline-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/rax-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-entry-type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"fs-extra": "^10.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-nested-routes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"speed-measure-webpack-plugin": "^1.5.0",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-pha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.2",
"webpack": "^5.86.0"
"webpack": "^5.88.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-suspense-ssr/src/components/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ async function getData(ctx) {
});

return fakeData;
}
}
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.1.14

### Patch Changes

- 1dbcfa51: fix: bump @swc/core, webpack, swc plugins, core-js version

## 0.1.13

### Patch Changes
Expand Down
19 changes: 11 additions & 8 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.13",
"version": "0.1.14",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand All @@ -15,13 +15,13 @@
"main": "./esm/index.js",
"type": "module",
"dependencies": {
"@swc/core": "1.3.19",
"@ice/swc-plugin-remove-export": "0.1.2",
"@ice/swc-plugin-keep-export": "0.1.4-2",
"@ice/swc-plugin-node-transform": "0.1.0-8",
"@swc/core": "1.3.77",
"@ice/swc-plugin-remove-export": "0.2.0",
"@ice/swc-plugin-keep-export": "0.2.0",
"@ice/swc-plugin-node-transform": "0.2.0",
"ansi-html-community": "^0.0.8",
"html-entities": "^2.3.2",
"core-js": "3.29.1",
"core-js": "3.32.0",
"caniuse-lite": "^1.0.30001431",
"chokidar": "3.5.3",
"esbuild": "^0.17.16",
Expand All @@ -32,7 +32,10 @@
"sass": "1.50.0",
"react-refresh": "0.14.0",
"core-js-pure": "^3.8.1",
"error-stack-parser": "^2.0.6"
"error-stack-parser": "^2.0.6",
"@rspack/core": "0.2.12",
"@rspack/dev-server": "0.2.12",
"@ice/css-modules-hash": "0.0.6"
},
"devDependencies": {
"@types/less": "^3.0.3",
Expand Down Expand Up @@ -65,7 +68,7 @@
"terser-webpack-plugin": "5.3.5",
"typescript": "^4.6.4",
"trusted-cert": "1.1.3",
"webpack": "5.86.0",
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.5.0",
"webpack-dev-server": "4.15.0",
"unplugin": "0.9.5",
Expand Down
1 change: 1 addition & 0 deletions packages/bundles/src/dev-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@rspack/dev-server';
2 changes: 2 additions & 0 deletions packages/bundles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sass from 'sass';
import swc from '@swc/core';
import esbuild from 'esbuild';
import * as caniuseLite from 'caniuse-lite';
import { getCssModulesLocalIdent } from '@ice/css-modules-hash';

const require = createRequire(import.meta.url);
const swcPluginRemoveExport = require.resolve('@ice/swc-plugin-remove-export');
Expand All @@ -26,6 +27,7 @@ export {

esbuild,
caniuseLite,
getCssModulesLocalIdent,
};

export type { ProcessOptions } from 'postcss';
Expand Down
3 changes: 3 additions & 0 deletions packages/bundles/src/react-refresh-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import runtime from 'react-refresh/runtime';

export default runtime;
1 change: 1 addition & 0 deletions packages/bundles/src/rspack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@rspack/core';
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.3.0

### Minor Changes

- f5d155b5: feat: support build by rust tools

### Patch Changes

- Updated dependencies [f5d155b5]
- Updated dependencies [1dbcfa51]
- @ice/webpack-config@1.1.0
- @ice/bundles@0.1.14
- @ice/rspack-config@1.0.1
- @ice/shared-config@1.0.1

## 3.2.10

### 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 @@ -57,6 +57,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
.option('--analyzer', 'visualize size of output files', false)
.option('--https [https]', 'enable https', false)
.option('--force', 'force remove cache directory', false)
.option('--speedup', 'speed up build time based on Rust tools', false)
.action(async ({ rootDir, ...commandArgs }, ctx) => {
renamePlatformToTarget(commandArgs);
process.env.NODE_ENV = 'development';
Expand Down
16 changes: 10 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.2.10",
"version": "3.3.0",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand Down Expand Up @@ -37,14 +37,16 @@
"bugs": "https://github.com/alibaba/ice/issues",
"homepage": "https://v3.ice.work",
"dependencies": {
"@ice/bundles": "0.1.13",
"@ice/bundles": "0.1.14",
"@ice/route-manifest": "1.2.1",
"@ice/runtime": "^1.2.7",
"@ice/webpack-config": "1.0.20",
"@ice/shared-config": "1.0.1",
"@ice/webpack-config": "1.1.0",
"@ice/rspack-config": "1.0.1",
"@swc/helpers": "0.5.1",
"@types/express": "^4.17.14",
"address": "^1.1.2",
"build-scripts": "^2.1.1-0",
"build-scripts": "^2.1.2-0",
"chalk": "^4.0.0",
"commander": "^9.0.0",
"consola": "^2.15.3",
Expand Down Expand Up @@ -84,8 +86,10 @@
"react-router": "6.14.2",
"sass": "^1.50.0",
"unplugin": "^0.9.0",
"webpack": "^5.86.0",
"webpack-dev-server": "^4.7.4"
"webpack": "^5.88.0",
"webpack-dev-server": "^4.7.4",
"@rspack/core": "0.2.12",
"@rspack/dev-server": "0.2.12"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
21 changes: 21 additions & 0 deletions packages/ice/src/bundler/config/defaultServerConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import detectPort from 'detect-port';
import type { CommandArgs } from 'build-scripts';
import type { Configuration } from 'webpack-dev-server';
import { DEFAULT_HOST, DEFAULT_PORT } from '../../constant.js';

async function getDefaultServerConfig(devServerConfig: Configuration, commandArgs: CommandArgs) {
// Get the value of the host and port from the command line, environment variables, and webpack config.
// Value priority: process.env.PORT > commandArgs > webpackConfig > DEFAULT.
const host = process.env.HOST ||
commandArgs.host ||
devServerConfig?.host ||
DEFAULT_HOST;
const port = process.env.PORT ||
commandArgs.port ||
devServerConfig?.port ||
await detectPort(DEFAULT_PORT);

return { host, port };
}

export default getDefaultServerConfig;
33 changes: 33 additions & 0 deletions packages/ice/src/bundler/config/getUrls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { TaskConfig } from 'build-scripts';
import type { Config } from '@ice/shared-config/types';
import type { AppConfig } from '@ice/runtime/types';
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';
import prepareURLs from '../../utils/prepareURLs.js';
import getRouterBasename from '../../utils/getRouterBasename.js';

interface Options {
taskConfig: TaskConfig<Config>;
appConfig: AppConfig;
devServerConfig: DevServerConfiguration;
}

const getUrls = ({
taskConfig,
appConfig,
devServerConfig,
}: Options) => {
const urlPathname = getRouterBasename(taskConfig, appConfig) || '/';
const protocol = devServerConfig.https ? 'https' : 'http';
const enabledHashRouter = appConfig.router?.type === 'hash';
const urls = prepareURLs(
protocol,
devServerConfig.host,
devServerConfig.port as number,
urlPathname.endsWith('/') ? urlPathname : `${urlPathname}/`,
enabledHashRouter,
);

return urls;
};

export default getUrls;
64 changes: 64 additions & 0 deletions packages/ice/src/bundler/config/middlewares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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 type { UserConfig } from '../../types/userConfig.js';
import type RouteManifest from '../../utils/routeManifest.js';
import type { GetAppConfig } from '../../types/plugin.js';

interface SetupOptions {
userConfig: UserConfig;
taskConfig: TaskConfig<Config>;
routeManifest: RouteManifest;
getAppConfig: GetAppConfig;
excuteServerEntry: () => Promise<any>;
mock: boolean;
rootDir: string;
}

function setupMiddlewares(middlewares: Parameters<DevServerConfiguration['setupMiddlewares']>[0], {
userConfig,
taskConfig,
routeManifest,
getAppConfig,
excuteServerEntry,
mock,
rootDir,
}: SetupOptions) {
const { ssr, ssg } = userConfig;
let renderMode: RenderMode;
// If ssr is set to true, use ssr for preview.
if (ssr) {
renderMode = 'SSR';
} else if (ssg) {
renderMode = 'SSG';
}
// Both ssr and ssg, should render the whole page in dev mode.
const documentOnly = !ssr && !ssg;
const serverRenderMiddleware = createRenderMiddleware({
documentOnly,
renderMode,
getAppConfig,
taskConfig,
userConfig,
routeManifest,
excuteServerEntry,
});
// @ts-ignore property of name is exist.
const insertIndex = middlewares.findIndex(({ name }) => name === 'serve-index');
middlewares.splice(
insertIndex, 0,
serverRenderMiddleware,
);

if (mock) {
const mockMiddleware = createMockMiddleware({ rootDir, exclude: userConfig?.mock?.exclude });
middlewares.splice(insertIndex, 0, mockMiddleware);
}
return middlewares;
}


export default setupMiddlewares;
Loading

0 comments on commit 3236acd

Please sign in to comment.