@modern-js/plugin-garfish 1.4.4-beta.2 → 1.4.4-beta.3

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.
@@ -1,3 +1,4 @@
1
+ import _merge from "lodash/merge";
1
2
  const _excluded = ["manifest"];
2
3
 
3
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
@@ -10,8 +11,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
11
 
11
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
13
 
13
- // eslint-disable-next-line filenames/match-exported
14
- import { createPlugin } from '@modern-js/runtime-core';
15
14
  import React from 'react';
16
15
  import hoistNonReactStatics from 'hoist-non-react-statics';
17
16
  import { logger } from "../util";
@@ -56,83 +55,86 @@ async function initOptions(manifest = {}, options) {
56
55
  return _objectSpread(_objectSpread({}, options), {}, {
57
56
  apps
58
57
  });
59
- }
60
-
61
- const GarfishPlugin = config => {
62
- setExternal();
63
-
64
- const {
65
- manifest
66
- } = config,
67
- options = _objectWithoutProperties(config, _excluded);
68
-
69
- logger('createPlugin', {
70
- config
71
- });
72
- const promise = initOptions(manifest, options);
73
- return createPlugin(() => ({
74
- hoc({
75
- App
76
- }, next) {
77
- class GetMicroFrontendApp extends React.Component {
78
- constructor(props) {
79
- super(props);
80
- this.state = {
81
- MApp: () => {
82
- logger('MApp init Component Render');
83
- return /*#__PURE__*/React.createElement('div');
84
- },
85
- apps: new Proxy({}, {
86
- get() {
87
- return () => /*#__PURE__*/React.createElement('div');
88
- }
89
-
90
- }),
91
- appInfoList: []
92
- };
93
-
94
- const load = async () => {
95
- const GarfishConfig = await promise;
96
- logger('initOptions result', {
97
- manifest,
98
- GarfishConfig
99
- });
100
- const MApp = generateMApp(GarfishConfig, manifest);
101
- const {
102
- appInfoList,
103
- apps
104
- } = generateApps(GarfishConfig, manifest);
105
- logger('generateApps', {
106
- MApp,
107
- apps,
108
- appInfoList
109
- });
110
- this.setState({
111
- MApp,
112
- apps,
113
- appInfoList
58
+ } // export default GarfishPlugin;
59
+
60
+
61
+ export default (defaultConfig => ({
62
+ name: '@modern-js/garfish-plugin',
63
+ setup: config => {
64
+ setExternal();
65
+
66
+ const _merge2 = _merge(defaultConfig, config),
67
+ {
68
+ manifest
69
+ } = _merge2,
70
+ options = _objectWithoutProperties(_merge2, _excluded);
71
+
72
+ logger('createPlugin', {
73
+ config
74
+ });
75
+ const promise = initOptions(manifest, options);
76
+ return {
77
+ hoc({
78
+ App
79
+ }, next) {
80
+ class GetMicroFrontendApp extends React.Component {
81
+ constructor(props) {
82
+ super(props);
83
+ this.state = {
84
+ MApp: () => {
85
+ logger('MApp init Component Render');
86
+ return /*#__PURE__*/React.createElement('div');
87
+ },
88
+ apps: new Proxy({}, {
89
+ get() {
90
+ return () => /*#__PURE__*/React.createElement('div');
91
+ }
92
+
93
+ }),
94
+ appInfoList: []
95
+ };
96
+
97
+ const load = async () => {
98
+ const GarfishConfig = await promise;
99
+ logger('initOptions result', {
100
+ manifest,
101
+ GarfishConfig
102
+ });
103
+ const MApp = generateMApp(GarfishConfig, manifest);
104
+ const {
105
+ appInfoList,
106
+ apps
107
+ } = generateApps(GarfishConfig, manifest);
108
+ logger('generateApps', {
109
+ MApp,
110
+ apps,
111
+ appInfoList
112
+ });
113
+ this.setState({
114
+ MApp,
115
+ apps,
116
+ appInfoList
117
+ });
118
+ };
119
+
120
+ load();
121
+ }
122
+
123
+ render() {
124
+ logger('GarfishProvider state', this.state);
125
+ return /*#__PURE__*/_jsx(GarfishProvider, {
126
+ value: this.state,
127
+ children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
114
128
  });
115
- };
129
+ }
116
130
 
117
- load();
118
- }
119
-
120
- render() {
121
- logger('GarfishProvider state', this.state);
122
- return /*#__PURE__*/_jsx(GarfishProvider, {
123
- value: this.state,
124
- children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
125
- });
126
131
  }
127
132
 
133
+ return next({
134
+ App: hoistNonReactStatics(GetMicroFrontendApp, App)
135
+ });
128
136
  }
129
137
 
130
- return next({
131
- App: hoistNonReactStatics(GetMicroFrontendApp, App)
132
- });
133
- }
134
-
135
- }));
136
- };
137
-
138
- export default GarfishPlugin;
138
+ };
139
+ }
140
+ }));
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _runtimeCore = require("@modern-js/runtime-core");
8
+ var _merge3 = _interopRequireDefault(require("lodash/merge"));
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
@@ -72,84 +72,88 @@ async function initOptions(manifest = {}, options) {
72
72
  return _objectSpread(_objectSpread({}, options), {}, {
73
73
  apps
74
74
  });
75
- }
76
-
77
- const GarfishPlugin = config => {
78
- (0, _setExternal.default)();
79
-
80
- const {
81
- manifest
82
- } = config,
83
- options = _objectWithoutProperties(config, _excluded);
84
-
85
- (0, _util.logger)('createPlugin', {
86
- config
87
- });
88
- const promise = initOptions(manifest, options);
89
- return (0, _runtimeCore.createPlugin)(() => ({
90
- hoc({
91
- App
92
- }, next) {
93
- class GetMicroFrontendApp extends _react.default.Component {
94
- constructor(props) {
95
- super(props);
96
- this.state = {
97
- MApp: () => {
98
- (0, _util.logger)('MApp init Component Render');
99
- return /*#__PURE__*/_react.default.createElement('div');
100
- },
101
- apps: new Proxy({}, {
102
- get() {
103
- return () => /*#__PURE__*/_react.default.createElement('div');
104
- }
105
-
106
- }),
107
- appInfoList: []
108
- };
109
-
110
- const load = async () => {
111
- const GarfishConfig = await promise;
112
- (0, _util.logger)('initOptions result', {
113
- manifest,
114
- GarfishConfig
115
- });
116
- const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
117
- const {
118
- appInfoList,
119
- apps
120
- } = (0, _apps.generateApps)(GarfishConfig, manifest);
121
- (0, _util.logger)('generateApps', {
122
- MApp,
123
- apps,
124
- appInfoList
125
- });
126
- this.setState({
127
- MApp,
128
- apps,
129
- appInfoList
75
+ } // export default GarfishPlugin;
76
+
77
+
78
+ var _default = defaultConfig => ({
79
+ name: '@modern-js/garfish-plugin',
80
+ setup: config => {
81
+ (0, _setExternal.default)();
82
+
83
+ const _merge2 = (0, _merge3.default)(defaultConfig, config),
84
+ {
85
+ manifest
86
+ } = _merge2,
87
+ options = _objectWithoutProperties(_merge2, _excluded);
88
+
89
+ (0, _util.logger)('createPlugin', {
90
+ config
91
+ });
92
+ const promise = initOptions(manifest, options);
93
+ return {
94
+ hoc({
95
+ App
96
+ }, next) {
97
+ class GetMicroFrontendApp extends _react.default.Component {
98
+ constructor(props) {
99
+ super(props);
100
+ this.state = {
101
+ MApp: () => {
102
+ (0, _util.logger)('MApp init Component Render');
103
+ return /*#__PURE__*/_react.default.createElement('div');
104
+ },
105
+ apps: new Proxy({}, {
106
+ get() {
107
+ return () => /*#__PURE__*/_react.default.createElement('div');
108
+ }
109
+
110
+ }),
111
+ appInfoList: []
112
+ };
113
+
114
+ const load = async () => {
115
+ const GarfishConfig = await promise;
116
+ (0, _util.logger)('initOptions result', {
117
+ manifest,
118
+ GarfishConfig
119
+ });
120
+ const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
121
+ const {
122
+ appInfoList,
123
+ apps
124
+ } = (0, _apps.generateApps)(GarfishConfig, manifest);
125
+ (0, _util.logger)('generateApps', {
126
+ MApp,
127
+ apps,
128
+ appInfoList
129
+ });
130
+ this.setState({
131
+ MApp,
132
+ apps,
133
+ appInfoList
134
+ });
135
+ };
136
+
137
+ load();
138
+ }
139
+
140
+ render() {
141
+ (0, _util.logger)('GarfishProvider state', this.state);
142
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Context.GarfishProvider, {
143
+ value: this.state,
144
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread(_objectSpread({}, this.props), this.state))
130
145
  });
131
- };
146
+ }
132
147
 
133
- load();
134
- }
135
-
136
- render() {
137
- (0, _util.logger)('GarfishProvider state', this.state);
138
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Context.GarfishProvider, {
139
- value: this.state,
140
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread(_objectSpread({}, this.props), this.state))
141
- });
142
148
  }
143
149
 
150
+ return next({
151
+ App: (0, _hoistNonReactStatics.default)(GetMicroFrontendApp, App)
152
+ });
144
153
  }
145
154
 
146
- return next({
147
- App: (0, _hoistNonReactStatics.default)(GetMicroFrontendApp, App)
148
- });
149
- }
150
-
151
- }));
152
- };
155
+ };
156
+ }
157
+ });
153
158
 
154
- var _default = GarfishPlugin;
155
159
  exports.default = _default;
@@ -1,5 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
 
3
+ import _merge from "lodash/merge";
3
4
  var _excluded = ["manifest"];
4
5
 
5
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -38,8 +39,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
38
39
 
39
40
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
40
41
 
41
- // eslint-disable-next-line filenames/match-exported
42
- import { createPlugin } from '@modern-js/runtime-core';
43
42
  import React from 'react';
44
43
  import hoistNonReactStatics from 'hoist-non-react-statics';
45
44
  import { logger } from "../util";
@@ -51,7 +50,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
51
50
 
52
51
  function initOptions() {
53
52
  return _initOptions.apply(this, arguments);
54
- }
53
+ } // export default GarfishPlugin;
54
+
55
55
 
56
56
  function _initOptions() {
57
57
  _initOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
@@ -120,115 +120,117 @@ function _initOptions() {
120
120
  return _initOptions.apply(this, arguments);
121
121
  }
122
122
 
123
- var GarfishPlugin = function GarfishPlugin(config) {
124
- setExternal();
125
-
126
- var manifest = config.manifest,
127
- options = _objectWithoutProperties(config, _excluded);
128
-
129
- logger('createPlugin', {
130
- config: config
131
- });
132
- var promise = initOptions(manifest, options);
133
- return createPlugin(function () {
134
- return {
135
- hoc: function hoc(_ref, next) {
136
- var App = _ref.App;
137
-
138
- var GetMicroFrontendApp = /*#__PURE__*/function (_React$Component) {
139
- _inherits(GetMicroFrontendApp, _React$Component);
140
-
141
- var _super = _createSuper(GetMicroFrontendApp);
142
-
143
- function GetMicroFrontendApp(props) {
144
- var _this;
145
-
146
- _classCallCheck(this, GetMicroFrontendApp);
147
-
148
- _this = _super.call(this, props);
149
- _this.state = {
150
- MApp: function MApp() {
151
- logger('MApp init Component Render');
152
- return /*#__PURE__*/React.createElement('div');
153
- },
154
- apps: new Proxy({}, {
155
- get: function get() {
156
- return function () {
157
- return /*#__PURE__*/React.createElement('div');
158
- };
159
- }
160
- }),
161
- appInfoList: []
162
- };
163
-
164
- var load = /*#__PURE__*/function () {
165
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
166
- var GarfishConfig, MApp, _generateApps, appInfoList, apps;
167
-
168
- return _regeneratorRuntime.wrap(function _callee$(_context) {
169
- while (1) {
170
- switch (_context.prev = _context.next) {
171
- case 0:
172
- _context.next = 2;
173
- return promise;
174
-
175
- case 2:
176
- GarfishConfig = _context.sent;
177
- logger('initOptions result', {
178
- manifest: manifest,
179
- GarfishConfig: GarfishConfig
180
- });
181
- MApp = generateMApp(GarfishConfig, manifest);
182
- _generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
183
- logger('generateApps', {
184
- MApp: MApp,
185
- apps: apps,
186
- appInfoList: appInfoList
187
- });
188
-
189
- _this.setState({
190
- MApp: MApp,
191
- apps: apps,
192
- appInfoList: appInfoList
193
- });
194
-
195
- case 8:
196
- case "end":
197
- return _context.stop();
198
- }
123
+ export default (function (defaultConfig) {
124
+ return {
125
+ name: '@modern-js/garfish-plugin',
126
+ setup: function setup(config) {
127
+ setExternal();
128
+
129
+ var _merge2 = _merge(defaultConfig, config),
130
+ manifest = _merge2.manifest,
131
+ options = _objectWithoutProperties(_merge2, _excluded);
132
+
133
+ logger('createPlugin', {
134
+ config: config
135
+ });
136
+ var promise = initOptions(manifest, options);
137
+ return {
138
+ hoc: function hoc(_ref, next) {
139
+ var App = _ref.App;
140
+
141
+ var GetMicroFrontendApp = /*#__PURE__*/function (_React$Component) {
142
+ _inherits(GetMicroFrontendApp, _React$Component);
143
+
144
+ var _super = _createSuper(GetMicroFrontendApp);
145
+
146
+ function GetMicroFrontendApp(props) {
147
+ var _this;
148
+
149
+ _classCallCheck(this, GetMicroFrontendApp);
150
+
151
+ _this = _super.call(this, props);
152
+ _this.state = {
153
+ MApp: function MApp() {
154
+ logger('MApp init Component Render');
155
+ return /*#__PURE__*/React.createElement('div');
156
+ },
157
+ apps: new Proxy({}, {
158
+ get: function get() {
159
+ return function () {
160
+ return /*#__PURE__*/React.createElement('div');
161
+ };
199
162
  }
200
- }, _callee);
201
- }));
202
-
203
- return function load() {
204
- return _ref2.apply(this, arguments);
163
+ }),
164
+ appInfoList: []
205
165
  };
206
- }();
207
-
208
- load();
209
- return _this;
210
- }
211
-
212
- _createClass(GetMicroFrontendApp, [{
213
- key: "render",
214
- value: function render() {
215
- logger('GarfishProvider state', this.state);
216
- return /*#__PURE__*/_jsx(GarfishProvider, {
217
- value: this.state,
218
- children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
219
- });
166
+
167
+ var load = /*#__PURE__*/function () {
168
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
169
+ var GarfishConfig, MApp, _generateApps, appInfoList, apps;
170
+
171
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
172
+ while (1) {
173
+ switch (_context.prev = _context.next) {
174
+ case 0:
175
+ _context.next = 2;
176
+ return promise;
177
+
178
+ case 2:
179
+ GarfishConfig = _context.sent;
180
+ logger('initOptions result', {
181
+ manifest: manifest,
182
+ GarfishConfig: GarfishConfig
183
+ });
184
+ MApp = generateMApp(GarfishConfig, manifest);
185
+ _generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
186
+ logger('generateApps', {
187
+ MApp: MApp,
188
+ apps: apps,
189
+ appInfoList: appInfoList
190
+ });
191
+
192
+ _this.setState({
193
+ MApp: MApp,
194
+ apps: apps,
195
+ appInfoList: appInfoList
196
+ });
197
+
198
+ case 8:
199
+ case "end":
200
+ return _context.stop();
201
+ }
202
+ }
203
+ }, _callee);
204
+ }));
205
+
206
+ return function load() {
207
+ return _ref2.apply(this, arguments);
208
+ };
209
+ }();
210
+
211
+ load();
212
+ return _this;
220
213
  }
221
- }]);
222
214
 
223
- return GetMicroFrontendApp;
224
- }(React.Component);
215
+ _createClass(GetMicroFrontendApp, [{
216
+ key: "render",
217
+ value: function render() {
218
+ logger('GarfishProvider state', this.state);
219
+ return /*#__PURE__*/_jsx(GarfishProvider, {
220
+ value: this.state,
221
+ children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
222
+ });
223
+ }
224
+ }]);
225
225
 
226
- return next({
227
- App: hoistNonReactStatics(GetMicroFrontendApp, App)
228
- });
229
- }
230
- };
231
- });
232
- };
226
+ return GetMicroFrontendApp;
227
+ }(React.Component);
233
228
 
234
- export default GarfishPlugin;
229
+ return next({
230
+ App: hoistNonReactStatics(GetMicroFrontendApp, App)
231
+ });
232
+ }
233
+ };
234
+ }
235
+ };
236
+ });
@@ -1,29 +1,6 @@
1
- import React from 'react';
1
+ import type { Plugin } from '@modern-js/runtime-core';
2
2
  import { Config } from './useModuleApps';
