From be11bb2bcae3cf7caa4ea3cf19c48e420c71e7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=92=E7=8B=92=E7=A5=9E?= Date: Wed, 24 Nov 2021 11:38:42 +0800 Subject: [PATCH 1/9] fix: miniapp render (#4867) * fix: miniapp render * fix: type define --- packages/miniapp-renderer/CHANGELOG.md | 4 ++++ packages/miniapp-renderer/package.json | 4 ++-- packages/miniapp-renderer/src/miniappRenderer.tsx | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/miniapp-renderer/CHANGELOG.md b/packages/miniapp-renderer/CHANGELOG.md index 426fc7a49a..65a22790d9 100644 --- a/packages/miniapp-renderer/CHANGELOG.md +++ b/packages/miniapp-renderer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.2.1 + +- [Refactor] miniapp page component + ## 0.1.15 - [Chore] use `pageSource` as the render unique path when `route.pageSource` existed diff --git a/packages/miniapp-renderer/package.json b/packages/miniapp-renderer/package.json index 7e3dae8d16..30355b7795 100644 --- a/packages/miniapp-renderer/package.json +++ b/packages/miniapp-renderer/package.json @@ -1,6 +1,6 @@ { "name": "miniapp-renderer", - "version": "0.2.0", + "version": "0.2.1", "description": "", "author": "ice-admin@alibaba-inc.com", "homepage": "https://github.com/alibaba/ice#readme", @@ -31,4 +31,4 @@ "bugs": { "url": "https://github.com/alibaba/ice/issues" } -} \ No newline at end of file +} diff --git a/packages/miniapp-renderer/src/miniappRenderer.tsx b/packages/miniapp-renderer/src/miniappRenderer.tsx index d80b9ed840..f282c172bc 100644 --- a/packages/miniapp-renderer/src/miniappRenderer.tsx +++ b/packages/miniapp-renderer/src/miniappRenderer.tsx @@ -3,7 +3,9 @@ import { createElement, ComponentType, Component, RaxElement } from 'rax'; interface IRoute { source: string; - component: ComponentType, + component: () => ComponentType & { + __pageConfig: IRoute; + }, pageSource: string; } @@ -33,9 +35,9 @@ function miniappRenderer( path: pageSource || source, render() { // Add page config to page component - // @ts-ignore - component.__pageConfig = route; - const appInstance = mount(getRenderApp(component, runtime, { + const Page = component(); + Page.__pageConfig = route; + const appInstance = mount(getRenderApp(Page, runtime, { ErrorBoundary, ErrorBoundaryFallback, onError, From 9b16dcefad84ea5ab4a854f8cadca9fcad01ea94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=92=E7=8B=92=E7=A5=9E?= Date: Wed, 24 Nov 2021 15:05:57 +0800 Subject: [PATCH 2/9] fix: mpa tabbar render (#4957) * fix: mpa tabbar render * fix: bug --- packages/build-mpa-config/src/generate/RaxGenerator.ts | 2 +- packages/build-mpa-config/src/template/rax/TabBar.tsx.ejs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/build-mpa-config/src/generate/RaxGenerator.ts b/packages/build-mpa-config/src/generate/RaxGenerator.ts index 076525a3ef..fd013ab16c 100644 --- a/packages/build-mpa-config/src/generate/RaxGenerator.ts +++ b/packages/build-mpa-config/src/generate/RaxGenerator.ts @@ -39,7 +39,7 @@ export default class RaxGenerator extends Base { if (content.tabBar) { this.runAppRenderData.tabBarPath = content.tabBar.custom ? relative(this.entryFolder, path.join(this.rootDir, 'src/components/CustomTabBar/index')) - : relative(this.entryFolder, path.join(this.targetDir, 'plugins/rax-app/TabBar')); + : relative(this.entryFolder, path.join(this.targetDir, 'plugins/app/TabBar')); } } } diff --git a/packages/build-mpa-config/src/template/rax/TabBar.tsx.ejs b/packages/build-mpa-config/src/template/rax/TabBar.tsx.ejs index 5a6482c26f..8ceb94c383 100644 --- a/packages/build-mpa-config/src/template/rax/TabBar.tsx.ejs +++ b/packages/build-mpa-config/src/template/rax/TabBar.tsx.ejs @@ -16,8 +16,10 @@ export default class TabBarWrapper extends Component { (window as any).location.href = `./${pageName}.html`; } } + render() { - return + if (!shouldRenderTabBar) return null; + return <% if (tabBarPath.indexOf('src') > -1) {%>
} currentPageName={currentPageName} /> From 593372360f0c096efaeb360223ef2cea7a2ca7b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=92=E7=8B=92=E7=A5=9E?= Date: Wed, 24 Nov 2021 19:45:14 +0800 Subject: [PATCH 3/9] chore: add changelog of @builder/mpa-config (#4965) --- packages/build-mpa-config/CHANGELOG.md | 5 +++++ packages/build-mpa-config/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/build-mpa-config/CHANGELOG.md b/packages/build-mpa-config/CHANGELOG.md index 3efa21c277..d8e3caed69 100644 --- a/packages/build-mpa-config/CHANGELOG.md +++ b/packages/build-mpa-config/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.0.5 + +- fix: `TabBar` resolve path +- chore: remove `x-if` in `TabBar` + ## 4.0.4 - fix: every mpa page should redirect runApp file path diff --git a/packages/build-mpa-config/package.json b/packages/build-mpa-config/package.json index 3d17454378..411f5661a6 100644 --- a/packages/build-mpa-config/package.json +++ b/packages/build-mpa-config/package.json @@ -1,6 +1,6 @@ { "name": "@builder/mpa-config", - "version": "4.0.4", + "version": "4.0.5", "description": "enable mpa project for framework", "author": "ice-admin@alibaba-inc.com", "homepage": "", From 29354ecd573a24503b5835699e876895dd4e90a3 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Wed, 24 Nov 2021 19:45:34 +0800 Subject: [PATCH 4/9] fix: support config devServer.historyApiFallback (#4963) --- packages/plugin-router/CHANGELOG.md | 4 ++++ packages/plugin-router/package.json | 2 +- packages/plugin-router/src/index.ts | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/plugin-router/CHANGELOG.md b/packages/plugin-router/CHANGELOG.md index d3a9d0e37d..43b73d8089 100644 --- a/packages/plugin-router/CHANGELOG.md +++ b/packages/plugin-router/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.4 + +- [fix] support config `devSever.historyApiFallback` + ## 2.0.3 - [fix] nested router config diff --git a/packages/plugin-router/package.json b/packages/plugin-router/package.json index 6f9034322d..eb303158db 100644 --- a/packages/plugin-router/package.json +++ b/packages/plugin-router/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-router", - "version": "2.0.3", + "version": "2.0.4", "description": "build-plugin-ice-router", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-router/src/index.ts b/packages/plugin-router/src/index.ts index 27096632d5..fca0c4cb85 100644 --- a/packages/plugin-router/src/index.ts +++ b/packages/plugin-router/src/index.ts @@ -62,7 +62,9 @@ const plugin = ({ context, onGetWebpackConfig, modifyUserConfig, getValue, apply config.resolve.alias.set(routerName, path.dirname(packagePath)); // config historyApiFallback for router type browser - config.devServer.set('historyApiFallback', true); + if (!config.devServer.get('historyApiFallback')) { + config.devServer.set('historyApiFallback', true); + } }); // copy types From 78b4e1d433cfa197d0d17af20f9de515367021e0 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Wed, 24 Nov 2021 19:45:52 +0800 Subject: [PATCH 5/9] fix: compatible with disable runtime when config mpa (#4961) --- packages/icejs/package.json | 2 +- packages/plugin-mpa/CHANGELOG.md | 4 ++++ packages/plugin-mpa/package.json | 2 +- packages/plugin-mpa/src/index.ts | 20 +++++++++++--------- yarn.lock | 6 +++--- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/icejs/package.json b/packages/icejs/package.json index f8a140ca19..17c187daa1 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -29,7 +29,7 @@ "build-plugin-ice-auth": "2.0.0", "build-plugin-ice-config": "2.0.1", "build-plugin-ice-logger": "2.0.0", - "build-plugin-ice-mpa": "2.0.1", + "build-plugin-ice-mpa": "2.0.2", "build-plugin-ice-request": "2.0.0", "build-plugin-ice-router": "2.0.3", "build-plugin-ice-ssr": "3.0.3", diff --git a/packages/plugin-mpa/CHANGELOG.md b/packages/plugin-mpa/CHANGELOG.md index 22c8cc74dd..e67ec162d4 100644 --- a/packages/plugin-mpa/CHANGELOG.md +++ b/packages/plugin-mpa/CHANGELOG.md @@ -1,5 +1,9 @@ # changelog +## 2.0.2 + +- [fix] compatible with the situation when config both `disableRuntime` and `mpa` + ## 2.0.1 - [feat] support disable rewrite rules for FaaS render diff --git a/packages/plugin-mpa/package.json b/packages/plugin-mpa/package.json index 109d3de28d..8decc2766f 100644 --- a/packages/plugin-mpa/package.json +++ b/packages/plugin-mpa/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-mpa", - "version": "2.0.1", + "version": "2.0.2", "description": "enable mpa project for icejs framework", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-mpa/src/index.ts b/packages/plugin-mpa/src/index.ts index b0c4296ae2..dc5bd27384 100644 --- a/packages/plugin-mpa/src/index.ts +++ b/packages/plugin-mpa/src/index.ts @@ -100,15 +100,17 @@ const plugin: IPlugin = (api) => { } // modify entry modifyUserConfig('entry', finalMPAEntries); - applyMethod('addImportDeclaration', { - multipleSource: { - runApp: redirectEntries.map(({ entryPath, runAppPath }) => ({ - filename: entryPath, - value: runAppPath, - type: 'normal', - })), - }, - }); + if (redirectEntries.length > 0) { + applyMethod('addImportDeclaration', { + multipleSource: { + runApp: redirectEntries.map(({ entryPath, runAppPath }) => ({ + filename: entryPath, + value: runAppPath, + type: 'normal', + })), + }, + }); + } // set page template onGetWebpackConfig(config => { setPageTemplate(rootDir, entries, (mpa as any).template || {}, config, setValue); diff --git a/yarn.lock b/yarn.lock index 99818dc93b..794edc7450 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5044,9 +5044,9 @@ build-scripts-config@^3.0.0: webpack-simple-progress-plugin "0.0.4" build-scripts@^1.0.0, build-scripts@^1.0.1, build-scripts@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/build-scripts/-/build-scripts-1.2.0.tgz#9be18aa73d6a5f5111fe81043038aa75e52006a8" - integrity sha512-OkSCr4iIre4KcN8WOO46uY+mvZjmNUuonim3niMDY8jf4L117h23JATm/m0xLFxe3LJ2KXCscAKK6VKbU4I/ow== + version "1.2.1" + resolved "https://registry.yarnpkg.com/build-scripts/-/build-scripts-1.2.1.tgz#626bf4343c425124320bea0189bfdafa6501280e" + integrity sha512-qumrwcAO1SwhN23Nn98gkHCmZw+PZ4nGjQdBp2vfQSq8/rElqXBP4SlgfbX7RP0ZfRZdUXeUgfRegco48XnJ6g== dependencies: address "^1.1.0" camelcase "^5.3.1" From 4230b33771e00f7ea4f7a09e2f5ca3fe633b6006 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Wed, 24 Nov 2021 19:49:18 +0800 Subject: [PATCH 6/9] fix: match the correct pathname of mock server (#4960) --- packages/webpack-dev-mock/CHANGELOG.md | 4 ++++ packages/webpack-dev-mock/package.json | 2 +- packages/webpack-dev-mock/src/matchPath.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/webpack-dev-mock/CHANGELOG.md b/packages/webpack-dev-mock/CHANGELOG.md index 1e59c85ef6..0ebdb6307f 100644 --- a/packages/webpack-dev-mock/CHANGELOG.md +++ b/packages/webpack-dev-mock/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.3.2 + +- [fix] match the correct pathname of request + ## 1.3.1 - [fix] update dependencies diff --git a/packages/webpack-dev-mock/package.json b/packages/webpack-dev-mock/package.json index e5cfd09032..a1d7a04a7c 100644 --- a/packages/webpack-dev-mock/package.json +++ b/packages/webpack-dev-mock/package.json @@ -1,6 +1,6 @@ { "name": "webpack-dev-mock", - "version": "1.3.1", + "version": "1.3.2", "description": "Webpack devserver middleware mock server", "main": "lib/index.js", "scripts": { diff --git a/packages/webpack-dev-mock/src/matchPath.ts b/packages/webpack-dev-mock/src/matchPath.ts index 05da9a6a11..227fc876cc 100644 --- a/packages/webpack-dev-mock/src/matchPath.ts +++ b/packages/webpack-dev-mock/src/matchPath.ts @@ -20,7 +20,7 @@ function decodeParam(val) { function matchPath(req, mockConfig) { const { method: reqMethod } = req; // compatible with http server - const reqPath = req.path || req.url; + const reqPath = req?._parsedUrl?.pathname || req.path || req.url; for (let m = 0; m < mockConfig.length; m += 1) { const mock = mockConfig[m]; const { path: mockPath, method: mockMethod } = mock; From 994a34955280cb0b88c9de2caa4a4649813ebeeb Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 25 Nov 2021 10:23:03 +0800 Subject: [PATCH 7/9] fix: compatible with special chars in html (#4962) --- packages/plugin-ice-ssr/CHANGELOG.md | 4 ++++ packages/plugin-ice-ssr/package.json | 2 +- packages/plugin-ice-ssr/src/index.ts | 4 ++-- packages/plugin-ice-ssr/src/renderPages.ts.ejs | 2 +- packages/plugin-ice-ssr/src/server.ts.ejs | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/plugin-ice-ssr/CHANGELOG.md b/packages/plugin-ice-ssr/CHANGELOG.md index c58bce88aa..3bbf059f0d 100644 --- a/packages/plugin-ice-ssr/CHANGELOG.md +++ b/packages/plugin-ice-ssr/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.0.4 + +- [fix] compatible with special charts in html content + ## 3.0.3 - [fix] route path value may be undefined diff --git a/packages/plugin-ice-ssr/package.json b/packages/plugin-ice-ssr/package.json index 2b36a473f8..4434c9a5fc 100644 --- a/packages/plugin-ice-ssr/package.json +++ b/packages/plugin-ice-ssr/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-ssr", - "version": "3.0.3", + "version": "3.0.4", "description": "ssr plugin", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/plugin-ice-ssr/src/index.ts b/packages/plugin-ice-ssr/src/index.ts index e2472bdfc2..8604e6cf73 100644 --- a/packages/plugin-ice-ssr/src/index.ts +++ b/packages/plugin-ice-ssr/src/index.ts @@ -210,8 +210,8 @@ const plugin = async (api): Promise => { const htmlFilePath = path.join(buildDir, 'index.html'); const bundle = fse.readFileSync(serverFilePath, 'utf-8'); const html = fse.readFileSync(htmlFilePath, 'utf-8'); - const minifiedHtml = minify(html, { collapseWhitespace: true, quoteCharacter: '\'' }); - const newBundle = bundle.replace(/__ICE_SERVER_HTML_TEMPLATE__/, minifiedHtml); + const minifiedHtml = minify(html, { collapseWhitespace: true, quoteCharacter: '\'' }).replace(/`/g, '`'); + const newBundle = bundle.replace(/'global.__ICE_SERVER_HTML_TEMPLATE__'/, `\`${minifiedHtml}\``); fse.writeFileSync(serverFilePath, newBundle, 'utf-8'); // @deprecated diff --git a/packages/plugin-ice-ssr/src/renderPages.ts.ejs b/packages/plugin-ice-ssr/src/renderPages.ts.ejs index 664d438e61..f79279c2fb 100644 --- a/packages/plugin-ice-ssr/src/renderPages.ts.ejs +++ b/packages/plugin-ice-ssr/src/renderPages.ts.ejs @@ -9,7 +9,7 @@ export default async function ssgRender(options) { const { htmlTemplate } = options; const loadableStatsPath = join(process.cwd(), '<%- outputDir %>', 'loadable-stats.json'); const buildConfig = { loadableStatsPath }; - const htmlTemplateContent = htmlTemplate || `__ICE_SERVER_HTML_TEMPLATE__`; + const htmlTemplateContent = htmlTemplate || 'global.__ICE_SERVER_HTML_TEMPLATE__'; const pagesData = []; const flatRoutes = await getFlatRoutes(routes || []); diff --git a/packages/plugin-ice-ssr/src/server.ts.ejs b/packages/plugin-ice-ssr/src/server.ts.ejs index a564bfca25..dc85f38ab1 100644 --- a/packages/plugin-ice-ssr/src/server.ts.ejs +++ b/packages/plugin-ice-ssr/src/server.ts.ejs @@ -57,7 +57,7 @@ const serverRender = async (context: ServerContext, opts = {}) => { } const buildConfig = { loadableStatsPath, publicPath }; - const htmlTemplateContent = htmlTemplate || `__ICE_SERVER_HTML_TEMPLATE__`; + const htmlTemplateContent = htmlTemplate || 'global.__ICE_SERVER_HTML_TEMPLATE__'; // load module to run before createApp ready loadStaticModules(appConfig); From 7f91d10e576d7e215ec4df44be8bbecde453d86b Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 25 Nov 2021 12:23:29 +0800 Subject: [PATCH 8/9] chore: version (#4968) --- packages/build-mpa-config/package.json | 2 +- packages/icejs/package.json | 6 +++--- packages/miniapp-renderer/package.json | 2 +- packages/webpack-dev-mock/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/build-mpa-config/package.json b/packages/build-mpa-config/package.json index 411f5661a6..6badb6ca5b 100644 --- a/packages/build-mpa-config/package.json +++ b/packages/build-mpa-config/package.json @@ -30,4 +30,4 @@ "devDependencies": { "build-scripts": "^1.1.0" } -} +} \ No newline at end of file diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 17c187daa1..5439e79668 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -1,6 +1,6 @@ { "name": "ice.js", - "version": "2.2.2", + "version": "2.2.3", "description": "command line interface and builtin plugin for icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", @@ -31,8 +31,8 @@ "build-plugin-ice-logger": "2.0.0", "build-plugin-ice-mpa": "2.0.2", "build-plugin-ice-request": "2.0.0", - "build-plugin-ice-router": "2.0.3", - "build-plugin-ice-ssr": "3.0.3", + "build-plugin-ice-router": "2.0.4", + "build-plugin-ice-ssr": "3.0.4", "build-plugin-ice-store": "2.0.5", "build-plugin-react-app": "2.0.4", "build-plugin-pwa": "1.0.1", diff --git a/packages/miniapp-renderer/package.json b/packages/miniapp-renderer/package.json index 30355b7795..977ad2eb10 100644 --- a/packages/miniapp-renderer/package.json +++ b/packages/miniapp-renderer/package.json @@ -31,4 +31,4 @@ "bugs": { "url": "https://github.com/alibaba/ice/issues" } -} +} \ No newline at end of file diff --git a/packages/webpack-dev-mock/package.json b/packages/webpack-dev-mock/package.json index a1d7a04a7c..d494cbef81 100644 --- a/packages/webpack-dev-mock/package.json +++ b/packages/webpack-dev-mock/package.json @@ -35,4 +35,4 @@ "lib", "!lib/**/*.map" ] -} +} \ No newline at end of file From a0138298ce00798216c05a62809a0ae23d5daca3 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 25 Nov 2021 14:29:07 +0800 Subject: [PATCH 9/9] fix: re-calculate webpack cache id when config disableRuntime (#4972) --- packages/build-user-config/CHANGELOG.md | 4 ++++ packages/build-user-config/package.json | 3 ++- packages/build-user-config/src/webpack5.js | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/build-user-config/CHANGELOG.md b/packages/build-user-config/CHANGELOG.md index ccac6c62a2..f7df1a6d46 100644 --- a/packages/build-user-config/CHANGELOG.md +++ b/packages/build-user-config/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.8 + +- [fix] re-calculate webpack cache id when config `disableRuntime` + ## 1.1.7 - [fix] undefined `postcssOptions.plugins` diff --git a/packages/build-user-config/package.json b/packages/build-user-config/package.json index ce361d1b9d..b980385d38 100644 --- a/packages/build-user-config/package.json +++ b/packages/build-user-config/package.json @@ -1,6 +1,6 @@ { "name": "@builder/user-config", - "version": "1.1.7", + "version": "1.1.8", "description": "Includes methods which are releated to set base user config for framework", "homepage": "", "license": "MIT", @@ -15,6 +15,7 @@ "fs-extra": "^8.1.0", "fork-ts-checker-webpack-plugin": "^5.0.5", "loader-utils": "^2.0.0", + "object-hash": "^2.2.0", "regenerator-runtime": "^0.13.3", "react-dev-utils": "^11.0.4", "webpack-dev-mock": "^1.0.1", diff --git a/packages/build-user-config/src/webpack5.js b/packages/build-user-config/src/webpack5.js index f8442d0739..483d2d7a4d 100644 --- a/packages/build-user-config/src/webpack5.js +++ b/packages/build-user-config/src/webpack5.js @@ -1,4 +1,5 @@ const path = require('path'); +const hash = require('object-hash'); // built-in webpack 5 abilities module.exports = (config, api) => { @@ -6,7 +7,7 @@ module.exports = (config, api) => { const { userConfig, rootDir, webpack } = context; // filesystem cache if (!process.env.DISABLE_FS_CACHE) { - const version = getValue('WEBPACK_CACHE_ID'); + const version = getValue('WEBPACK_CACHE_ID') || hash(userConfig); const cacheConfig = { cache: { type: 'filesystem',