@modern-js/plugin-garfish 2.0.0-beta.7 → 2.0.0

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - 6bc7763: fix(plugin-garfish): 修复 assetPrefix 用户配置被 plugin-garfish 覆盖问题,自定义入口未正确传递节点参数
12
+ fix(plugin-garfish): Fix the problem that the assetPrefix user configuration is overwritten by plugin-garfish, and the custom entry does not pass the node parameters correctly
13
+ - 81b54f9: fix: garfish wrapped app missing props
14
+ fix: garfish 包装过的 APP 缺少 props
15
+ - Updated dependencies [c9e800d39a]
16
+ - Updated dependencies [edd1cfb1af]
17
+ - Updated dependencies [6bda14ed71]
18
+ - Updated dependencies [dda38c9c3e]
19
+ - Updated dependencies [8b8e1bb571]
20
+ - Updated dependencies [ffb2ed4]
21
+ - Updated dependencies [bbe4c4ab64]
22
+ - @modern-js/runtime@2.0.0
23
+ - @modern-js/utils@2.0.0
24
+
3
25
  ## 2.0.0-beta.7
4
26
 
5
27
  ### Major Changes
@@ -134,11 +134,11 @@ var cli_default = ({
134
134
  env = process.env.NODE_ENV || "development",
135
135
  CHAIN_ID
136
136
  }) => {
137
- var _a2, _b2, _c2, _d;
137
+ var _a2, _b2, _c2, _d, _e;
138
138
  const resolveOptions = useResolvedConfigContext();
139
139
  if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
140
140
  chain.output.libraryTarget("umd");
141
- if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
141
+ if (!((_b2 = useConfig.dev) == null ? void 0 : _b2.assetPrefix) && ((_c2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _c2.port) && env === "development") {
142
142
  chain.output.publicPath(
143
143
  `//localhost:${resolveOptions.server.port}/`
144
144
  );
@@ -147,7 +147,7 @@ var cli_default = ({
147
147
  chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
148
148
  }
149
149
  const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
150
- (_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
150
+ (_d = resolveOptions.deploy) == null ? void 0 : _d.microFrontend
151
151
  );
152
152
  if (externalBasicLibrary) {
153
153
  chain.externals(externals);
@@ -166,7 +166,7 @@ var cli_default = ({
166
166
  output: resolveWebpackConfig.output,
167
167
  externals: resolveWebpackConfig.externals,
168
168
  env,
169
- alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
169
+ alias: (_e = resolveWebpackConfig.resolve) == null ? void 0 : _e.alias,
170
170
  plugins: resolveWebpackConfig.plugins
171
171
  });
172
172
  }
@@ -67,11 +67,11 @@ function generateRouterPlugin (basename,routerConfig) {
67
67
  return router(routerConfig);
68
68
  }
69
69
 
70
- function generateAppWrapperAndRootDom ({ App, props, dom }) {
70
+ function generateAppWrapperAndRootDom ({ App, props: garfishProps, dom }) {
71
71
  let AppWrapper = App;
72
- if (props) {
73
- AppWrapper = function () {
74
- return React.createElement(App, props);
72
+ if (garfishProps) {
73
+ AppWrapper = function (props) {
74
+ return React.createElement(App, { ...garfishProps, ...props });
75
75
  };
76
76
  AppWrapper = hoistNonReactStatics(AppWrapper, App);
77
77
  }
@@ -88,6 +88,9 @@ const makeRenderFunction = (code) => {
88
88
  return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
89
89
  `bootstrap(AppWrapper, mountNode, root`,
90
90
  "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
91
+ ).replace(
92
+ `customBootstrap(AppWrapper)`,
93
+ "customBootstrap(AppWrapper, mountNode)"
91
94
  );
92
95
  };
93
96
  function getRuntimeConfig(config) {
@@ -150,11 +150,11 @@ var cli_default = ({
150
150
  env = process.env.NODE_ENV || "development",
151
151
  CHAIN_ID
152
152
  }) => {
153
- var _a2, _b2, _c2, _d;
153
+ var _a2, _b2, _c2, _d, _e;
154
154
  const resolveOptions = useResolvedConfigContext();
155
155
  if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
156
156
  chain.output.libraryTarget("umd");
157
- if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
157
+ if (!((_b2 = useConfig.dev) == null ? void 0 : _b2.assetPrefix) && ((_c2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _c2.port) && env === "development") {
158
158
  chain.output.publicPath(
159
159
  `//localhost:${resolveOptions.server.port}/`
160
160
  );
@@ -163,7 +163,7 @@ var cli_default = ({
163
163
  chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
164
164
  }
165
165
  const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
166
- (_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
166
+ (_d = resolveOptions.deploy) == null ? void 0 : _d.microFrontend
167
167
  );
168
168
  if (externalBasicLibrary) {
169
169
  chain.externals(externals);
@@ -182,7 +182,7 @@ var cli_default = ({
182
182
  output: resolveWebpackConfig.output,
183
183
  externals: resolveWebpackConfig.externals,
184
184
  env,
185
- alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
185
+ alias: (_e = resolveWebpackConfig.resolve) == null ? void 0 : _e.alias,
186
186
  plugins: resolveWebpackConfig.plugins
187
187
  });
188
188
  }
@@ -93,11 +93,11 @@ function generateRouterPlugin (basename,routerConfig) {
93
93
  return router(routerConfig);
94
94
  }
95
95
 
96
- function generateAppWrapperAndRootDom ({ App, props, dom }) {
96
+ function generateAppWrapperAndRootDom ({ App, props: garfishProps, dom }) {
97
97
  let AppWrapper = App;
98
- if (props) {
99
- AppWrapper = function () {
100
- return React.createElement(App, props);
98
+ if (garfishProps) {
99
+ AppWrapper = function (props) {
100
+ return React.createElement(App, { ...garfishProps, ...props });
101
101
  };
102
102
  AppWrapper = hoistNonReactStatics(AppWrapper, App);
103
103
  }
@@ -114,6 +114,9 @@ const makeRenderFunction = (code) => {
114
114
  return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
115
115
  `bootstrap(AppWrapper, mountNode, root`,
116
116
  "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
117
+ ).replace(
118
+ `customBootstrap(AppWrapper)`,
119
+ "customBootstrap(AppWrapper, mountNode)"
117
120
  );
118
121
  };
119
122
  function getRuntimeConfig(config) {
@@ -247,9 +247,9 @@ var cli_default = function() {
247
247
  var ref, ref1;
248
248
  var resolveOptions = useResolvedConfigContext();
249
249
  if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (ref = resolveOptions.deploy) === null || ref === void 0 ? void 0 : ref.microFrontend) {
250
- var ref2, ref3;
250
+ var ref2, ref3, ref4;
251
251
  chain.output.libraryTarget("umd");
252
- if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (ref2 = resolveOptions.server) === null || ref2 === void 0 ? void 0 : ref2.port) && env === "development") {
252
+ if (!((ref2 = useConfig.dev) === null || ref2 === void 0 ? void 0 : ref2.assetPrefix) && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (ref3 = resolveOptions.server) === null || ref3 === void 0 ? void 0 : ref3.port) && env === "development") {
253
253
  chain.output.publicPath("//localhost:".concat(resolveOptions.server.port, "/"));
254
254
  }
255
255
  if (webpack.BannerPlugin) {
@@ -259,7 +259,7 @@ var cli_default = function() {
259
259
  }
260
260
  ]);
261
261
  }
262
- var ref4 = getDefaultMicroFrontedConfig((ref3 = resolveOptions.deploy) === null || ref3 === void 0 ? void 0 : ref3.microFrontend), enableHtmlEntry = ref4.enableHtmlEntry, externalBasicLibrary = ref4.externalBasicLibrary;
262
+ var ref5 = getDefaultMicroFrontedConfig((ref4 = resolveOptions.deploy) === null || ref4 === void 0 ? void 0 : ref4.microFrontend), enableHtmlEntry = ref5.enableHtmlEntry, externalBasicLibrary = ref5.externalBasicLibrary;
263
263
  if (externalBasicLibrary) {
264
264
  chain.externals(externals);
265
265
  }
@@ -1,9 +1,9 @@
1
1
  var makeProvider = function() {
2
- return "\nexport const provider = function ({basename, dom}) {\n return {\n render({basename, dom, props, appName}) {\n render({ props, basename, dom, appName });\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n if (IS_REACT18) {\n root.unmount();\n } else {\n unmountComponentAtNode(node);\n }\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n\nfunction canContinueRender ({ dom, appName }) {\n var renderByGarfish =\n typeof __GARFISH_EXPORTS__ !== 'undefined'\n || typeof window !== 'undefined' && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.some((app)=>app.appInfo.name === appName);\n let renderByProvider = dom || appName;\n if (renderByGarfish) {\n // Runs in the Garfish environment and is rendered by the provider\n if (renderByProvider) {\n return true;\n } else {\n // Runs in the Garfish environment and is not rendered by the provider\n return false;\n }\n } else {\n // Running in a non-Garfish environment\n return true;\n }\n}\n\nfunction generateRouterPlugin (basename,routerConfig) {\n if (basename) {\n routerConfig.basename = basename;\n if (routerConfig.supportHtml5History !== false) {\n if (!routerConfig.historyOptions) {\n routerConfig.historyOptions = {\n basename: basename\n };\n } else {\n routerConfig.historyOptions.basename = basename;\n }\n }\n }\n return router(routerConfig);\n}\n\nfunction generateAppWrapperAndRootDom ({ App, props, dom }) {\n let AppWrapper = App;\n if (props) {\n AppWrapper = function () {\n return React.createElement(App, props);\n };\n AppWrapper = hoistNonReactStatics(AppWrapper, App);\n }\n const mountNode = dom ? (dom.querySelector('#' + MOUNT_ID) || dom) : document.getElementById(MOUNT_ID);\n return { AppWrapper, mountNode }\n}\n";
2
+ return "\nexport const provider = function ({basename, dom}) {\n return {\n render({basename, dom, props, appName}) {\n render({ props, basename, dom, appName });\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n if (IS_REACT18) {\n root.unmount();\n } else {\n unmountComponentAtNode(node);\n }\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n\nfunction canContinueRender ({ dom, appName }) {\n var renderByGarfish =\n typeof __GARFISH_EXPORTS__ !== 'undefined'\n || typeof window !== 'undefined' && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.some((app)=>app.appInfo.name === appName);\n let renderByProvider = dom || appName;\n if (renderByGarfish) {\n // Runs in the Garfish environment and is rendered by the provider\n if (renderByProvider) {\n return true;\n } else {\n // Runs in the Garfish environment and is not rendered by the provider\n return false;\n }\n } else {\n // Running in a non-Garfish environment\n return true;\n }\n}\n\nfunction generateRouterPlugin (basename,routerConfig) {\n if (basename) {\n routerConfig.basename = basename;\n if (routerConfig.supportHtml5History !== false) {\n if (!routerConfig.historyOptions) {\n routerConfig.historyOptions = {\n basename: basename\n };\n } else {\n routerConfig.historyOptions.basename = basename;\n }\n }\n }\n return router(routerConfig);\n}\n\nfunction generateAppWrapperAndRootDom ({ App, props: garfishProps, dom }) {\n let AppWrapper = App;\n if (garfishProps) {\n AppWrapper = function (props) {\n return React.createElement(App, { ...garfishProps, ...props });\n };\n AppWrapper = hoistNonReactStatics(AppWrapper, App);\n }\n const mountNode = dom ? (dom.querySelector('#' + MOUNT_ID) || dom) : document.getElementById(MOUNT_ID);\n return { AppWrapper, mountNode }\n}\n";
3
3
  };
4
4
  var makeRenderFunction = function(code) {
5
5
  var inGarfishToRender = "\n const { basename, props, dom, appName } = typeof arguments[0] === 'object' && arguments[0] || {};\n if (!canContinueRender({ dom, appName })) return null;\n let { AppWrapper, mountNode } = generateAppWrapperAndRootDom({App, props, dom});\n ";
6
- return inGarfishToRender + code.replace("router(", "generateRouterPlugin(basename,").replace("(App)", "(AppWrapper)").replace(/MOUNT_ID/g, "mountNode").replace("bootstrap(AppWrapper, mountNode, root", "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null");
6
+ return inGarfishToRender + code.replace("router(", "generateRouterPlugin(basename,").replace("(App)", "(AppWrapper)").replace(/MOUNT_ID/g, "mountNode").replace("bootstrap(AppWrapper, mountNode, root", "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null").replace("customBootstrap(AppWrapper)", "customBootstrap(AppWrapper, mountNode)");
7
7
  };
8
8
  function getRuntimeConfig(config) {
9
9
  var ref;
@@ -1,12 +1,12 @@
1
1
  import type { CliHookCallbacks, useConfigContext } from '@modern-js/core';
2
2
  import type { CliPlugin, AppTools } from '@modern-js/app-tools';
3
- export declare type UseConfig = ReturnType<typeof useConfigContext>;
3
+ export type UseConfig = ReturnType<typeof useConfigContext>;
4
4
  export declare const externals: {
5
5
  'react-dom': string;
6
6
  react: string;
7
7
  };
8
- export declare type LifeCycle = CliHookCallbacks;
9
- declare type NonInValidAble<T> = T extends null | undefined | false ? never : T;
8
+ export type LifeCycle = CliHookCallbacks;
9
+ type NonInValidAble<T> = T extends null | undefined | false ? never : T;
10
10
  export declare function getDefaultMicroFrontedConfig(microFrontend: NonInValidAble<NonNullable<UseConfig['deploy']>['microFrontend']>): any;
11
11
 
12
12
  declare const _default: ({
@@ -1,19 +1,19 @@
1
1
  import garfish, { interfaces as GarfishInterfaces } from 'garfish';
2
2
  import React from 'react';
3
- export declare type Options = typeof garfish.options;
4
- export declare type ModuleInfo = GarfishInterfaces.AppInfo & {
3
+ export type Options = typeof garfish.options;
4
+ export type ModuleInfo = GarfishInterfaces.AppInfo & {
5
5
  Component?: React.ComponentType | React.ElementType;
6
6
  path?: string;
7
7
  originInfo?: Record<string, unknown>;
8
8
  };
9
- export declare type ModulesInfo = Array<ModuleInfo>;
10
- export declare type Manifest = {
9
+ export type ModulesInfo = Array<ModuleInfo>;
10
+ export type Manifest = {
11
11
  modules?: ModulesInfo;
12
12
  loadable?: LoadableConfig;
13
13
  componentRender?: boolean;
14
14
  getAppList?: (info: any) => Promise<Array<GarfishInterfaces.AppInfo>>;
15
15
  };
16
- export declare type LoadingComponent = React.ComponentType<{
16
+ export type LoadingComponent = React.ComponentType<{
17
17
  isLoading: boolean;
18
18
  pastDelay: boolean;
19
19
  timedOut: boolean;
@@ -25,15 +25,15 @@ export interface LoadableConfig {
25
25
  delay?: number;
26
26
  loading?: LoadingComponent;
27
27
  }
28
- export declare type ModernGarfishConfig = {
28
+ export type ModernGarfishConfig = {
29
29
  manifest?: Manifest;
30
30
  };
31
- export declare type MicroComponentProps = {
31
+ export type MicroComponentProps = {
32
32
  loadable?: LoadableConfig;
33
33
  [index: string]: any;
34
34
  };
35
- export declare type Config = Partial<Options> & ModernGarfishConfig;
36
- export declare type UseModuleApps = { [index in 'apps' | string]: index extends 'apps' ? ModulesInfo : React.FC<MicroComponentProps> } & {
35
+ export type Config = Partial<Options> & ModernGarfishConfig;
36
+ export type UseModuleApps = { [index in 'apps' | string]: index extends 'apps' ? ModulesInfo : React.FC<MicroComponentProps> } & {
37
37
  readonly MApp: React.FC<MicroComponentProps>;
38
38
  readonly apps: ModulesInfo;
39
39
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.7",
14
+ "version": "2.0.0",
15
15
  "jsnext:source": "./src/cli/index.ts",
16
16
  "types": "./dist/types/cli/index.d.ts",
17
17
  "typesVersions": {
@@ -60,10 +60,10 @@
60
60
  "garfish": "^1.8.1",
61
61
  "hoist-non-react-statics": "^3.3.2",
62
62
  "react-loadable": "^5.5.0",
63
- "@modern-js/utils": "2.0.0-beta.7"
63
+ "@modern-js/utils": "2.0.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@modern-js/runtime": "^2.0.0-beta.7"
66
+ "@modern-js/runtime": "^2.0.0"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@modern-js/runtime": {
@@ -85,13 +85,13 @@
85
85
  "react-router-dom": "^6.6.0",
86
86
  "typescript": "^4",
87
87
  "webpack-chain": "^6.5.1",
88
- "@modern-js/app-tools": "2.0.0-beta.7",
89
- "@modern-js/core": "2.0.0-beta.7",
90
- "@modern-js/runtime": "2.0.0-beta.7",
91
- "@modern-js/plugin-router-v5": "2.0.0-beta.7",
92
- "@modern-js/types": "2.0.0-beta.7",
93
- "@scripts/build": "2.0.0-beta.7",
94
- "@scripts/jest-config": "2.0.0-beta.7"
88
+ "@modern-js/app-tools": "2.0.0",
89
+ "@modern-js/core": "2.0.0",
90
+ "@modern-js/runtime": "2.0.0",
91
+ "@modern-js/plugin-router-v5": "2.0.0",
92
+ "@modern-js/types": "2.0.0",
93
+ "@scripts/build": "2.0.0",
94
+ "@scripts/jest-config": "2.0.0"
95
95
  },
96
96
  "sideEffects": false,
97
97
  "modernConfig": {},