@modern-js/app-tools 3.11.1 → 3.11.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.
@@ -55,10 +55,9 @@ const builderPluginAdapterBasic = (options)=>({
55
55
  chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(external_node_path_default().join(__dirname, `../loaders/serverModuleLoader.${depExt}`));
56
56
  }
57
57
  const { appContext } = options;
58
- const { metaName } = appContext;
59
58
  chain.watchOptions({
60
59
  ignored: [
61
- `[\\\\/](?:node_modules(?![\\\\/]\\.${metaName})|.git)[\\\\/]`
60
+ createWatchIgnored(appContext.internalDirectory)
62
61
  ]
63
62
  });
64
63
  });
@@ -128,6 +127,13 @@ function applyNodeCompat(isServiceWorker, chain) {
128
127
  for (const ext of nodeExts)chain.resolve.extensions.prepend(ext);
129
128
  if (isServiceWorker) for (const ext of webWorkerExts)chain.resolve.extensions.prepend(ext);
130
129
  }
130
+ function createWatchIgnored(internalDirectory) {
131
+ const segments = internalDirectory.split(/[\\/]/);
132
+ const index = segments.lastIndexOf('node_modules');
133
+ const internalPath = segments.slice(index + 1).map((segment)=>segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('[\\\\/]');
134
+ const nodeModules = -1 !== index && internalPath ? `node_modules(?![\\\\/]${internalPath}(?:[\\\\/]|$))` : 'node_modules';
135
+ return new RegExp(`[\\\\/](?:${nodeModules}|\\.git)[\\\\/]`);
136
+ }
131
137
  exports.builderPluginAdapterBasic = __webpack_exports__.builderPluginAdapterBasic;
132
138
  for(var __rspack_i in __webpack_exports__)if (-1 === [
133
139
  "builderPluginAdapterBasic"
@@ -42,7 +42,7 @@ class BottomTemplatePlugin {
42
42
  });
43
43
  }
44
44
  constructor(htmlPlugin){
45
- this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
45
+ this.bottomTemplateReg = /<\x21--<\?-\s*bottomTemplate\s*\?>--\x3e/;
46
46
  this.bodyRegExp = /(<\/\s*body\s*>)/i;
47
47
  this.htmlPlugin = htmlPlugin;
48
48
  this.name = 'bottom-template';
package/dist/cjs/index.js CHANGED
@@ -277,7 +277,9 @@ var __webpack_exports__ = {};
277
277
  });
278
278
  const __rspack_default_export = appTools;
279
279
  __webpack_require__.d(__webpack_exports__, {
280
+ appTools: ()=>appTools,
280
281
  closeServer: ()=>_utils_createServer__rspack_import_19.closeServer,
282
+ default: ()=>__rspack_default_export,
281
283
  defineConfig: ()=>_defineConfig__rspack_import_16.defineConfig,
282
284
  dev: ()=>_commands_dev__rspack_import_17.dev,
283
285
  generateWatchFiles: ()=>_utils_generateWatchFiles__rspack_import_13.generateWatchFiles,
@@ -285,9 +287,6 @@ var __webpack_exports__ = {};
285
287
  mergeConfig: ()=>_modern_js_plugin_cli__rspack_import_22.mergeConfig,
286
288
  resolveModernRsbuildConfig: ()=>_rsbuild__rspack_import_20.resolveModernRsbuildConfig,
287
289
  serve: ()=>_commands_serve__rspack_import_18.serve
288
- }, {
289
- appTools: appTools,
290
- default: __rspack_default_export
291
290
  });
292
291
  })();
293
292
  exports.appTools = __webpack_exports__.appTools;
@@ -13,10 +13,9 @@ const builderPluginAdapterBasic = (options)=>({
13
13
  chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(__dirname, `../loaders/serverModuleLoader.${depExt}`));
14
14
  }
15
15
  const { appContext } = options;
16
- const { metaName } = appContext;
17
16
  chain.watchOptions({
18
17
  ignored: [
19
- `[\\\\/](?:node_modules(?![\\\\/]\\.${metaName})|.git)[\\\\/]`
18
+ createWatchIgnored(appContext.internalDirectory)
20
19
  ]
21
20
  });
22
21
  });