3
- declare const GarfishPlugin: (config: Config) => import("@modern-js/core").Plugin<{
4
- hoc: import("@modern-js/runtime-core").Pipeline<{
5
- App: React.ComponentType<any>;
6
- }, React.ComponentType<any>>;
7
- provide: import("@modern-js/runtime-core").Pipeline<{
8
- element: JSX.Element;
9
- readonly props: import("@modern-js/runtime-core/src/plugin").AppProps;
10
- readonly context: import("@modern-js/runtime-core").RuntimeContext;
11
- }, JSX.Element>;
12
- client: import("@modern-js/runtime-core").AsyncPipeline<{
13
- App: React.ComponentType<any>;
14
- readonly context?: import("@modern-js/runtime-core").RuntimeContext | undefined;
15
- rootElement: HTMLElement;
16
- }, void>;
17
- server: import("@modern-js/runtime-core").AsyncPipeline<{
18
- App: React.ComponentType<any>;
19
- readonly context?: import("@modern-js/runtime-core").RuntimeContext | undefined;
20
- }, string>;
21
- init: import("@modern-js/runtime-core").AsyncPipeline<{
22
- context: import("@modern-js/runtime-core").RuntimeContext;
23
- }, unknown>;
24
- pickContext: import("@modern-js/runtime-core").Pipeline<{
25
- context: import("@modern-js/runtime-core").RuntimeContext;
26
- pickedContext: import("@modern-js/runtime-core").TRuntimeContext;
27
- }, import("@modern-js/runtime-core").TRuntimeContext>;
28
- }, Record<string, never>>;
29
- export default GarfishPlugin;
3
+
4
+ declare const _default: (defaultConfig: Partial<Config>) => Plugin;
5
+
6
+ export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.4-beta.2",
14
+ "version": "1.4.4-beta.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/runtime/index.d.ts",
17
17
  "typesVersions": {
@@ -52,6 +52,7 @@
52
52
  "debug": "^4.3.2",
53
53
  "garfish": "^1.3.3",
54
54
  "hoist-non-react-statics": "^3.3.2",
55
+ "lodash": "^4.17.21",
55
56
  "react-loadable": "^5.5.0"
56
57
  },
