@modern-js/plugin-garfish 1.4.6 → 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/dist/js/modern/cli/index.js +5 -3
- package/dist/js/modern/runtime/utils/apps.js +3 -1
- package/dist/js/modern/util.js +5 -2
- package/dist/js/node/cli/index.js +5 -3
- package/dist/js/node/runtime/utils/apps.js +3 -1
- package/dist/js/node/util.js +7 -2
- package/dist/js/treeshaking/cli/index.js +5 -3
- package/dist/js/treeshaking/runtime/utils/apps.js +4 -2
- package/dist/js/treeshaking/util.js +5 -2
- 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 +5 -1
- package/package.json +5 -3
- package/tests/__snapshots__/cli.test.tsx.snap +0 -10
- package/tests/cli.test.tsx +7 -1
|
@@ -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,6 +135,7 @@ 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
141
|
const {
|
package/dist/js/modern/util.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
3
|
+
*/
|
|
4
|
+
import createDebug from 'debug';
|
|
5
|
+
export const logger = createDebug('modern-js:plugin-garfish');
|
|
3
6
|
export const SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
4
7
|
export function generateSubAppContainerKey(moduleInfo) {
|
|
5
8
|
return moduleInfo ? `modern_sub_app_container_${decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)}` : 'modern_sub_app_container';
|
|
@@ -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,6 +141,7 @@ 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
147
|
const {
|
package/dist/js/node/util.js
CHANGED
|
@@ -7,9 +7,14 @@ exports.SUBMODULE_APP_COMPONENT_KEY = void 0;
|
|
|
7
7
|
exports.generateSubAppContainerKey = generateSubAppContainerKey;
|
|
8
8
|
exports.logger = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
16
|
+
*/
|
|
17
|
+
const logger = (0, _debug.default)('modern-js:plugin-garfish');
|
|
13
18
|
exports.logger = logger;
|
|
14
19
|
const SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
15
20
|
exports.SUBMODULE_APP_COMPONENT_KEY = SUBMODULE_APP_COMPONENT_KEY;
|
|
@@ -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,6 +219,7 @@ 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
225
|
_appInfo = appInstance.appInfo;
|
|
@@ -231,7 +233,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
case
|
|
236
|
+
case 3:
|
|
235
237
|
case "end":
|
|
236
238
|
return _context2.stop();
|
|
237
239
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
3
|
+
*/
|
|
4
|
+
import createDebug from 'debug';
|
|
5
|
+
export var logger = createDebug('modern-js:plugin-garfish');
|
|
3
6
|
export var SUBMODULE_APP_COMPONENT_KEY = 'SubModuleComponent';
|
|
4
7
|
export function generateSubAppContainerKey(moduleInfo) {
|
|
5
8
|
return moduleInfo ? "modern_sub_app_container_".concat(decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)) : 'modern_sub_app_container';
|
|
@@ -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
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tips: this package will be bundled and running in the browser, do not import from `@modern-js/utils`.
|
|
3
|
+
*/
|
|
4
|
+
import createDebug from 'debug';
|
|
1
5
|
import { ModuleInfo } from './runtime';
|
|
2
|
-
export declare const logger:
|
|
6
|
+
export declare const logger: createDebug.Debugger;
|
|
3
7
|
export declare const SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
|
|
4
8
|
export declare function generateSubAppContainerKey(moduleInfo?: ModuleInfo): string;
|
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": {
|
|
@@ -50,14 +50,16 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@babel/runtime": "^7",
|
|
53
|
-
"@modern-js/utils": "^1.4.
|
|
53
|
+
"@modern-js/utils": "^1.4.1",
|
|
54
|
+
"@types/debug": "^4.1.7",
|
|
54
55
|
"@types/react-loadable": "^5.5.6",
|
|
56
|
+
"debug": "^4.3.2",
|
|
55
57
|
"garfish": "^1.3.3",
|
|
56
58
|
"hoist-non-react-statics": "^3.3.2",
|
|
57
59
|
"react-loadable": "^5.5.0"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@modern-js/core": "1.7.
|
|
62
|
+
"@modern-js/core": "1.7.1",
|
|
61
63
|
"@modern-js/plugin-router": "^1.2.9",
|
|
62
64
|
"@modern-js/runtime-core": "1.4.1",
|
|
63
65
|
"@modern-js/types": "^1.4.0",
|
|
@@ -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();
|