create-module-federation 0.0.0-next-20250306071320 → 0.0.0-next-20250306125957
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/README.md +40 -1
- package/dist/index.js +7 -4
- package/package.json +1 -1
- package/templates/provider-modern-ts/modern.config.ts +18 -0
- package/templates/provider-rsbuild-ts/rsbuild.config.ts +11 -0
- /package/templates/{modern-common → consumer-modern-ts}/modern.config.ts +0 -0
- /package/templates/{rsbuild-common → consumer-rsbuild-ts}/rsbuild.config.ts +0 -0
package/README.md
CHANGED
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://module-federation.io/" target="blank"><img src="https://module-federation.io/module-federation.svg" alt="Module Federation 2.0" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# create-module-federation
|
|
6
|
+
|
|
7
|
+
Create a new Module Federation project.
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://npmjs.com/package/create-module-federation">
|
|
11
|
+
<img src="https://img.shields.io/npm/v/create-module-federation?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
12
|
+
</a>
|
|
13
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
14
|
+
<a href="https://npmcharts.com/compare/create-module-federation?minimal=true"><img src="https://img.shields.io/npm/dm/create-module-federation.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Using `npm create`:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm create module-federation@latest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Using CLI flags:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx create-module-federation --dir my-project --template provider-modern --name provider
|
|
29
|
+
|
|
30
|
+
# Using abbreviations
|
|
31
|
+
npx create-module-federation -d my-project -t provider-modern -n provider
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
See [Documentation](https://module-federation.io/guide/start/quick-start).
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
[MIT](https://github.com/module-federation/core/blob/main/LICENSE).
|
package/dist/index.js
CHANGED
|
@@ -319,11 +319,13 @@ async function create({ name, templates }) {
|
|
|
319
319
|
}));
|
|
320
320
|
if ('no' === option) cancelAndExit();
|
|
321
321
|
}
|
|
322
|
+
argv.template = templates.includes(argv.template || '') ? argv.template : void 0;
|
|
322
323
|
const projectType = await getProjectType(argv.template);
|
|
323
324
|
if ("other" === projectType) {
|
|
324
325
|
const otherOptions = Object.keys(OTHER_TYPE).map((key)=>({
|
|
325
326
|
value: key,
|
|
326
|
-
label: OTHER_TYPE[key].label
|
|
327
|
+
label: OTHER_TYPE[key].label,
|
|
328
|
+
hint: OTHER_TYPE[key].hint
|
|
327
329
|
}));
|
|
328
330
|
const otherProjectKey = checkCancel(await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
|
|
329
331
|
message: 'Please select the type of template you want to create:',
|
|
@@ -331,7 +333,8 @@ async function create({ name, templates }) {
|
|
|
331
333
|
}));
|
|
332
334
|
const { command } = OTHER_TYPE[otherProjectKey];
|
|
333
335
|
const commandWithManager = command.replace(/^npm create /, `${pkgManager} create `);
|
|
334
|
-
const
|
|
336
|
+
const npmParams = 'npm' === pkgManager && pkgInfo?.version && parseInt(pkgInfo.version.split('.')[0], 10) < 7 ? ' --' : '';
|
|
337
|
+
const realCommand = `${commandWithManager}${npmParams} -d ${distFolder} -n ${mfName}${argv.override ? ' --override' : ''}`;
|
|
335
338
|
const [cmd, ...cmdArgs] = realCommand.split(' ');
|
|
336
339
|
const { status } = (0, __WEBPACK_EXTERNAL_MODULE_child_process__.spawnSync)(cmd, cmdArgs, {
|
|
337
340
|
stdio: 'inherit'
|
|
@@ -357,11 +360,11 @@ async function create({ name, templates }) {
|
|
|
357
360
|
}
|
|
358
361
|
const TEMPLATES = [
|
|
359
362
|
'provider-modern',
|
|
360
|
-
'consumer-modern',
|
|
361
363
|
'provider-rsbuild',
|
|
362
|
-
'consumer-rsbuild',
|
|
363
364
|
'rslib',
|
|
364
365
|
'rslib-storybook',
|
|
366
|
+
'consumer-modern',
|
|
367
|
+
'consumer-rsbuild',
|
|
365
368
|
'create-zephyr'
|
|
366
369
|
];
|
|
367
370
|
create({
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
2
|
+
import { moduleFederationPlugin } from '@module-federation/modern-js';
|
|
3
|
+
|
|
4
|
+
// https://modernjs.dev/en/configure/app/usage
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
runtime: {
|
|
7
|
+
router: true,
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
appTools({
|
|
11
|
+
bundler: 'rspack', // Set to 'webpack' to enable webpack
|
|
12
|
+
}),
|
|
13
|
+
moduleFederationPlugin(),
|
|
14
|
+
],
|
|
15
|
+
server: {
|
|
16
|
+
port: 3001,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig } from '@rsbuild/core';
|
|
2
|
+
import { pluginReact } from '@rsbuild/plugin-react';
|
|
3
|
+
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
4
|
+
import moduleFederationConfig from './module-federation.config';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [pluginReact(), pluginModuleFederation(moduleFederationConfig)],
|
|
8
|
+
server: {
|
|
9
|
+
port: 3001,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
File without changes
|
|
File without changes
|