diff --git a/README.md b/README.md index f23d225..d091f4f 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,9 @@ Finally, To start developing your application run `npm run start`. The applicati - [hello-world](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/hello-world) - [basic-spa](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-spa) -- [basic-store](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-store) +- [basic-ssr](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-ssr) - [basic-mpa](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-mpa) +- [basic-store](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-store) - [basic-request](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-request) - [icestark-child](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/icestark-child) - [icestark-layout](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/icestark-layout) diff --git a/README_zh-CN.md b/README_zh-CN.md index 831cd42..640cb05 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -106,8 +106,9 @@ createApp(appConfig) - [hello-world](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/hello-world) - [basic-spa](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-spa) -- [basic-store](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-store) +- [basic-ssr](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-ssr) - [basic-mpa](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-mpa) +- [basic-store](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-store) - [basic-request](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/basic-request) - [icestark-child](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/icestark-child) - [icestark-layout](https://codesandbox.io/s/github/ice-lab/icejs/tree/master/examples/icestark-layout) diff --git a/examples/basic-mpa/public/dashboard.html b/examples/basic-mpa/public/dashboard.html index 2d54236..d852647 100644 --- a/examples/basic-mpa/public/dashboard.html +++ b/examples/basic-mpa/public/dashboard.html @@ -4,7 +4,7 @@ - mpa-dashboard + icejs · mpa example diff --git a/examples/basic-mpa/public/index.html b/examples/basic-mpa/public/index.html index 407c28d..cff2166 100644 --- a/examples/basic-mpa/public/index.html +++ b/examples/basic-mpa/public/index.html @@ -4,7 +4,7 @@ - mpa-index + icejs · mpa example diff --git a/examples/basic-request/public/index.html b/examples/basic-request/public/index.html index 990d51e..30c8e82 100644 --- a/examples/basic-request/public/index.html +++ b/examples/basic-request/public/index.html @@ -4,7 +4,7 @@ - icejs simple app + icejs · request example diff --git a/examples/basic-spa/public/index.html b/examples/basic-spa/public/index.html index 754b5bb..5a294f0 100644 --- a/examples/basic-spa/public/index.html +++ b/examples/basic-spa/public/index.html @@ -4,7 +4,7 @@ - Lite + icejs · spa example diff --git a/examples/hello-world/public/index.html b/examples/hello-world/public/index.html index 990d51e..c8f794b 100644 --- a/examples/hello-world/public/index.html +++ b/examples/hello-world/public/index.html @@ -4,7 +4,7 @@ - icejs simple app + icejs · hello world example diff --git a/examples/icestark-child/public/index.html b/examples/icestark-child/public/index.html index 754b5bb..d57234d 100644 --- a/examples/icestark-child/public/index.html +++ b/examples/icestark-child/public/index.html @@ -4,7 +4,7 @@ - Lite + icejs · icestark child example diff --git a/examples/icestark-layout/public/index.html b/examples/icestark-layout/public/index.html index 754b5bb..10974f9 100644 --- a/examples/icestark-layout/public/index.html +++ b/examples/icestark-layout/public/index.html @@ -4,7 +4,7 @@ - Lite + icejs · icestark layout example diff --git a/examples/with-fusion-design/public/index.html b/examples/with-fusion-design/public/index.html index c20937f..76feb34 100644 --- a/examples/with-fusion-design/public/index.html +++ b/examples/with-fusion-design/public/index.html @@ -4,7 +4,7 @@ - Scaffold Lite + icejs · with fusion design example diff --git a/examples/with-rematch/public/index.html b/examples/with-rematch/public/index.html index 754b5bb..0e84f03 100644 --- a/examples/with-rematch/public/index.html +++ b/examples/with-rematch/public/index.html @@ -4,7 +4,7 @@ - Lite + icejs · with rematch example diff --git a/lerna.json b/lerna.json index 0b89b45..ff32545 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.1.4", + "version": "1.1.5", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/create-ice/package.json b/packages/create-ice/package.json index 9202f77..6889bf2 100644 --- a/packages/create-ice/package.json +++ b/packages/create-ice/package.json @@ -1,6 +1,6 @@ { "name": "create-ice", - "version": "1.1.4", + "version": "1.1.5", "description": "npm init ice", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 11392d7..8f61519 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -1,6 +1,6 @@ { "name": "ice.js", - "version": "1.1.4", + "version": "1.1.5", "description": "command line interface and builtin plugin for icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", @@ -21,16 +21,16 @@ }, "dependencies": { "@alib/build-scripts": "^0.1.13", - "build-plugin-ice-config": "1.1.4", - "build-plugin-ice-core": "1.1.4", - "build-plugin-ice-helpers": "1.1.4", - "build-plugin-ice-logger": "1.1.4", - "build-plugin-ice-mpa": "1.1.4", - "build-plugin-ice-request": "1.1.4", - "build-plugin-ice-router": "1.1.4", - "build-plugin-ice-ssr": "1.1.4", - "build-plugin-ice-store": "1.1.4", - "build-plugin-react-app": "1.1.4", + "build-plugin-ice-config": "1.1.5", + "build-plugin-ice-core": "1.1.5", + "build-plugin-ice-helpers": "1.1.5", + "build-plugin-ice-logger": "1.1.5", + "build-plugin-ice-mpa": "1.1.5", + "build-plugin-ice-request": "1.1.5", + "build-plugin-ice-router": "1.1.5", + "build-plugin-ice-ssr": "1.1.5", + "build-plugin-ice-store": "1.1.5", + "build-plugin-react-app": "1.1.5", "inquirer": "^7.1.0" }, "engines": { diff --git a/packages/plugin-config/package.json b/packages/plugin-config/package.json index b33a044..daf27f5 100644 --- a/packages/plugin-config/package.json +++ b/packages/plugin-config/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-config", - "version": "1.1.4", + "version": "1.1.5", "description": "Define application config in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-core/package.json b/packages/plugin-core/package.json index 23b0853..029cb7e 100644 --- a/packages/plugin-core/package.json +++ b/packages/plugin-core/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-core", - "version": "1.1.4", + "version": "1.1.5", "description": "the core plugin for icejs.", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-helpers/package.json b/packages/plugin-helpers/package.json index cdf36c9..948ac52 100644 --- a/packages/plugin-helpers/package.json +++ b/packages/plugin-helpers/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-helpers", - "version": "1.1.4", + "version": "1.1.5", "description": "builtin helpers in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-icestark/package.json b/packages/plugin-icestark/package.json index 65ad455..3e42630 100644 --- a/packages/plugin-icestark/package.json +++ b/packages/plugin-icestark/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-icestark", - "version": "1.1.4", + "version": "1.1.5", "description": "Easy use `icestark` in icejs.", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-icestark/src/module.tsx b/packages/plugin-icestark/src/module.tsx index cf625eb..2ee127a 100644 --- a/packages/plugin-icestark/src/module.tsx +++ b/packages/plugin-icestark/src/module.tsx @@ -8,7 +8,8 @@ import { registerAppLeave, getBasename, } from '@ice/stark-app'; -import { Router } from '$ice/Router'; +import { IceRouter } from '$ice/Router'; +import { createHashHistory, createBrowserHistory } from '$ice/history'; import DefaultLayout from '$ice/Layout'; import removeRootLayout from './runtime/removeLayout'; import { IIceStark } from './types'; @@ -19,10 +20,13 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => { const { icestark, router } = appConfig; const { type: appType } = (icestark || {}) as IIceStark; const { type, basename, modifyRoutes: runtimeModifyRoutes } = router; + if (runtimeModifyRoutes) { modifyRoutes(runtimeModifyRoutes); } if (appType === 'child') { + const history = createHistory(type, getBasename()); + addDOMRender(({ App, appMountNode }) => { return new Promise(resolve => { if (isInIcestark()) { @@ -42,13 +46,15 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => { setRenderRouter((routes) => () => { const routerProps = { type, - basename: getBasename(), routes, + basename: getBasename(), + history }; - return ; + return ; }); } else if (appType === 'framework') { const { getApps, appRouter, Layout, AppRoute: CustomAppRoute, removeRoutesLayout } = (icestark || {}) as IIceStark; + const history = createHistory(type, basename); if (removeRoutesLayout) { modifyRoutes(removeRootLayout); } @@ -60,8 +66,9 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => { const [apps, setApps] = useState(null); const routerProps = { type, - basename, routes, + basename, + history }; const BasicLayout = Layout || DefaultLayout; const RenderAppRoute = CustomAppRoute || AppRoute; @@ -113,7 +120,9 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => { {routes && routes.length && ( } + render={() => { + return ; + }} /> )} @@ -125,4 +134,12 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => { } }; +function createHistory(type: string, basename: string) { + const histories = { + hash: createHashHistory, + browser: createBrowserHistory, + }; + return histories[type]({basename}); +} + export default module; diff --git a/packages/plugin-icestark/src/runtime/_Router.tsx b/packages/plugin-icestark/src/runtime/_Router.tsx index 2f8fb1e..e219dcc 100644 --- a/packages/plugin-icestark/src/runtime/_Router.tsx +++ b/packages/plugin-icestark/src/runtime/_Router.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; // eslint-disable-next-line -const Router = ({ type, routes, basename }) => { +const IceRouter = ({ type, routes, basename, history }) => { return (
); }; -export { Router }; +export { IceRouter }; diff --git a/packages/plugin-icestark/src/runtime/_history.ts b/packages/plugin-icestark/src/runtime/_history.ts new file mode 100644 index 0000000..d1f2caa --- /dev/null +++ b/packages/plugin-icestark/src/runtime/_history.ts @@ -0,0 +1,6 @@ +export { + createBrowserHistory, + createHashHistory, + createMemoryHistory, + History +} from 'history'; diff --git a/packages/plugin-icestark/tsconfig.json b/packages/plugin-icestark/tsconfig.json index 212de8f..ec300aa 100644 --- a/packages/plugin-icestark/tsconfig.json +++ b/packages/plugin-icestark/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "lib", "paths": { "$ice/Router": ["./src/runtime/_Router"], + "$ice/history": ["./src/runtime/_history"], "$ice/Layout": ["./src/runtime/Layout"] } } -} \ No newline at end of file +} diff --git a/packages/plugin-logger/package.json b/packages/plugin-logger/package.json index cdd8ad0..7d37e4b 100644 --- a/packages/plugin-logger/package.json +++ b/packages/plugin-logger/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-logger", - "version": "1.1.4", + "version": "1.1.5", "description": "builtin logger in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-mpa/package.json b/packages/plugin-mpa/package.json index be9b3e9..b7eb5d0 100644 --- a/packages/plugin-mpa/package.json +++ b/packages/plugin-mpa/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-mpa", - "version": "1.1.4", + "version": "1.1.5", "description": "enable mpa project for icejs framework", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-react-app/package.json b/packages/plugin-react-app/package.json index 50ca99a..9e7c61a 100644 --- a/packages/plugin-react-app/package.json +++ b/packages/plugin-react-app/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-react-app", - "version": "1.1.4", + "version": "1.1.5", "description": "The basic webpack configuration for ice project", "author": "ice-admin@alibaba-inc.com", "main": "src/index.js", diff --git a/packages/plugin-react-app/src/utils/babelPluginCorejsLock.js b/packages/plugin-react-app/src/utils/babelPluginCorejsLock.js index 85792f4..2422e43 100644 --- a/packages/plugin-react-app/src/utils/babelPluginCorejsLock.js +++ b/packages/plugin-react-app/src/utils/babelPluginCorejsLock.js @@ -12,7 +12,8 @@ module.exports = ({ types }, { fileList }) => { }); if (entryFile) { const { node } = nodePath; - if (node.source.value.startsWith('core-js/')) { + // only replace core-js/modules/xxx added by @babel/preset-env + if (node.source.value.startsWith('core-js/modules')) { node.source.value = node.source.value.replace('core-js/', `${coreJSPath}/`); } } diff --git a/packages/plugin-rematch/package.json b/packages/plugin-rematch/package.json index 58f2f31..466649b 100644 --- a/packages/plugin-rematch/package.json +++ b/packages/plugin-rematch/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-rematch", - "version": "1.1.4", + "version": "1.1.5", "description": "Easy use `rematch` in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-request/package.json b/packages/plugin-request/package.json index b6d348c..d448997 100644 --- a/packages/plugin-request/package.json +++ b/packages/plugin-request/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-request", - "version": "1.1.4", + "version": "1.1.5", "description": "request for build-plugin-ice-request", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-router/package.json b/packages/plugin-router/package.json index 52a16fe..1f571c4 100644 --- a/packages/plugin-router/package.json +++ b/packages/plugin-router/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-router", - "version": "1.1.4", + "version": "1.1.5", "description": "build-plugin-ice-router", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-ssr/package.json b/packages/plugin-ssr/package.json index 2085a0c..d8ebc53 100644 --- a/packages/plugin-ssr/package.json +++ b/packages/plugin-ssr/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-ssr", - "version": "1.1.4", + "version": "1.1.5", "description": "ssr plugin", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-store/package.json b/packages/plugin-store/package.json index ced52eb..9d15dc3 100644 --- a/packages/plugin-store/package.json +++ b/packages/plugin-store/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-store", - "version": "1.1.4", + "version": "1.1.5", "description": "builtin `icestore` in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "",