From 77536895bbf67a6318c909b5b1b6e0b7a0bee2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=9D=E5=BF=A0?= Date: Thu, 23 Apr 2020 17:02:12 +0800 Subject: [PATCH 01/23] chore: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb8c99f..c5b0f8e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ice.js", "private": true, - "version": "1.1.8", + "version": "1.2.0", "workspaces": [ "packages/*" ], From d857a088260f3bc9cb76b48fd473c7ede90d3970 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 23 Apr 2020 17:07:38 +0800 Subject: [PATCH 02/23] feat: add webpackHotDevClient when command is start(#262) --- .../plugin-react-app/src/userConfig/entry.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/plugin-react-app/src/userConfig/entry.js b/packages/plugin-react-app/src/userConfig/entry.js index ed73c57..2c96b53 100644 --- a/packages/plugin-react-app/src/userConfig/entry.js +++ b/packages/plugin-react-app/src/userConfig/entry.js @@ -11,10 +11,21 @@ const resolveEntryPath = (entry, rootDir) => { return ''; }; +const addHotDevClient = (entry) => { + const webpackDevClientEntry = require.resolve('react-dev-utils/webpackHotDevClient'); + const hotEntries = {}; + + Object.keys(entry).forEach((key) => { + hotEntries[key] = [webpackDevClientEntry, ...entry[key]]; + }); + + return hotEntries; +}; + // entry: string | array // entry : { [name]: string | array } module.exports = (config, value, context) => { - const { rootDir, command, userConfig } = context; + const { rootDir, command, userConfig, commandArgs } = context; const ignoreHtmlTemplate = command === 'build' && userConfig.ignoreHtmlTemplate; let entry; if (Array.isArray(value) || typeof value === 'string') { @@ -73,6 +84,10 @@ module.exports = (config, value, context) => { }]]); } + // add webpackHotDevClient when execute command is start and enable HMR + if (!commandArgs.disableReload && command === 'start') { + entry = addHotDevClient(entry); + } // remove default entry then add new enrty to webpack config config.entryPoints.clear(); config.merge({ entry }); From 1c2d80a1e805e8e19ebba10f110c43aae9917bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=96=87=E6=B6=9B?= Date: Fri, 24 Apr 2020 10:19:43 +0800 Subject: [PATCH 03/23] feat: useRequest support fn (#268) --- .../src/components/Fetch/index.tsx | 12 +++++- .../src/pages/Home/components/User/index.tsx | 4 +- examples/basic-spa/src/config.ts | 2 +- packages/plugin-request/request/useRequest.ts | 39 ++++++++++++++----- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/examples/basic-service/src/components/Fetch/index.tsx b/examples/basic-service/src/components/Fetch/index.tsx index cf6de85..6ae2f5b 100644 --- a/examples/basic-service/src/components/Fetch/index.tsx +++ b/examples/basic-service/src/components/Fetch/index.tsx @@ -1,16 +1,26 @@ import * as React from 'react'; +import { useRequest } from 'ice'; import todoService from '@/services/todo'; const Fetch = () => { + const { request, response, loading, error } = useRequest(todoService.getAll); + async function handleRequest() { const data = await todoService.getAll(); console.log('getAllResult', data); } + React.useEffect(() => { + request(); + // eslint-disable-next-line + }, []); + + console.log(response, loading, error); + return (
); diff --git a/examples/basic-service/src/pages/Home/components/User/index.tsx b/examples/basic-service/src/pages/Home/components/User/index.tsx index ccafe60..dc05441 100644 --- a/examples/basic-service/src/pages/Home/components/User/index.tsx +++ b/examples/basic-service/src/pages/Home/components/User/index.tsx @@ -13,11 +13,11 @@ const User = () => { console.log('getUser-data', data); console.log({...localService.getUser}); } - + return (
); diff --git a/examples/basic-service/src/pages/Home/components/User/index.tsx b/examples/basic-service/src/pages/Home/components/User/index.tsx index dc05441..ccafe60 100644 --- a/examples/basic-service/src/pages/Home/components/User/index.tsx +++ b/examples/basic-service/src/pages/Home/components/User/index.tsx @@ -13,11 +13,11 @@ const User = () => { console.log('getUser-data', data); console.log({...localService.getUser}); } - + return (