@@ -86,4 +85,11 @@ function applyNodeCompat(isServiceWorker, chain) {
86
85
  for (const ext of nodeExts)chain.resolve.extensions.prepend(ext);
87
86
  if (isServiceWorker) for (const ext of webWorkerExts)chain.resolve.extensions.prepend(ext);
88
87
  }
88
+ function createWatchIgnored(internalDirectory) {
89
+ const segments = internalDirectory.split(/[\\/]/);
90
+ const index = segments.lastIndexOf('node_modules');
91
+ const internalPath = segments.slice(index + 1).map((segment)=>segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('[\\\\/]');
92
+ const nodeModules = -1 !== index && internalPath ? `node_modules(?![\\\\/]${internalPath}(?:[\\\\/]|$))` : 'node_modules';
93
+ return new RegExp(`[\\\\/](?:${nodeModules}|\\.git)[\\\\/]`);
94
+ }
89
95
  export { builderPluginAdapterBasic };
@@ -13,7 +13,7 @@ class BottomTemplatePlugin {
13
13
  });
14
14
  }
15
15
  constructor(htmlPlugin){
16
- this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
16
+ this.bottomTemplateReg = /<\x21--<\?-\s*bottomTemplate\s*\?>--\x3e/;
17
17
  this.bodyRegExp = /(<\/\s*body\s*>)/i;
18
18
  this.htmlPlugin = htmlPlugin;
19
19
  this.name = 'bottom-template';
@@ -17,10 +17,9 @@ const builderPluginAdapterBasic = (options)=>({
17
17
  chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(__rspack_import_meta_dirname__, `../loaders/serverModuleLoader.${depExt}`));
18
18
  }
19
19
  const { appContext } = options;
20
- const { metaName } = appContext;
21
20
  chain.watchOptions({
22
21
  ignored: [
23
- `[\\\\/](?:node_modules(?![\\\\/]\\.${metaName})|.git)[\\\\/]`
22
+ createWatchIgnored(appContext.internalDirectory)
24
23
  ]
25
24
  });
26
25
  });
@@ -90,4 +89,11 @@ function applyNodeCompat(isServiceWorker, chain) {
90
89
  for (const ext of nodeExts)chain.resolve.extensions.prepend(ext);
91
90
  if (isServiceWorker) for (const ext of webWorkerExts)chain.resolve.extensions.prepend(ext);
92
91
  }
92
+ function createWatchIgnored(internalDirectory) {
93
+ const segments = internalDirectory.split(/[\\/]/);
94
+ const index = segments.lastIndexOf('node_modules');
95
+ const internalPath = segments.slice(index + 1).map((segment)=>segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('[\\\\/]');
96
+ const nodeModules = -1 !== index && internalPath ? `node_modules(?![\\\\/]${internalPath}(?:[\\\\/]|$))` : 'node_modules';
97
+ return new RegExp(`[\\\\/](?:${nodeModules}|\\.git)[\\\\/]`);
98
+ }
93
99
  export { builderPluginAdapterBasic };
@@ -14,7 +14,7 @@ class BottomTemplatePlugin {
14
14
  });
15
15
  }
