Skip to content

Commit

Permalink
Merge pull request #3308 from alibaba/release-next
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbin92 authored Jul 2, 2020
2 parents b987b09 + c8f23b7 commit 75f5501
Show file tree
Hide file tree
Showing 34 changed files with 151 additions and 55 deletions.
19 changes: 16 additions & 3 deletions docs/guide/basic/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ icejs 中一般不允许修改该配置。
### eslint

- 类型:`boolean` | `object`
- 默认值:`true`
- 默认值:`false`

默认开启 eslint 代码检测,如需关闭配置为 `false` 即可。
默认关闭 eslint 代码检测,如需开启配置为 `true` 即可。

```json
{
"eslint": false
"eslint": true
}
```

Expand All @@ -457,6 +457,19 @@ icejs 中一般不允许修改该配置。
}
```

### tsChecker

- 类型:`boolean`
- 默认值:`false`

默认关闭 TypeScript 类型检测,如需开启配置为 `true` 即可。

```json
{
"tsChecker": true
}
```

## 根据环境区分工程配置

参考 [区分不同环境](/docs/guide/basic/config.md)
Expand Down
3 changes: 2 additions & 1 deletion examples/basic-store/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"plugins": [],
"router": {
"lazy": false
}
},
"tsChecker": true
}
5 changes: 5 additions & 0 deletions examples/basic-store/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.module.scss' {
const classes: { [key: string]: string };
export default classes;
}

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.1",
"version": "1.6.2",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ice.js",
"private": true,
"version": "1.6.0",
"version": "1.6.1",
"workspaces": [
"packages/*"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/create-ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-ice",
"version": "1.6.1",
"version": "1.6.2",
"description": "npm init ice",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
22 changes: 11 additions & 11 deletions packages/icejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice.js",
"version": "1.6.1",
"version": "1.6.2",
"description": "command line interface and builtin plugin for icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand All @@ -25,16 +25,16 @@
},
"dependencies": {
"@alib/build-scripts": "^0.1.13",
"build-plugin-ice-config": "1.6.1",
"build-plugin-ice-core": "1.6.1",
"build-plugin-ice-helpers": "1.6.1",
"build-plugin-ice-logger": "1.6.1",
"build-plugin-ice-mpa": "1.6.1",
"build-plugin-ice-request": "1.6.1",
"build-plugin-ice-router": "1.6.1",
"build-plugin-ice-ssr": "1.6.1",
"build-plugin-ice-store": "1.6.1",
"build-plugin-react-app": "1.6.1",
"build-plugin-ice-config": "1.6.2",
"build-plugin-ice-core": "1.6.2",
"build-plugin-ice-helpers": "1.6.2",
"build-plugin-ice-logger": "1.6.2",
"build-plugin-ice-mpa": "1.6.2",
"build-plugin-ice-request": "1.6.2",
"build-plugin-ice-router": "1.6.2",
"build-plugin-ice-ssr": "1.6.2",
"build-plugin-ice-store": "1.6.2",
"build-plugin-react-app": "1.6.2",
"chokidar": "^3.3.1",
"commander": "^5.0.0",
"detect-port": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-auth",
"version": "1.6.1",
"version": "1.6.2",
"description": "",
"author": "ice-admin@alibaba-inc.com",
"homepage": "https://github.com/alibaba/ice#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-config",
"version": "1.6.1",
"version": "1.6.2",
"description": "Define application config in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-core",
"version": "1.6.1",
"version": "1.6.2",
"description": "the core plugin for icejs.",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IErrorInfo {
};

interface IState {
error?: Error;
error?: Error | null;
info?: IErrorInfo;
};

Expand All @@ -25,16 +25,18 @@ class ErrorBoundary extends React.Component<IProps, IState> {

state = {
error: null,
info: null
info: {
componentStack: ''
}
};

componentDidCatch(error: Error, info: IErrorInfo): void {
const { onError } = this.props;

if (typeof onError === 'function') {
try {
// istanbul ignore next: Ignoring ternary; can’t reproduce missing info in test environment.
onError.call(this, error, info ? info.componentStack : '');
// can’t reproduce missing info in development environment.
onError.call(this, error, info.componentStack);
} catch (ignoredError) {
// ignored error
}
Expand All @@ -49,13 +51,10 @@ class ErrorBoundary extends React.Component<IProps, IState> {
const { error, info } = this.state;

// render fallback UI if there is error
if (error !== null) {
if (error !== null && typeof Fallback === 'function') {
return (
<Fallback
componentStack={
// istanbul ignore next: Ignoring ternary; can’t reproduce missing info in test environment.
info ? info.componentStack : ''
}
componentStack={info.componentStack}
error={error}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { IAppConfig } from './types';
<% if (globalStyle) {%>import '../<%= globalStyle %>'<% } %>
export interface IContext {
initialData: any;
pageInitialProps: any;
pathname: string;
initialData?: any;
pageInitialProps?: any;
pathname?: string;
}
const defaultAppConfig = {
Expand Down Expand Up @@ -42,7 +42,7 @@ function createApp(customConfig: IAppConfig) {
// client side rendering
// get history instance
const { type, basename, history: customHistory } = appConfig.router;
const { type, basename = '', history: customHistory } = appConfig.router;
const history = customHistory || createHistory(type, basename);
appConfig.router.history = history;
Expand All @@ -61,6 +61,7 @@ function createApp(customConfig: IAppConfig) {
// ssr not enabled, or SSR is enabled but the server does not return data
if (appConfig.app.getInitialData) {
(async() => {
// @ts-ignore
initialData = await appConfig.app.getInitialData();
renderApp(appConfig, { initialData, pageInitialProps });
})();
Expand All @@ -70,7 +71,7 @@ function createApp(customConfig: IAppConfig) {
}
}
function renderApp(config: IAppConfig, context: IContext) {
function renderApp(config: IAppConfig, context?: IContext) {
const runtime = new RuntimeModule(config, <%- buildConfig %>, context)
loadModlues(runtime);
const { appConfig, modifyDOMRender } = runtime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createBrowserHistory, createHashHistory, createMemoryHistory, History } from '$ice/history';
import {
createBrowserHistory,
createHashHistory,
createMemoryHistory,
History
// @ts-ignore
} from '$ice/history';

// provide history instance
// can be used in the application through history.push()
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-core/src/generator/templates/app/types.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ app?: IApp
<%- iceIAppConfigTypesExports %>
}
<% } %>

declare global {
interface Window {
__ICE_SSR_ENABLED__: any;
__ICE_APP_DATA__: any;
__ICE_PAGE_PROPS__: any;
}
}
2 changes: 2 additions & 0 deletions packages/plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default (api) => {
const plugins = getAllPlugin();
// get runtime module
const runtimeModules = plugins.map(({ pluginPath }) => {
// compatible with function plugin
if (!pluginPath) return false;
const modulePath = path.join(path.dirname(pluginPath), 'module.js');
return fse.existsSync(modulePath) ? formatPath(modulePath) : false;
})
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-fast-refresh/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-fast-refresh",
"version": "1.6.1",
"version": "1.6.2",
"description": "A Webpack plugin to enable Fast Refresh (also previously known as Hot Reloading) for React",
"author": "思忠 <chenbinbin.cb@alibaba-inc.com>",
"homepage": "https://github.com/alibaba/ice#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-helpers",
"version": "1.6.1",
"version": "1.6.2",
"description": "builtin helpers in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-icestark/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-icestark",
"version": "1.6.1",
"version": "1.6.2",
"description": "Easy use `icestark` in icejs.",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-logger",
"version": "1.6.1",
"version": "1.6.2",
"description": "builtin logger in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-mpa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-mpa",
"version": "1.6.1",
"version": "1.6.2",
"description": "enable mpa project for icejs framework",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-prerender/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-prerender",
"version": "1.6.1",
"version": "1.6.2",
"description": "Prerender Plugin",
"main": "lib/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-react-app",
"version": "1.6.1",
"version": "1.6.2",
"description": "The basic webpack configuration for ice project",
"author": "ice-admin@alibaba-inc.com",
"main": "src/index.js",
Expand All @@ -20,6 +20,7 @@
"copy-webpack-plugin": "^5.0.4",
"core-js": "^3.3.1",
"eslint-loader": "^4.0.0",
"fork-ts-checker-webpack-plugin": "^5.0.5",
"friendly-errors-webpack-plugin": "^1.7.0",
"fs-extra": "^8.1.0",
"html-webpack-plugin": "^3.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-react-app/src/config/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ module.exports = {
compileDependencies: [],
babelPlugins: [],
babelPresets: [],
eslint: false
eslint: false,
tsChecker: false
};
3 changes: 2 additions & 1 deletion packages/plugin-react-app/src/config/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ module.exports = {
babelPresets: 'array',
eslint: (val) => {
return validation('eslint', val, 'boolean|object');
}
},
tsChecker: 'boolean'
};
3 changes: 2 additions & 1 deletion packages/plugin-react-app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ module.exports = ({
libraryName: /@ali\/ice-.*/,
stylePath: 'style.js',
},
]]);
]])
.end();
if (mode === 'development') {
// disable build-scripts stats output
process.env.DISABLE_STATS = true;
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-react-app/src/userConfig/tsChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = (config, tsChecker) => {
if (tsChecker) {
config.plugin('fork-ts-checker-webpack-plugin')
.use(ForkTsCheckerWebpackPlugin);
}
};
2 changes: 1 addition & 1 deletion packages/plugin-rematch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-rematch",
"version": "1.6.1",
"version": "1.6.2",
"description": "Easy use `rematch` in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-request/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-request",
"version": "1.6.1",
"version": "1.6.2",
"description": "request for build-plugin-ice-request",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-router",
"version": "1.6.1",
"version": "1.6.2",
"description": "build-plugin-ice-router",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-router/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { History } from 'history';
import { RouteItemProps, IModifyRoutes } from './base';

export interface IAppRouterProps {
type?: 'hash' | 'browser' | 'memory';
type?: 'hash' | 'browser' | 'memory' | 'static';
routes?: RouteItemProps[];
basename?: string;
modifyRoutes?: IModifyRoutes;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-service",
"version": "1.6.1",
"version": "1.6.2",
"description": "service pulgin",
"author": "ice-admin@alibaba-inc.com",
"homepage": "https://github.com/ice-lab/icejs#readme",
Expand Down
Loading

0 comments on commit 75f5501

Please sign in to comment.