Skip to content

Commit

Permalink
feat(module-federation): add module federation package (nrwl#12961)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 authored Nov 4, 2022
1 parent ed33d17 commit 377e3bd
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = {
{ name: 'js', description: 'anything TS->JS specific' },
{ name: 'linter', description: 'anything Linter specific' },
{ name: 'misc', description: 'misc stuff' },
{
name: 'module-federation',
description: 'anything related to the Module Federation package',
},
{ name: 'nest', description: 'anything Nest specific' },
{ name: 'nextjs', description: 'anything Next specific' },
{ name: 'node', description: 'anything Node specific' },
Expand Down
11 changes: 11 additions & 0 deletions docs/generated/packages/module-federation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "module-federation",
"packageName": "@nrwl/module-federation",
"description": "The Module Federation plugin for Nx contains a Webpack Plugin and helpers to enable Module Federation for your Angular and React apps in your Nx Workspace. ",
"root": "/packages/module-federation",
"source": "/packages/module-federation/src",
"documentation": [],
"generators": [],
"executors": []
}
7 changes: 7 additions & 0 deletions docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@
"path": "generated/packages/make-angular-cli-faster.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "module-federation",
"packageName": "module-federation",
"description": "The Module Federation plugin for Nx contains a Webpack Plugin and helpers to enable Module Federation for your Angular and React apps in your Nx Workspace. ",
"path": "generated/packages/module-federation.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "nest",
"packageName": "nest",
Expand Down
14 changes: 14 additions & 0 deletions packages/module-federation/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../.eslintrc",
"rules": {},
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["./package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nrwl/nx/nx-plugin-checks": "error"
}
}
]
}
13 changes: 13 additions & 0 deletions packages/module-federation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>

{{links}}

<hr>

# Nx: Smart, Fast and Extensible Build System

Nx is a next generation build system with first class monorepo support and powerful integrations.

This package is a [Module Federation plugin for Nx](https://nx.dev/module-federation/overview).

{{content}}
Empty file.
11 changes: 11 additions & 0 deletions packages/module-federation/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
displayName: 'module-federation',
testEnvironment: 'node',
preset: '../../jest.preset.js',
};
4 changes: 4 additions & 0 deletions packages/module-federation/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"generators": {},
"packageJsonUpdates": {}
}
19 changes: 19 additions & 0 deletions packages/module-federation/migrations.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path = require('path');
import json = require('./migrations.json');

type MigrationGenerator = {
cli: string;
version: string;
description: string;
factory: string;
};

describe('Module Federation migrations', () => {
it('should have valid paths', () => {
Object.values<MigrationGenerator>(json.generators).forEach((m) => {
expect(() =>
require.resolve(path.join(__dirname, `${m.factory}.ts`))
).not.toThrow();
});
});
});
34 changes: 34 additions & 0 deletions packages/module-federation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@nrwl/module-federation",
"version": "0.0.1",
"private": true,
"description": "The Module Federation plugin for Nx contains a Webpack Plugin and helpers to enable Module Federation for your Angular and React apps in your Nx Workspace. ",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/module-federation"
},
"keywords": [
"Monorepo",
"Web",
"Node",
"Webpack",
"Module Federation",
"CLI"
],
"main": "src/index.js",
"typings": "src/index.d.ts",
"license": "MIT",
"bugs": {
"url": "https://github.com/nrwl/nx/issues"
},
"homepage": "https://nx.dev",
"ng-update": {
"requirements": {},
"migrations": "./migrations.json"
},
"dependencies": {},
"publishConfig": {
"access": "public"
}
}
78 changes: 78 additions & 0 deletions packages/module-federation/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/module-federation/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/module-federation/**/*.ts",
"packages/module-federation/package.json",
"packages/module-federation/migrations.json"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/module-federation"],
"options": {
"jestConfig": "packages/module-federation/jest.config.ts",
"passWithNoTests": true
}
},
"build-base": {
"executor": "@nrwl/js:tsc",
"options": {
"outputPath": "build/packages/module-federation",
"tsConfig": "packages/module-federation/tsconfig.lib.json",
"main": "packages/module-federation/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"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": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/build/packages/module-federation"],
"options": {
"command": "node ./scripts/copy-readme.js module-federation"
}
}
},
"tags": []
}
13 changes: 13 additions & 0 deletions packages/module-federation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
11 changes: 11 additions & 0 deletions packages/module-federation/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}
20 changes: 20 additions & 0 deletions packages/module-federation/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx",
"**/*.d.ts",
"jest.config.ts"
]
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@nrwl/js": ["packages/js/src"],
"@nrwl/js/*": ["packages/js/*"],
"@nrwl/linter": ["packages/linter"],
"@nrwl/module-federation": ["packages/module-federation"],
"@nrwl/nest": ["packages/nest"],
"@nrwl/next": ["packages/next"],
"@nrwl/node": ["packages/node"],
Expand Down
1 change: 1 addition & 0 deletions workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"js": "packages/js",
"linter": "packages/linter",
"make-angular-cli-faster": "packages/make-angular-cli-faster",
"module-federation": "packages/module-federation",
"nest": "packages/nest",
"next": "packages/next",
"node": "packages/node",
Expand Down

0 comments on commit 377e3bd

Please sign in to comment.