57
58
  "devDependencies": {
@@ -67,6 +68,7 @@
67
68
  "@testing-library/user-event": "^13.5.0",
68
69
  "@types/hoist-non-react-statics": "^3.3.1",
69
70
  "@types/jest": "^26.0.24",
71
+ "@types/lodash": "^4.14.181",
70
72
  "@types/node": "^14",
71
73
  "@types/react": "^17",
72
74
  "@types/react-dom": "^17",
@@ -1,5 +1,12 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`plugin-garfish cli cli addRuntimeExports 1`] = `
4
+ Array [
5
+ "export { default as garfish, default as masterApp } from '@modern-js/test/plugin-garfish'",
6
+ "export * from '@modern-js/test/plugin-garfish'",
7
+ ]
8
+ `;
9
+
3
10
  exports[`plugin-garfish cli cli get runtime config 1`] = `
4
11
  Object {
5
12
  "masterApp": Object {
@@ -1,9 +1,24 @@
1
1
  import '@testing-library/jest-dom';
2
- import { manager } from '@modern-js/core';
2
+ import { Hooks, manager, ToRunners } from '@modern-js/core';
3
3
  import WebpackChain from 'webpack-chain';
4
4
  import GarfishPlugin, { externals } from '../src/cli';
5
5
  import { getRuntimeConfig, makeRenderFunction, setRuntimeConfig } from '../src/cli/utils';
6
6
 
7
+ const addExportList = [];
8
+ jest.mock('@modern-js/utils', () => {
9
+ const originalModule = jest.requireActual('@modern-js/utils');
10
+ return {
11
+ __esModule: true,
12
+ ...originalModule,
13
+ createRuntimeExportsUtils: ()=>({
14
+ addExport: (val: any)=> {
15
+ addExportList.push(val);
16
+ },
17
+ getPath: ()=> 'test',
18
+ }),
19
+ }
20
+ });
21
+
7
22
  describe('plugin-garfish cli', () => {
8
23
  test('cli garfish basename', async () => {
9
24
  expect(GarfishPlugin().name).toBe('@modern-js/plugin-garfish');
@@ -21,7 +36,7 @@ describe('plugin-garfish cli', () => {
21
36
  },
22
37
  }
23
38
  } as any);
24
-
39
+
25
40
  expect(configHistoryOptions.resolved.runtime.masterApp.basename).toBe('/test');
26
41
 
27
42
  const configHistory: any = await runner.resolvedConfig({
@@ -34,7 +49,7 @@ describe('plugin-garfish cli', () => {
34
49
  },
35
50
  }
36
51
  } as any);
37
-
52
+
38
53
  expect(configHistory.resolved.runtime.masterApp.basename).toBe('/test2');
39
54
  });
40
55
 
@@ -202,4 +217,23 @@ describe('plugin-garfish cli', () => {
202
217
  expect(generateConfig.externals).toBeUndefined();
203
218
  expect(generateConfig.output.filename).toBeUndefined();
204
219
  });
220
+
221
+ test('cli addRuntimeExports', async ()=>{
222
+ const resolveConfig: any = {};
223
+ const mfPackagePath = '@modern-js/test/plugin-garfish';
224
+ const plugin = GarfishPlugin({
225
+ mfPackagePath,
226
+ });
227
+
228
+ const lifecycle = await plugin.setup({
229
+ useResolvedConfigContext: () => resolveConfig,
230
+ useAppContext: ()=>({
231
+ internalDirectory: 'test'
232
+ }),
233
+ } as any);
234
+
235
+ lifecycle && lifecycle.config();
236
+ lifecycle && lifecycle.addRuntimeExports()
237
+ expect(addExportList).toMatchSnapshot();
238
+ });
205
239
  });