Skip to content

Commit 88b39bc

Browse files
authored
Release: 2.7.3 (#561)
* fix: 🐛 simply copy callable functions extra properties (#557) * fix: 🐛 append missing styles (#560) * fix: 🐛 empty value or undefined in activePath array should be ignored (#559)
1 parent 698b7b5 commit 88b39bc

File tree

23 files changed

+113
-20
lines changed

23 files changed

+113
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
See [https://github.com/ice-lab/icestark/releases](https://github.com/ice-lab/icestark/releases) for what has changed in each version of icestark.
44

5+
## 2.7.3
6+
7+
- [fix] empty value or `undefined` in `activePath` array will be ignored. ([#558](https://github.com/ice-lab/icestark/issues/558))
8+
- [fix] append missing styles in vite developing mode. ([#555](https://github.com/ice-lab/icestark/issues/555))
9+
510
## 2.7.2
611

712
- [fix] set actual basename when `activePath` is an array. ([#526](https://github.com/ice-lab/icestark/issues/526))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "icestark-monorepo",
3-
"version": "2.7.2",
3+
"version": "2.7.3",
44
"private": true,
55
"description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.",
66
"scripts": {

packages/icestark/__tests__/AppRouter.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ describe('AppRouter', () => {
121121
unmount();
122122
})
123123

124-
125124
test('app-multi-paths', async () => {
126125
(fetch as FetchMock).mockResponseOnce(umdSourceWithSetLibrary.toString());
127126
const { container, unmount } = render(

packages/icestark/__tests__/checkActive.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,17 @@ describe('checkActive', () => {
9797
// matched idx
9898
checkFnc = findActivePath(formatPath(['/test', '/seller'], {}));
9999
expect(checkFnc('/seller')).toEqual('/seller');
100+
101+
// undefined array
102+
checkFnc = findActivePath(formatPath([undefined, '/seller'], {}));
103+
expect(checkFnc('/')).toBeFalsy();
104+
105+
// nuallable array
106+
checkFnc = findActivePath(formatPath([null, '/seller'], {}));
107+
expect(checkFnc('/')).toBeFalsy();
108+
109+
// empty array
110+
checkFnc = findActivePath(formatPath(['', '/seller'], {}));
111+
expect(checkFnc('/')).toBeFalsy();
100112
})
101113
});

packages/icestark/__tests__/index.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ describe('AppRouter', () => {
149149
expect(container.innerHTML).toContain('test render b');
150150
unmount();
151151
});
152+
152153
test('test for AppRoute entry -> success', done => {
153154
window.history.pushState({}, 'test', '/fetch-entry');
154155

packages/icestark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ice/stark",
3-
"version": "2.7.2",
3+
"version": "2.7.3",
44
"description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.",
55
"scripts": {
66
"build": "rm -rf lib && tsc",

packages/icestark/src/AppRouter.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ export default class AppRouter extends React.Component<AppRouterProps, AppRouter
231231
}
232232
});
233233

234-
235234
if (match) {
236235
const { name, activePath, path } = element.props as AppRouteProps;
237236

packages/icestark/src/apps.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ async function loadApp(app: MicroApp) {
301301
}
302302
} catch (err) {
303303
configuration.onError(err);
304+
log.error(err);
304305
updateAppConfig(name, { status: LOAD_ERROR });
305306
}
306307
if (lifeCycle.mount) {
@@ -380,7 +381,15 @@ export async function createMicroApp(
380381
break;
381382
case UNMOUNTED:
382383
if (!appConfig.cached) {
383-
await loadAndAppendCssAssets(appConfig?.appAssets?.cssList || [], {
384+
const appendAssets = [
385+
...(appConfig?.appAssets?.cssList || []),
386+
// In vite development mode, styles are inserted into DOM manually.
387+
// While es module natively imported twice may never excute twice.
388+
// https://github.com/ice-lab/icestark/issues/555
389+
...(appConfig?.loadScriptMode === 'import' ? filterRemovedAssets(importCachedAssets[appConfig.name] ?? [], ['LINK', 'STYLE']) : []),
390+
];
391+
392+
await loadAndAppendCssAssets(appendAssets, {
384393
cacheCss: shouldCacheCss(appConfig.loadScriptMode),
385394
fetch,
386395
});

packages/icestark/src/util/checkActive.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pathToRegexp from 'path-to-regexp';
22
import urlParse from 'url-parse';
3-
import { isFunction, toArray, isObject, addLeadingSlash } from './helpers';
3+
import { ErrorCode, formatErrMessage } from './error';
4+
import { isFunction, toArray, isObject, addLeadingSlash, log, isDev } from './helpers';
45

56
/**
67
* "slash" - hashes like #/ and #/sunshine/lollipops
@@ -97,7 +98,18 @@ const findActivePath = (activePath?: PathData[] | ActiveFn): (url?: string) => s
9798
let matchedPath;
9899
const isActive = activePath.some((path) => {
99100
matchedPath = path?.value;
100-
return matchPath(url, path);
101+
102+
if (!matchedPath && isDev) {
103+
log.warn(
104+
formatErrMessage(
105+
ErrorCode.ACTIVE_PATH_ITEM_CAN_NOT_BE_EMPTY,
106+
`Each item of activePath must be string、object、array or a function. Received ${matchedPath?.toString()}`,
107+
),
108+
);
109+
}
110+
111+
// Escape when path is empty or undefined
112+
return matchedPath ? matchPath(url, path) : false;
101113
});
102114

103115
return isActive ? matchedPath : false;

packages/icestark/src/util/error.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum ErrorCode {
55
'CANNOT_FIND_APP' = 4,
66
'JS_LOAD_ERROR' = 5,
77
'CSS_LOAD_ERROR' = 6,
8+
'ACTIVE_PATH_ITEM_CAN_NOT_BE_EMPTY' = 7,
89
}
910

1011
export function normalizeMsg(msg: string, args: string[]) {

0 commit comments

Comments
 (0)