Skip to content

Commit

Permalink
Merge pull request #5722 from alibaba/release/3.0
Browse files Browse the repository at this point in the history
Release/3.0.4
  • Loading branch information
ClarkXia authored Dec 27, 2022
2 parents b70b95e + bbabb0e commit 2300505
Show file tree
Hide file tree
Showing 91 changed files with 1,322 additions and 769 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [14.x, 16.x, 18.x]
os: [ubuntu-latest, windows-latest]
fail-fast: false
steps:
Expand Down
3 changes: 3 additions & 0 deletions examples/basic-project/ice.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default defineConfig(() => ({
syntaxFeatures: {
exportDefaultFrom: true,
},
alias: {
'@comp': './src/components',
},
define: {
HAHA: JSON.stringify(true),
'process.env.HAHA': JSON.stringify(true),
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-project/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import lessStyles from './index.module.less';
import sassStyles from './index.module.scss';
import type { AppData } from '@/types';

const Bar = lazy(() => import('../components/bar'));
const Bar = lazy(() => import('@comp/bar'));

export default function Home(props) {
const appContext = useAppContext();
Expand Down
1 change: 1 addition & 0 deletions examples/with-ssg/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chrome 55
5 changes: 5 additions & 0 deletions examples/with-ssg/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: false,
});
21 changes: 21 additions & 0 deletions examples/with-ssg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "with-ssg",
"version": "1.0.0",
"scripts": {
"start": "ice start",
"build": "ice build"
},
"description": "ICE example with ssg",
"author": "ICE Team",
"license": "MIT",
"dependencies": {
"@ice/app": "workspace:*",
"@ice/runtime": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6"
}
}
13 changes: 13 additions & 0 deletions examples/with-ssg/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineDataLoader } from 'ice';

export default {
app: {
rootId: 'app',
},
};

export const dataLoader = defineDataLoader(async () => {
return {
id: 123,
};
});
22 changes: 22 additions & 0 deletions examples/with-ssg/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.js example for data loader." />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Title />
<Links />
</head>
<body>
<Main />
<Scripts />
</body>
</html>
);
}

export default Document;
42 changes: 42 additions & 0 deletions examples/with-ssg/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useData, defineDataLoader, defineStaticDataLoader, useAppData } from 'ice';
import { useState } from 'react';

export default function Home() {
const data = useData();
const appData = useAppData();

return (
<>
<h2>With SSG</h2>
<Counter />
<div>id: {appData.id}</div>
<div>price: <span className="price">{data.price}</span></div>
</>
);
}

function Counter() {
const [count, setCount] = useState(0);

function updateCount() {
setCount(count + 1);
}

return (
<button type="button" onClick={updateCount}>
👍🏻 {count}
</button>
);
}

export const dataLoader = defineDataLoader(() => {
return {
price: 99.99,
};
});

export const staticDataLoader = defineStaticDataLoader(() => {
return {
price: '0.00',
};
});
12 changes: 12 additions & 0 deletions examples/with-ssg/src/pages/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Outlet } from 'ice';