16
16
  constructor(htmlPlugin){
17
- this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
17
+ this.bottomTemplateReg = /<\x21--<\?-\s*bottomTemplate\s*\?>--\x3e/;
18
18
  this.bodyRegExp = /(<\/\s*body\s*>)/i;
19
19
  this.htmlPlugin = htmlPlugin;
20
20
  this.name = 'bottom-template';
@@ -17,7 +17,7 @@ Choose a release containing MCP Apps support. Run `pnpm dev`. The explicit BFF r
17
17
 
18
18
  ## Build cards
19
19
 
20
- Declare local default-export React components or this project's MF exposes in `mcp-views.json`:
20
+ Declare local default-export React components, this project's MF exposes, or exposes of deployed remotes in `mcp-views.json`:
21
21
 
22
22
  ```json
23
23
  {
@@ -46,6 +46,31 @@ mcpAppsPlugin({
46
46
  });
47
47
  ```
48
48
 
49
+ ### Reference deployed remotes
50
+
51
+ When another project publishes the card as an MF remote, set `remote` to the manifest URL of the remote:
52
+
53
+ ```json
54
+ {
55
+ "remote": "https://ui.example.com/mf-manifest.json",
56
+ "views": {
57
+ "todos": { "expose": "./Todos" },
58
+ "stats": { "expose": "./Stats" }
59
+ },
60
+ "csp": { "resourceDomains": ["https://cdn.example.com"] }
61
+ }
62
+ ```
63
+
64
+ The top-level `remote` is shared by all expose views. A view can set its own `remote` to override it. Component paths still reference local components. Without a top-level or view-level `remote`, exposes refer to this application. With a top-level `remote`, expose views in the same config cannot refer to this application's exposes. To mix both, omit the top-level `remote` and set `remote` only on the views that reference a deployed remote.
65
+
66
+ - The URL must be an absolute HTTP(S) URL whose path ends with `.json`. Entries that are not manifests, such as `remoteEntry.js`, are not supported
67
+ - The remote's name is not needed. The runtime reads it from the manifest
68
+ - The shell reads the remote manifest and loads the expose when the card opens. Republishing the remote needs no rebuild or restart of the MCP server. Exposes are not checked at build time. A missing expose shows a load error in the card
69
+ - This project does not need the MF plugin, but it must install the runtime that `mf.runtime` points to. Set `mf.runtime` as above when the remote uses another MF implementation
70
+ - The manifest origin is added to CSP automatically. Declare other origins serving the remote's scripts and styles, such as a CDN, in `csp.resourceDomains`. The manifest and scripts must allow cross-origin requests
71
+ - The remote must share React as a singleton so it uses the shell's React
72
+ - Adding a card or changing `remote` or `expose` still requires rebuilding the MCP server
73
+
49
74
  Local cards build as separate entries without the framework page runtime. With `source.enableAsyncEntry`, each entry adds a dynamic import boundary so MF shared dependencies can initialize. The MF plugin enables this option automatically. Otherwise cards mount directly without an extra request.
50
75
 
51
76
 
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.11.1",
18
+ "version": "3.11.3",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "exports": {
@@ -116,7 +116,7 @@
116
116
  "@babel/parser": "^7.29.12",
117
117
  "@babel/traverse": "^7.29.12",
118
118
  "@babel/types": "^7.29.11",
119
- "@rsbuild/core": "2.3.1",
119
+ "@rsbuild/core": "2.3.2",
120
120
  "@swc/core": "1.16.21",
121
121
  "@swc/helpers": "^0.5.17",
122
122
  "es-module-lexer": "^1.7.0",
@@ -126,16 +126,16 @@
126
126
  "ndepe": "^0.1.13",
127
127
  "pkg-types": "^1.3.1",
128
128
  "std-env": "^3.10.0",
129
- "@modern-js/builder": "3.11.1",
130
- "@modern-js/plugin": "3.11.1",
131
- "@modern-js/plugin-data-loader": "3.11.1",
132
- "@modern-js/i18n-utils": "3.11.1",
133
- "@modern-js/prod-server": "3.11.1",
134
- "@modern-js/server": "3.11.1",
135
- "@modern-js/server-core": "3.11.1",
136
- "@modern-js/types": "3.11.1",
137
- "@modern-js/server-utils": "3.11.1",
138
- "@modern-js/utils": "3.11.1"
129
+ "@modern-js/builder": "3.11.3",
130
+ "@modern-js/i18n-utils": "3.11.3",
131
+ "@modern-js/plugin": "3.11.3",
132
+ "@modern-js/plugin-data-loader": "3.11.3",
133
+ "@modern-js/prod-server": "3.11.3",
134
+ "@modern-js/server": "3.11.3",
135
+ "@modern-js/server-core": "3.11.3",
136
+ "@modern-js/server-utils": "3.11.3",
137
+ "@modern-js/types": "3.11.3",
138
+ "@modern-js/utils": "3.11.3"
139
139
  },
140
140
  "devDependencies": {
141
141
  "@types/babel__traverse": "7.28.0",
@@ -143,8 +143,8 @@
143
143
  "ts-node": "^10.9.2",
144
144
  "tsconfig-paths": "^4.2.0",
145
145
  "typescript": "^5",
146
- "@modern-js/rslib": "3.11.1",
147
- "@scripts/rstest-config": "2.66.5"
146
+ "@modern-js/rslib": "3.11.3",
147
+ "@scripts/rstest-config": "2.66.7"
148
148
  },
149
149
  "peerDependencies": {
150
150
  "ts-node": "^10.9.2",