From 89d34b6f5b84d8ee13c03600390d7daffadbe0c6 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Mon, 4 Nov 2024 13:22:28 +0000 Subject: [PATCH 1/5] feat(module-federation): add initial module-federation package --- packages/module-federation/.eslintrc.json | 45 ++++++++++++ packages/module-federation/README.md | 18 +++++ packages/module-federation/executors.json | 5 ++ packages/module-federation/index.ts | 0 packages/module-federation/jest.config.ts | 16 +++++ packages/module-federation/migrations.json | 1 + packages/module-federation/package.json | 34 +++++++++ packages/module-federation/project.json | 70 +++++++++++++++++++ packages/module-federation/tsconfig.json | 16 +++++ packages/module-federation/tsconfig.lib.json | 10 +++ packages/module-federation/tsconfig.spec.json | 9 +++ 11 files changed, 224 insertions(+) create mode 100644 packages/module-federation/.eslintrc.json create mode 100644 packages/module-federation/README.md create mode 100644 packages/module-federation/executors.json create mode 100644 packages/module-federation/index.ts create mode 100644 packages/module-federation/jest.config.ts create mode 100644 packages/module-federation/migrations.json create mode 100644 packages/module-federation/package.json create mode 100644 packages/module-federation/project.json create mode 100644 packages/module-federation/tsconfig.json create mode 100644 packages/module-federation/tsconfig.lib.json create mode 100644 packages/module-federation/tsconfig.spec.json diff --git a/packages/module-federation/.eslintrc.json b/packages/module-federation/.eslintrc.json new file mode 100644 index 0000000000000..85e1f5edfb9ab --- /dev/null +++ b/packages/module-federation/.eslintrc.json @@ -0,0 +1,45 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["./package.json", "./generators.json", "./executors.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/nx-plugin-checks": "error" + } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "eslint", + "typescript", + "@nx/cypress", + "@nx/playwright", + "@nx/vite" + ] + } + ] + } + } + ] +} diff --git a/packages/module-federation/README.md b/packages/module-federation/README.md new file mode 100644 index 0000000000000..7ff5a6dc3deb9 --- /dev/null +++ b/packages/module-federation/README.md @@ -0,0 +1,18 @@ +

+ + + Nx - Smart Monorepos · Fast CI + +

