Skip to content

Commit

Permalink
feat: add Create a new Module Federation project cli
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jan 20, 2025
1 parent 4de2f93 commit 5af6ae0
Show file tree
Hide file tree
Showing 90 changed files with 3,053 additions and 192 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-otters-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-module-federation': patch
---

feat: add Create a new Module Federation project cli
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
vite.config.ts
**/dist/**
**/dist/**
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ apps/website-new/docs

/.nx/workspace-data
/.nx/cache

**/*.handlebars
6 changes: 3 additions & 3 deletions apps/rslib-module/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export default defineConfig({
root: './dist/mf',
},
},
server: {
port: 3001,
},
},
],
server: {
port: 3001,
},
plugins: [
pluginReact(),
pluginModuleFederation({
Expand Down
1 change: 1 addition & 0 deletions packages/create-module-federation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# create-module-federation
21 changes: 21 additions & 0 deletions packages/create-module-federation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present hanric(2heal1)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions packages/create-module-federation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# `create-module-federation`
27 changes: 27 additions & 0 deletions packages/create-module-federation/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
clearMocks: true,
testEnvironment: 'jsdom',
coveragePathIgnorePatterns: ['__tests__', '/node_modules/'],
coverageProvider: 'v8',
coverageReporters: ['cobertura', 'clover', 'json', 'lcov', 'text'],
globals: {
__DEV__: true,
__TEST__: true,
__BROWSER__: false,
__VERSION__: '"unknown"',
},
preset: 'ts-jest',
transformIgnorePatterns: [
// Change MODULE_NAME_HERE to your module that isn't being compiled
'/node_modules/(?!((@byted/garfish-)|(byted-tea-sdk))).+\\.js$',
],
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest'],
},
rootDir: __dirname,
testMatch: ['<rootDir>__tests__/**/**.spec.[jt]s?(x)'],
testPathIgnorePatterns: ['/node_modules/'],
};
44 changes: 44 additions & 0 deletions packages/create-module-federation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "create-module-federation",
"description": "Create a new Module Federation project",
"public": true,
"sideEffects": false,
"version": "0.0.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/module-federation/core/",
"directory": "packages/create-module-federation"
},
"publishConfig": {
"access": "public"
},
"type": "module",
"scripts": {
"build": "rslib build"
},
"main": "./dist/index.js",
"bin": {
"create-module-federation": "./dist/index.js"
},
"files": [
"template",
"dist"
],
"dependencies": {
"@clack/prompts": "^0.8.2",
"execa": "5.1.1",
"fs-extra": "9.1.0",
"minimist": "^1.2.8",
"rslog": "^1.2.3",
"glob": "7.2.0",
"handlebars": "4.7.7"
},
"devDependencies": {
"@types/glob": "7.2.0",
"@types/minimist": "^1.2.5",
"@types/fs-extra": "9.0.6",
"@rslib/core": "^0.3.1",
"rsbuild-plugin-publint": "^0.2.1"
}
}
65 changes: 65 additions & 0 deletions packages/create-module-federation/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "create-module-federation",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/create-module-federation/src",
"projectType": "library",
"tags": ["type:pkg"],
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"dependsOn": [
{
"target": "build",
"dependencies": true
}
],
"commands": [
"cd packages/create-module-federation; pnpm run build",
"cp packages/create-module-federation/LICENSE packages/create-module-federation/dist"
]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/create-module-federation/**/*.ts",
"packages/create-module-federation/package.json"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/create-module-federation/jest.config.js",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"pre-release": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"commands": [
{
"command": "nx run create-module-federation:test",
"forwardAllArgs": false
},
{
"command": "nx run create-module-federation:build",
"forwardAllArgs": false
}
]
}
}
}
}
7 changes: 7 additions & 0 deletions packages/create-module-federation/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { pluginPublint } from 'rsbuild-plugin-publint';
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [{ format: 'esm' }],
plugins: [pluginPublint()],
});
Loading

0 comments on commit 5af6ae0

Please sign in to comment.