@modern-js/plugin-garfish 1.4.4 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/js/modern/cli/index.js +5 -3
- package/dist/js/modern/runtime/utils/apps.js +3 -2
- package/dist/js/modern/util.js +3 -0
- package/dist/js/node/cli/index.js +5 -3
- package/dist/js/node/runtime/utils/apps.js +3 -2
- package/dist/js/node/util.js +3 -0
- package/dist/js/treeshaking/cli/index.js +5 -3
- package/dist/js/treeshaking/runtime/utils/apps.js +4 -3
- package/dist/js/treeshaking/util.js +3 -0
- package/dist/types/runtime/useModuleApps.d.ts +3 -2
- package/dist/types/runtime/utils/apps.d.ts +2 -2
- package/dist/types/util.d.ts +3 -0
- package/jest.config.js +0 -1
- package/package.json +12 -11
- package/tests/__snapshots__/cli.test.tsx.snap +0 -10
- package/tests/cli.test.tsx +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 1.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 17d0cc46: feat: prebundle lodash to @modern-js/utils/lodash
|
|
8
|
+
- Updated dependencies [485375ae]
|
|
9
|
+
- Updated dependencies [77ff9754]
|
|
10
|
+
- Updated dependencies [d2d1d6b2]
|
|
11
|
+
- Updated dependencies [07a4887e]
|
|
12
|
+
- Updated dependencies [ea2ae711]
|
|
13
|
+
- Updated dependencies [17d0cc46]
|
|
14
|
+
- Updated dependencies [d2d1d6b2]
|
|
15
|
+
- @modern-js/plugin-router@1.2.9
|
|
16
|
+
- @modern-js/runtime-core@1.4.1
|
|
17
|
+
- @modern-js/utils@1.4.0
|
|
18
|
+
|
|
19
|
+
## 1.4.5
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- bebb39b6: chore: improve devDependencies and peerDependencies
|
|
24
|
+
- 8491b6dd: fix: optimise "types" exports from plugin
|
|
25
|
+
- Updated dependencies [bebb39b6]
|
|
26
|
+
- Updated dependencies [132f7b53]
|
|
27
|
+
- Updated dependencies [c4a7e4a3]
|
|
28
|
+
- @modern-js/plugin-router@1.2.8
|
|
29
|
+
- @modern-js/utils@1.3.7
|
|
30
|
+
|
|
3
31
|
## 1.4.4
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -71,6 +71,11 @@ export default (({
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
tools: {
|
|
74
|
+
devServer: {
|
|
75
|
+
headers: {
|
|
76
|
+
'Access-Control-Allow-Origin': '*'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
74
79
|
webpack: (webpackConfig, {
|
|
75
80
|
chain,
|
|
76
81
|
webpack,
|
|
@@ -82,9 +87,6 @@ export default (({
|
|
|
82
87
|
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
83
88
|
|
|
84
89
|
chain.output.libraryTarget('umd');
|
|
85
|
-
chain.devServer.headers({
|
|
86
|
-
'Access-Control-Allow-Origin': '*'
|
|
87
|
-
});
|
|
88
90
|
|
|
89
91
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
90
92
|
chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
|
|
@@ -37,6 +37,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
37
37
|
appInstance: null,
|
|
38
38
|
domId: generateSubAppContainerKey(appInfo)
|
|
39
39
|
};
|
|
40
|
+
this.unregisterHistoryListener = void 0;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -114,7 +115,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
114
115
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
history === null || history === void 0 ? void 0 : history.listen(() => {
|
|
118
|
+
this.unregisterHistoryListener = history === null || history === void 0 ? void 0 : history.listen(() => {
|
|
118
119
|
if (locationHref !== history.location.pathname) {
|
|
119
120
|
locationHref = history.location.pathname;
|
|
120
121
|
const popStateEvent = new PopStateEvent('popstate');
|
|
@@ -134,9 +135,9 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
134
135
|
const {
|
|
135
136
|
appInstance
|
|
136
137
|
} = this.state;
|
|
138
|
+
this.unregisterHistoryListener();
|
|
137
139
|
|
|
138
140
|
if (appInstance) {
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
140
141
|
const {
|
|
141
142
|
appInfo
|
|
142
143
|
} = appInstance;
|
package/dist/js/modern/util.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
3
|
+
*/
|
|
1
4
|
import createDebug from 'debug';
|
|
2
5
|
export const logger = createDebug('modern-js:plugin-garfish');
|
|
3
6
|
export const SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
@@ -86,6 +86,11 @@ var _default = ({
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
tools: {
|
|
89
|
+
devServer: {
|
|
90
|
+
headers: {
|
|
91
|
+
'Access-Control-Allow-Origin': '*'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
89
94
|
webpack: (webpackConfig, {
|
|
90
95
|
chain,
|
|
91
96
|
webpack,
|
|
@@ -97,9 +102,6 @@ var _default = ({
|
|
|
97
102
|
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
98
103
|
|
|
99
104
|
chain.output.libraryTarget('umd');
|
|
100
|
-
chain.devServer.headers({
|
|
101
|
-
'Access-Control-Allow-Origin': '*'
|
|
102
|
-
});
|
|
103
105
|
|
|
104
106
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
105
107
|
chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
|
|
@@ -43,6 +43,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
43
43
|
appInstance: null,
|
|
44
44
|
domId: (0, _util.generateSubAppContainerKey)(appInfo)
|
|
45
45
|
};
|
|
46
|
+
this.unregisterHistoryListener = void 0;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -120,7 +121,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
120
121
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
history === null || history === void 0 ? void 0 : history.listen(() => {
|
|
124
|
+
this.unregisterHistoryListener = history === null || history === void 0 ? void 0 : history.listen(() => {
|
|
124
125
|
if (locationHref !== history.location.pathname) {
|
|
125
126
|
locationHref = history.location.pathname;
|
|
126
127
|
const popStateEvent = new PopStateEvent('popstate');
|
|
@@ -140,9 +141,9 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
140
141
|
const {
|
|
141
142
|
appInstance
|
|
142
143
|
} = this.state;
|
|
144
|
+
this.unregisterHistoryListener();
|
|
143
145
|
|
|
144
146
|
if (appInstance) {
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
146
147
|
const {
|
|
147
148
|
appInfo
|
|
148
149
|
} = appInstance;
|
package/dist/js/node/util.js
CHANGED
|
@@ -11,6 +11,9 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
16
|
+
*/
|
|
14
17
|
const logger = (0, _debug.default)('modern-js:plugin-garfish');
|
|
15
18
|
exports.logger = logger;
|
|
16
19
|
const SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
@@ -94,6 +94,11 @@ export default (function () {
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
tools: {
|
|
97
|
+
devServer: {
|
|
98
|
+
headers: {
|
|
99
|
+
'Access-Control-Allow-Origin': '*'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
97
102
|
webpack: function webpack(webpackConfig, _ref3) {
|
|
98
103
|
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
99
104
|
|
|
@@ -106,9 +111,6 @@ export default (function () {
|
|
|
106
111
|
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
107
112
|
|
|
108
113
|
chain.output.libraryTarget('umd');
|
|
109
|
-
chain.devServer.headers({
|
|
110
|
-
'Access-Control-Allow-Origin': '*'
|
|
111
|
-
});
|
|
112
114
|
|
|
113
115
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
114
116
|
chain.output.publicPath(env === 'development' ? "//localhost:".concat(resolveOptions.server.port, "/") : webpackConfig.output.publicPath);
|
|
@@ -76,6 +76,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
76
76
|
appInstance: null,
|
|
77
77
|
domId: generateSubAppContainerKey(appInfo)
|
|
78
78
|
};
|
|
79
|
+
_this.unregisterHistoryListener = void 0;
|
|
79
80
|
return _this;
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -174,7 +175,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
174
175
|
return appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount();
|
|
175
176
|
|
|
176
177
|
case 22:
|
|
177
|
-
history === null || history === void 0 ? void 0 : history.listen(function () {
|
|
178
|
+
this.unregisterHistoryListener = history === null || history === void 0 ? void 0 : history.listen(function () {
|
|
178
179
|
if (locationHref !== history.location.pathname) {
|
|
179
180
|
locationHref = history.location.pathname;
|
|
180
181
|
var popStateEvent = new PopStateEvent('popstate');
|
|
@@ -218,9 +219,9 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
218
219
|
switch (_context2.prev = _context2.next) {
|
|
219
220
|
case 0:
|
|
220
221
|
appInstance = this.state.appInstance;
|
|
222
|
+
this.unregisterHistoryListener();
|
|
221
223
|
|
|
222
224
|
if (appInstance) {
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
224
225
|
_appInfo = appInstance.appInfo;
|
|
225
226
|
|
|
226
227
|
if (_appInfo.cache) {
|
|
@@ -232,7 +233,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
case
|
|
236
|
+
case 3:
|
|
236
237
|
case "end":
|
|
237
238
|
return _context2.stop();
|
|
238
239
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
3
|
+
*/
|
|
1
4
|
import createDebug from 'debug';
|
|
2
5
|
export var logger = createDebug('modern-js:plugin-garfish');
|
|
3
6
|
export var SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
@@ -28,10 +28,11 @@ export declare type ModernGarfishConfig = {
|
|
|
28
28
|
};
|
|
29
29
|
export declare type MicroComponentProps = {
|
|
30
30
|
loadable?: LoadableConfig;
|
|
31
|
+
[index: string]: any;
|
|
31
32
|
};
|
|
32
33
|
export declare type Config = Partial<Options> & ModernGarfishConfig;
|
|
33
|
-
export declare type UseModuleApps = { [index in 'apps' | string]: index extends 'apps' ? ModulesInfo : React.FC<
|
|
34
|
-
readonly MApp: React.FC<
|
|
34
|
+
export declare type UseModuleApps = { [index in 'apps' | string]: index extends 'apps' ? ModulesInfo : React.FC<MicroComponentProps> } & {
|
|
35
|
+
readonly MApp: React.FC<MicroComponentProps>;
|
|
35
36
|
readonly apps: ModulesInfo;
|
|
36
37
|
};
|
|
37
38
|
export declare function useModuleApps(): UseModuleApps;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Garfish from 'garfish';
|
|
3
|
-
import { Manifest, ModulesInfo } from '../useModuleApps';
|
|
3
|
+
import { Manifest, MicroComponentProps, ModulesInfo } from '../useModuleApps';
|
|
4
4
|
export interface AppMap {
|
|
5
|
-
[key: string]: React.FC<
|
|
5
|
+
[key: string]: React.FC<MicroComponentProps>;
|
|
6
6
|
}
|
|
7
7
|
export declare function generateApps(options: typeof Garfish.options, manifest?: Manifest): {
|
|
8
8
|
apps: AppMap;
|
package/dist/types/util.d.ts
CHANGED
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.7",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"typesVersions": {
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
],
|
|
25
25
|
"runtime": [
|
|
26
26
|
"./dist/types/runtime/index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"types": [
|
|
29
|
+
"./type.d.ts"
|
|
27
30
|
]
|
|
28
31
|
}
|
|
29
32
|
},
|
|
@@ -31,6 +34,7 @@
|
|
|
31
34
|
"module": "./dist/js/treeshaking/runtime/index.js",
|
|
32
35
|
"jsnext:modern": "./dist/js/modern/index.js",
|
|
33
36
|
"exports": {
|
|
37
|
+
"./types": "./type.d.ts",
|
|
34
38
|
".": {
|
|
35
39
|
"node": {
|
|
36
40
|
"jsnext:source": "./src/index.ts",
|
|
@@ -46,20 +50,19 @@
|
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
52
|
"@babel/runtime": "^7",
|
|
49
|
-
"@modern-js/utils": "^1.
|
|
53
|
+
"@modern-js/utils": "^1.4.1",
|
|
50
54
|
"@types/debug": "^4.1.7",
|
|
51
55
|
"@types/react-loadable": "^5.5.6",
|
|
52
56
|
"debug": "^4.3.2",
|
|
53
57
|
"garfish": "^1.3.3",
|
|
54
58
|
"hoist-non-react-statics": "^3.3.2",
|
|
55
|
-
"lodash": "^4.17.21",
|
|
56
59
|
"react-loadable": "^5.5.0"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
|
-
"@modern-js/core": "
|
|
60
|
-
"@modern-js/plugin-router": "^1.2.
|
|
61
|
-
"@modern-js/runtime-core": "
|
|
62
|
-
"@modern-js/types": "^1.
|
|
62
|
+
"@modern-js/core": "1.7.1",
|
|
63
|
+
"@modern-js/plugin-router": "^1.2.9",
|
|
64
|
+
"@modern-js/runtime-core": "1.4.1",
|
|
65
|
+
"@modern-js/types": "^1.4.0",
|
|
63
66
|
"@scripts/build": "0.0.0",
|
|
64
67
|
"@scripts/jest-config": "0.0.0",
|
|
65
68
|
"@testing-library/jest-dom": "^5.16.1",
|
|
@@ -68,7 +71,6 @@
|
|
|
68
71
|
"@testing-library/user-event": "^13.5.0",
|
|
69
72
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
70
73
|
"@types/jest": "^26.0.24",
|
|
71
|
-
"@types/lodash": "^4.14.181",
|
|
72
74
|
"@types/node": "^14",
|
|
73
75
|
"@types/react": "^17",
|
|
74
76
|
"@types/react-dom": "^17",
|
|
@@ -81,9 +83,8 @@
|
|
|
81
83
|
"webpack-chain": "^6.5.1"
|
|
82
84
|
},
|
|
83
85
|
"peerDependencies": {
|
|
84
|
-
"@modern-js/plugin-router": "^1.2.
|
|
85
|
-
"@modern-js/runtime-core": "^1.4.
|
|
86
|
-
"@modern-js/core": "^1.6.0",
|
|
86
|
+
"@modern-js/plugin-router": "^1.2.9",
|
|
87
|
+
"@modern-js/runtime-core": "^1.4.1",
|
|
87
88
|
"react": "^17"
|
|
88
89
|
},
|
|
89
90
|
"sideEffects": false,
|
|
@@ -51,11 +51,6 @@ Object {
|
|
|
51
51
|
|
|
52
52
|
exports[`plugin-garfish cli webpack config close external and use js entry 1`] = `
|
|
53
53
|
Object {
|
|
54
|
-
"devServer": Object {
|
|
55
|
-
"headers": Object {
|
|
56
|
-
"Access-Control-Allow-Origin": "*",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
54
|
"externals": Object {
|
|
60
55
|
"react": "react",
|
|
61
56
|
"react-dom": "react-dom",
|
|
@@ -76,11 +71,6 @@ Object {
|
|
|
76
71
|
|
|
77
72
|
exports[`plugin-garfish cli webpack config default micro config 1`] = `
|
|
78
73
|
Object {
|
|
79
|
-
"devServer": Object {
|
|
80
|
-
"headers": Object {
|
|
81
|
-
"Access-Control-Allow-Origin": "*",
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
74
|
"output": Object {
|
|
85
75
|
"libraryTarget": "umd",
|
|
86
76
|
"publicPath": "//localhost:8080/",
|
package/tests/cli.test.tsx
CHANGED
|
@@ -207,6 +207,12 @@ describe('plugin-garfish cli', () => {
|
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
const generateConfig = webpackConfig.toConfig();
|
|
210
|
+
expect(config[0].tools.devServer).toMatchObject({
|
|
211
|
+
headers: {
|
|
212
|
+
'Access-Control-Allow-Origin': '*',
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
210
216
|
expect(generateConfig).toMatchSnapshot();
|
|
211
217
|
expect(generateConfig).toMatchObject({
|
|
212
218
|
output: {
|
|
@@ -231,7 +237,7 @@ describe('plugin-garfish cli', () => {
|
|
|
231
237
|
internalDirectory: 'test'
|
|
232
238
|
}),
|
|
233
239
|
} as any);
|
|
234
|
-
|
|
240
|
+
|
|
235
241
|
lifecycle && lifecycle.config();
|
|
236
242
|
lifecycle && lifecycle.addRuntimeExports()
|
|
237
243
|
expect(addExportList).toMatchSnapshot();
|