+ +{{links}} + +
+ +# Nx: Smart Monorepos · Fast CI + +Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution. + +This package is a [Module Federation plugin for Nx](https://nx.dev/nx-api/module-federation). + +{{content}} diff --git a/packages/module-federation/executors.json b/packages/module-federation/executors.json new file mode 100644 index 0000000000000..f8866a4e64c69 --- /dev/null +++ b/packages/module-federation/executors.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/schema", + "executors": { + } +} diff --git a/packages/module-federation/index.ts b/packages/module-federation/index.ts new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/packages/module-federation/jest.config.ts b/packages/module-federation/jest.config.ts new file mode 100644 index 0000000000000..79612dcfd1f67 --- /dev/null +++ b/packages/module-federation/jest.config.ts @@ -0,0 +1,16 @@ +/* eslint-disable */ +export default { + displayName: 'module-federation', + preset: '../../jest.preset.js', + globals: {}, + transform: { + '^.+\\.[tj]s$': [ + 'ts-jest', + { + tsconfig: '/tsconfig.spec.json', + }, + ], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/packages/module-federation', +}; diff --git a/packages/module-federation/migrations.json b/packages/module-federation/migrations.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/packages/module-federation/migrations.json @@ -0,0 +1 @@ +{} diff --git a/packages/module-federation/package.json b/packages/module-federation/package.json new file mode 100644 index 0000000000000..fede19a820e96 --- /dev/null +++ b/packages/module-federation/package.json @@ -0,0 +1,34 @@ +{ + "name": "@nx/module-federation", + "description": "The Nx Plugin for Module Federation contains executors and utilities that support building applications using Module Federation.", + "version": "0.0.1", + "type": "commonjs", + "repository": { + "type": "git", + "url": "https://github.com/nrwl/nx.git", + "directory": "packages/module-federation" + }, + "bugs": { + "url": "https://github.com/nrwl/nx/issues" + }, + "keywords": [ + "Monorepo", + "Rspack", + "Webpack", + "Bundling", + "Module Federation" + ], + "author": "Colum Ferry", + "license": "MIT", + "homepage": "https://nx.dev", + "main": "index.js", + "executors": "./executors.json", + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + }, + "nx-migrations": { + "migrations": "./migrations.json" + } +} diff --git a/packages/module-federation/project.json b/packages/module-federation/project.json new file mode 100644 index 0000000000000..1365eedab5948 --- /dev/null +++ b/packages/module-federation/project.json @@ -0,0 +1,70 @@ +{ + "name": "module-federation", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/module-federation", + "projectType": "library", + "targets": { + "build-base": { + "executor": "@nx/js:tsc", + "options": { + "outputPath": "build/packages/module-federation", + "tsConfig": "packages/module-federation/tsconfig.lib.json", + "main": "packages/module-federation/index.ts", + "generateExportsField": true, + "additionalEntryPoints": [ + "{projectRoot}/{executors,generators,migrations}.json", + "{projectRoot}/plugin.ts" + ], + "assets": [ + { + "input": "packages/module-federation", + "glob": "**/files/**", + "output": "/" + }, + { + "input": "packages/module-federation", + "glob": "**/files/**/.gitkeep", + "output": "/" + }, + { + "input": "packages/module-federation", + "glob": "**/*.json", + "ignore": [ + "**/tsconfig*.json", + "project.json", + ".eslintrc.json" + ], + "output": "/" + }, + { + "input": "packages/module-federation", + "glob": "**/*.js", + "ignore": [ + "**/jest.config.js" + ], + "output": "/" + }, + { + "input": "packages/module-federation", + "glob": "**/*.d.ts", + "output": "/" + }, + { + "input": "", + "glob": "LICENSE", + "output": "/" + } + ] + }, + "outputs": [ + "{options.outputPath}" + ] + }, + "build": { + "command": "node ./scripts/copy-readme.js module-federation", + "outputs": [ + "{workspaceRoot}/build/packages/module-federation" + ] + } + } +} diff --git a/packages/module-federation/tsconfig.json b/packages/module-federation/tsconfig.json new file mode 100644 index 0000000000000..19b9eece4df14 --- /dev/null +++ b/packages/module-federation/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs" + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/module-federation/tsconfig.lib.json b/packages/module-federation/tsconfig.lib.json new file mode 100644 index 0000000000000..7bfc80f73e6fa --- /dev/null +++ b/packages/module-federation/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["**/*.ts"], + "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] +} diff --git a/packages/module-federation/tsconfig.spec.json b/packages/module-federation/tsconfig.spec.json new file mode 100644 index 0000000000000..546f12877f7f0 --- /dev/null +++ b/packages/module-federation/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] +} From 2732004dea78561ce8e8913cf982b53c243d6328 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Mon, 4 Nov 2024 13:26:42 +0000 Subject: [PATCH 2/5] docs(module-federation): add initial nx dev links for module-federation package --- docs/generated/manifests/menus.json | 8 ++++++++ docs/generated/manifests/nx-api.json | 12 ++++++++++++ docs/generated/packages-metadata.json | 11 +++++++++++ docs/shared/reference/sitemap.md | 1 + 4 files changed, 32 insertions(+) diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 265016dde5640..fced90b0cc15b 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -8179,6 +8179,14 @@ "isExternal": false, "disableCollapsible": false }, + { + "id": "module-federation", + "path": "/nx-api/module-federation", + "name": "module-federation", + "children": [], + "isExternal": false, + "disableCollapsible": false + }, { "id": "nest", "path": "/nx-api/nest", diff --git a/docs/generated/manifests/nx-api.json b/docs/generated/manifests/nx-api.json index 78f4f3bf96d02..564a146ae86a6 100644 --- a/docs/generated/manifests/nx-api.json +++ b/docs/generated/manifests/nx-api.json @@ -1306,6 +1306,18 @@ }, "path": "/nx-api/js" }, + "module-federation": { + "githubRoot": "https://github.com/nrwl/nx/blob/master", + "name": "module-federation", + "packageName": "@nx/module-federation", + "description": "The Nx Plugin for Module Federation contains executors and utilities that support building applications using Module Federation.", + "documents": {}, + "root": "/packages/module-federation", + "source": "/packages/module-federation/src", + "executors": {}, + "generators": {}, + "path": "/nx-api/module-federation" + }, "nest": { "githubRoot": "https://github.com/nrwl/nx/blob/master", "name": "nest", diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index 20745b2d6fcac..aa253011a364f 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -1292,6 +1292,17 @@ "root": "/packages/js", "source": "/packages/js/src" }, + { + "description": "The Nx Plugin for Module Federation contains executors and utilities that support building applications using Module Federation.", + "documents": [], + "executors": [], + "generators": [], + "githubRoot": "https://github.com/nrwl/nx/blob/master", + "name": "module-federation", + "packageName": "@nx/module-federation", + "root": "/packages/module-federation", + "source": "/packages/module-federation/src" + }, { "description": "The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.", "documents": [ diff --git a/docs/shared/reference/sitemap.md b/docs/shared/reference/sitemap.md index 54496eddbd763..72c75be604959 100644 --- a/docs/shared/reference/sitemap.md +++ b/docs/shared/reference/sitemap.md @@ -490,6 +490,7 @@ - [setup-build](/nx-api/js/generators/setup-build) - [typescript-sync](/nx-api/js/generators/typescript-sync) - [setup-prettier](/nx-api/js/generators/setup-prettier) + - [module-federation](/nx-api/module-federation) - [nest](/nx-api/nest) - [documents](/nx-api/nest/documents) - [Overview](/nx-api/nest/documents/overview) From 6c1a87aeca489db1f4a128639e634c4d3599bc44 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Mon, 4 Nov 2024 13:28:27 +0000 Subject: [PATCH 3/5] chore(module-federation): fix formatting --- packages/module-federation/executors.json | 3 +-- packages/module-federation/package.json | 3 +-- packages/module-federation/project.json | 18 ++++-------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/module-federation/executors.json b/packages/module-federation/executors.json index f8866a4e64c69..b64f99d988d2c 100644 --- a/packages/module-federation/executors.json +++ b/packages/module-federation/executors.json @@ -1,5 +1,4 @@ { "$schema": "http://json-schema.org/schema", - "executors": { - } + "executors": {} } diff --git a/packages/module-federation/package.json b/packages/module-federation/package.json index fede19a820e96..be727b51d1d42 100644 --- a/packages/module-federation/package.json +++ b/packages/module-federation/package.json @@ -26,8 +26,7 @@ "dependencies": { "tslib": "^2.3.0" }, - "peerDependencies": { - }, + "peerDependencies": {}, "nx-migrations": { "migrations": "./migrations.json" } diff --git a/packages/module-federation/project.json b/packages/module-federation/project.json index 1365eedab5948..70a094ad8ef99 100644 --- a/packages/module-federation/project.json +++ b/packages/module-federation/project.json @@ -29,19 +29,13 @@ { "input": "packages/module-federation", "glob": "**/*.json", - "ignore": [ - "**/tsconfig*.json", - "project.json", - ".eslintrc.json" - ], + "ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"], "output": "/" }, { "input": "packages/module-federation", "glob": "**/*.js", - "ignore": [ - "**/jest.config.js" - ], + "ignore": ["**/jest.config.js"], "output": "/" }, { @@ -56,15 +50,11 @@ } ] }, - "outputs": [ - "{options.outputPath}" - ] + "outputs": ["{options.outputPath}"] }, "build": { "command": "node ./scripts/copy-readme.js module-federation", - "outputs": [ - "{workspaceRoot}/build/packages/module-federation" - ] + "outputs": ["{workspaceRoot}/build/packages/module-federation"] } } } From bd19be0a7f404f2bb119d8d57adc61b989ef6079 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Mon, 4 Nov 2024 14:59:30 +0000 Subject: [PATCH 4/5] chore(repo): update codeowners for MF --- CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index b117b961294a7..fb4aa0d893f1e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -106,6 +106,9 @@ rust-toolchain @nrwl/nx-native-reviewers /packages/vite/** @nrwl/nx-js-reviewers /e2e/vite/** @nrwl/nx-js-reviewers +## Module Federation +/packages/module-federation/** @jaysoo @Coly010 @ndcunningham + ## Tools /docs/generated/packages/cypress/** @nrwl/nx-testing-tools-reviewers @nrwl/nx-docs-reviewers /docs/shared/packages/cypress/** @nrwl/nx-testing-tools-reviewers @nrwl/nx-docs-reviewers From 27aaa280f5e930077cdfb81a8227938fe8b0fd78 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Wed, 6 Nov 2024 16:57:17 +0000 Subject: [PATCH 5/5] chore(repo): update CODEOWNERS for module federation package --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index fb4aa0d893f1e..829108e90c533 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -107,7 +107,7 @@ rust-toolchain @nrwl/nx-native-reviewers /e2e/vite/** @nrwl/nx-js-reviewers ## Module Federation -/packages/module-federation/** @jaysoo @Coly010 @ndcunningham +/packages/module-federation/** @nrwl/nx-js-reviewers ## Tools /docs/generated/packages/cypress/** @nrwl/nx-testing-tools-reviewers @nrwl/nx-docs-reviewers