Skip to content

Commit

Permalink
Merge pull request #4981 from alibaba/release-next
Browse files Browse the repository at this point in the history
Release/2.3.0
  • Loading branch information
ClarkXia authored Dec 2, 2021
2 parents 38112c4 + 1871a53 commit 256595b
Show file tree
Hide file tree
Showing 105 changed files with 1,432 additions and 466 deletions.
1 change: 0 additions & 1 deletion examples/basic-mpa/build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"router": false,
"vite": true,
"mpa": {
"openPage": "Dashboard",
Expand Down
12 changes: 12 additions & 0 deletions examples/basic-mpa/src/pages/About/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { runApp, IAppConfig } from 'ice';
import Index from './index';

const appConfig: IAppConfig = {
router: {
type: 'hash',
routes: [{ path: '/', component: Index }],
},
};

runApp(appConfig);
11 changes: 11 additions & 0 deletions examples/basic-mpa/src/pages/About/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

const About = () => {
return (
<>
<h2>About Page...</h2>
</>
);
};

export default About;
2 changes: 1 addition & 1 deletion examples/basic-mpa/src/pages/Dashboard/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Provider = store.Provider;

const appConfig: IAppConfig = {
router: {
routes
routes,
},
app: {
addProvider({ children }) {
Expand Down
18 changes: 18 additions & 0 deletions examples/basic-mpa/src/pages/Profile/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { runApp, IAppConfig } from 'ice';
import Page from './index';
import store from './store';

const Provider = store.Provider;

const appConfig: IAppConfig = {
app: {
rootId: 'custom-container',
renderComponent: Page,
addProvider: ({ children }) => {
return <Provider>{children}</Provider>;
}
},
};

runApp(appConfig);
9 changes: 8 additions & 1 deletion examples/basic-mpa/src/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';
import store from './store';

const Profile = () => {
const [pageState, pageActions] = store.useModel('counter');
return (
<>
<h2>Profile Page</h2>
<h2>Profile Page...</h2>
<div>
<button type="button" onClick={pageActions.increment}>+</button>
<span>{pageState.count}</span>
<button type="button" onClick={pageActions.decrement}>-</button>
</div>
</>
);
};
Expand Down
14 changes: 14 additions & 0 deletions examples/basic-mpa/src/pages/Profile/models/counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
state: {
count: 0
},

reducers: {
increment (prevState) {
return { count: prevState.count + 1 };
},
decrement (prevState) {
return { count: prevState.count - 1 };
}
}
};
6 changes: 6 additions & 0 deletions examples/basic-mpa/src/pages/Profile/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createStore } from 'ice';
import counter from './models/counter';

const store = createStore({ counter });

export default store;
1 change: 1 addition & 0 deletions examples/basic-spa/build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// "router": false,
"remoteRuntime": true,
"polyfill": false,
"ignoreHtmlTemplate": false,
Expand Down
4 changes: 3 additions & 1 deletion examples/basic-spa/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const appConfig: IAppConfig = {
rootId: 'ice-container',
errorBoundary: true,
parseSearchParams: true,
// renderComponent: () => <>HELLO</>,
getInitialData: async() => {
// const result = await request('/repo');
const result = {
Expand All @@ -33,7 +34,8 @@ const appConfig: IAppConfig = {
router: {
basename: '/ice',
type: 'hash',
fallback: <div>加载中...</div>
fallback: <div>加载中...</div>,
// routes: [{path: '/home', component: () => <>He</>}]
},
request: {
timeout: 5000,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-spa/src/pages/About/components/Child.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';

const Child = () => {
function getData() {
throw new Error('test Error');
throw new Error('Child Error');
}

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-spa/src/pages/About/components/Todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';

class Todo extends PureComponent {
componentDidMount() {
throw new Error('test error boundary');
throw new Error('Todo Error');
}

render() {
Expand Down
1 change: 0 additions & 1 deletion examples/icestark-layout/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"plugins": [
"build-plugin-icestark",
["build-plugin-fusion", {
"themePackage": "@icedesign/theme",
"themeConfig": {
"nextPrefix": "next-fd-"
}
Expand Down
9 changes: 3 additions & 6 deletions examples/icestark-layout/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import { ConfigProvider } from '@alifd/next';
const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
addProvider: ({ children }) => (
<ConfigProvider prefix="next-fd-">{children}</ConfigProvider>
),
},
logger: {
level: 'warn'
addProvider: ({ children }) => {
return <ConfigProvider prefix="next-fd-">{children}</ConfigProvider>;
},
},
router: {
type: 'browser',
Expand Down
5 changes: 5 additions & 0 deletions examples/icestark-layout/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as React from 'react';

export default function Home() {
return <h2>Index Page</h2>;
}
7 changes: 7 additions & 0 deletions examples/spa-renderComponent/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// "vite": true,
"store": true,
"router": false,
"plugins": [],
"ssr": true
}
15 changes: 15 additions & 0 deletions examples/spa-renderComponent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-simple",
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"devDependencies": {
"@types/react": "^16.9.20",
"@types/react-dom": "^16.9.5"
},
"scripts": {
"start": "../../packages/icejs/bin/ice-cli.js start --mode dev",
"build": "../../packages/icejs/bin/ice-cli.js build --mode prod"
}
}
Binary file added examples/spa-renderComponent/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions examples/spa-renderComponent/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" />
<meta name="viewport" content="width=device-width" />
<title>icejs · icestark child example</title>
</head>

<body>
<div id="ice-container"></div>
</body>
</html>
6 changes: 6 additions & 0 deletions examples/spa-renderComponent/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"template": "node",
"container": {
"port": 3333
}
}
27 changes: 27 additions & 0 deletions examples/spa-renderComponent/src/Test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import { getSearchParams } from 'ice';
import store from './store';

export default function Test(props) {
console.log('Test props', props);
console.log('search params', getSearchParams());

const [counterState, counterAction] = store.useModel('counter');

return <>
Hello: {props.name}
<div>Count: {counterState.count}</div>
<div onClick={counterAction.increment}>+</div>
<div onClick={counterAction.decrement}>-</div>
</>;
}

Test.pageConfig = {
title: '哈哈'
};

Test.getInitialProps = async (ctx) => {
return {
name: 'React(getInitialProps)'
};
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { runApp, IAppConfig } from 'ice';
import Page from './index';
import Test from './Test';

const appConfig: IAppConfig = {
app: {
rootId: 'custom-container',
rootId: 'ice-container',
renderComponent: Test,
},
renderComponent: Page,
// router: {}
};

runApp(appConfig);
14 changes: 14 additions & 0 deletions examples/spa-renderComponent/src/models/counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
state: {
count: 0,
},

reducers: {
increment(prevState) {
prevState.count += 1;
},
decrement(prevState) {
prevState.count -= 1;
}
}
};
6 changes: 6 additions & 0 deletions examples/spa-renderComponent/src/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createStore } from 'ice';
import counter from './models/counter';

const store = createStore({ counter });

export default store;
38 changes: 38 additions & 0 deletions examples/spa-renderComponent/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "es6",
"jsx": "react",
"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,
"types": ["node"],
"paths": {
"@/*": [
"./src/*"
],
"ice": [
".ice/index.ts"
],
}
}
}
4 changes: 2 additions & 2 deletions examples/without-react-router/src/pages/About/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Main from './index';

const appConfig: IAppConfig = {
app: {
rootId: 'ice-container'
rootId: 'ice-container',
renderComponent: Main,
},
renderComponent: Main,
};

runApp(appConfig);
4 changes: 2 additions & 2 deletions examples/without-react-router/src/pages/Home/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Main from './index';

const appConfig: IAppConfig = {
app: {
rootId: 'ice-container'
rootId: 'ice-container',
renderComponent: Main,
},
renderComponent: Main,
};

runApp(appConfig);
15 changes: 12 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ module.exports = {
moduleNameMapper,
// 'testRunner': 'jest-circus/runner',
'coverageDirectory': './coverage/',
'testEnvironment': 'node',
'collectCoverage': true,
'collectCoverageFrom': ['packages/*/lib/*.{js,jsx}'],
'coveragePathIgnorePatterns': [
'<rootDir>/node_modules/'
],
// copy from jest config

'testEnvironment': 'node',
'transform': {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.tsx?$': 'ts-jest'
Expand All @@ -26,8 +28,15 @@ module.exports = {
'testPathIgnorePatterns': [
'/node_modules/',
'/lib/',
'create-cli-utils/',
'create-cli-utils/'
],
// copy from jest config
'testMatch': [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)' ],
// For ts-jest use rootDir's tsconfig.json, while unable to resolve references.
// The following strategy maybe not the best, but it works.
// https://github.com/kulshekhar/ts-jest/issues/1648
'globals': {
'ts-jest': {
'tsconfig': 'tsconfig.settings.json',
},
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@ice/spec": "^1.0.0",
"@napi-rs/cli": "^1.1.0",
"@testing-library/react-hooks": "^3.2.1",
"@types/dts-bundle": "^0.0.32",
"@types/jest": "^25.2.1",
Expand Down Expand Up @@ -74,8 +75,7 @@
"simple-git": "^1.132.0",
"ts-jest": "^26.0.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.0",
"@napi-rs/cli": "^1.1.0"
"typescript": "^4.0.0"
},
"dependencies": {
"core-js": "^3.6.4"
Expand Down
Loading

0 comments on commit 256595b

Please sign in to comment.