export default function Layout() {
console.log('render layout');

return (
<>
<h2>With SSG</h2>
<Outlet />
</>
);
}
1 change: 1 addition & 0 deletions examples/with-ssg/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@ice/app/types" />
32 changes: 32 additions & 0 deletions examples/with-ssg/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "esnext",
"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,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"ice": [".ice"]
}
},
"include": ["src", ".ice", "ice.config.*"],
"exclude": ["build", "public"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"stylelint": "^14.10.0",
"tsx": "^3.9.0",
"tsx": "^3.12.1",
"typescript": "^4.7.4",
"vitest": "^0.15.2"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/bundles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.2

- [fix] add esbuild and esbuild-register

## 0.1.1

- [fix] Bump version of `@swc/core`(1.3.3 -> 1.3.19), https://github.com/swc-project/swc/issues/6371
Expand Down
4 changes: 3 additions & 1 deletion packages/bundles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/bundles",
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",
"author": "ICE",
"description": "Basic dependencies for ice.",
Expand All @@ -24,6 +24,7 @@
"core-js": "3.26.0",
"caniuse-lite": "^1.0.30001431",
"chokidar": "3.5.3",
"esbuild": "^0.16.5",
"events": "3.3.0",
"jest-worker": "27.5.1",
"less": "4.1.2",
Expand All @@ -45,6 +46,7 @@
"css-minimizer-webpack-plugin": "3.4.1",
"cssnano": "^5.1.7",
"es-module-lexer": "0.10.5",
"esbuild-register": "3.4.1",
"eslint": "^8.14.0",
"eslint-webpack-plugin": "3.1.1",
"fork-ts-checker-webpack-plugin": "7.2.6",
Expand Down
7 changes: 7 additions & 0 deletions packages/bundles/scripts/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const taskExternals = {
postcss: 'postcss',
'@swc/core': '@swc/core',
'jest-worker': 'jest-worker',
esbuild: 'esbuild',
};

const commonDeps = ['terser', 'tapable', 'cssnano', 'terser-webpack-plugin', 'webpack', 'schema-utils',
Expand Down Expand Up @@ -63,6 +64,12 @@ const tasks = [
// Dependencies of webpack-dev-server.
...webpackDevServerDeps,
].map((pkgName) => ({ pkgName, externals: taskExternals })),
{
pkgName: 'esbuild-register',
file: 'node_modules/esbuild-register/dist/node.js',
externals: taskExternals,
bundleName: 'node.js',
},
{
pkgName: 'unplugin',
declaration: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/bundles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import postcss from 'postcss';
import less from 'less';
import sass from 'sass';
import swc from '@swc/core';
import esbuild from 'esbuild';

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

coreJsPath,

esbuild,
};

export type { ProcessOptions } from 'postcss';
Expand Down
9 changes: 9 additions & 0 deletions packages/ice/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v3.0.4

- [feat] support incremental compile for server bundle
- [feat] refactor server bundle alias
- [feat] support log debug info with different namespaces
- [fix] support HMR when modules is used by dataLoader
- [fix] error occur when configure `dataLoader: false`
- [fix] don't compile data-loader to lower ES version

## v3.0.3

- [feat] support `generator.addEntryCode` for add code in entry file
Expand Down
11 changes: 5 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.0.3",
"version": "3.0.4",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",
Expand Down Expand Up @@ -37,14 +37,14 @@
"@babel/parser": "7.18.10",
"@babel/traverse": "7.18.10",
"@babel/types": "7.18.10",
"@ice/bundles": "0.1.1",
"@ice/bundles": "0.1.2",
"@ice/route-manifest": "1.0.0",
"@ice/runtime": "^1.0.0",
"@ice/webpack-config": "1.0.3",
"@ice/webpack-config": "1.0.4",
"@swc/helpers": "0.4.12",
"@types/express": "^4.17.14",
"address": "^1.1.2",
"build-scripts": "^2.0.0-26",
"build-scripts": "^2.0.1-0",
"chalk": "^4.0.0",
"commander": "^9.0.0",
"consola": "^2.15.3",
Expand All @@ -54,8 +54,6 @@
"dotenv": "^16.0.0",
"dotenv-expand": "^8.0.3",
"ejs": "^3.1.6",
"esbuild": "^0.14.51",
"esbuild-register": "^3.3.2",
"fast-glob": "^3.2.11",
"find-up": "^5.0.0",
"fs-extra": "^10.0.0",
Expand All @@ -80,6 +78,7 @@
"@types/sass": "^1.43.1",
"@types/temp": "^0.9.1",
"chokidar": "^3.5.3",
"esbuild": "^0.16.5",
"jest": "^29.0.2",
"react": "^18.2.0",
"react-router": "^6.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import consola from 'consola';
import fse from 'fs-extra';
import { getWebpackConfig } from '@ice/webpack-config';
import type { Context, TaskConfig } from 'build-scripts';
Expand All @@ -15,6 +14,7 @@ import { RUNTIME_TMP_DIR, SERVER_OUTPUT_DIR } from '../constant.js';
import emptyDir from '../utils/emptyDir.js';
import type { UserConfig } from '../types/userConfig.js';
import warnOnHashRouterEnabled from '../utils/warnOnHashRouterEnabled.js';
import { logger } from '../utils/logger.js';

const build = async (
context: Context<Config, ExtendsPluginAPI>,
Expand Down Expand Up @@ -96,7 +96,7 @@ const build = async (
}

if (messages.errors.length) {
consola.error('webpack compile error');
logger.error('Webpack compile error.');
reject(new Error(messages.errors.join('\n\n')));
return;
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/ice/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { Config } from '@ice/webpack-config/esm/types';
import type { AppConfig, RenderMode } from '@ice/runtime';
import type ora from '@ice/bundles/compiled/ora/index.js';

import consola from 'consola';
import WebpackDevServer from '@ice/bundles/compiled/webpack-dev-server/lib/Server.js';
import webpack from '@ice/bundles/compiled/webpack/index.js';
import lodash from '@ice/bundles/compiled/lodash/index.js';
Expand All @@ -19,6 +18,7 @@ import prepareURLs from '../utils/prepareURLs.js';
import createRenderMiddleware from '../middlewares/ssr/renderMiddleware.js';
import createMockMiddleware from '../middlewares/mock/createMiddleware.js';
import getRouterBasename from '../utils/getRouterBasename.js';
import { logger } from '../utils/logger.js';

const { merge } = lodash;

Expand Down Expand Up @@ -225,7 +225,7 @@ async function invokeCompilerWatch({
}

if (messages.errors.length) {
consola.error('webpack compile error');
logger.error('Webpack compile error');
throw new Error(messages.errors.join('\n\n'));
}
});
Expand Down
Loading

0 comments on commit 2300505

Please sign in to comment.