Skip to content

Commit

Permalink
Add mfe1
Browse files Browse the repository at this point in the history
  • Loading branch information
omarbelkhodja-minotore committed Sep 13, 2023
1 parent 9a1b6ac commit 40cf82f
Show file tree
Hide file tree
Showing 31 changed files with 4,563 additions and 6,315 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Build mfe1",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npx",
"runtimeArgs": ["nx", "run", "mfe1:build:production", "--verbose"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}

36 changes: 36 additions & 0 deletions mfe1/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "angularArchitects",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "angular-architects",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
20 changes: 20 additions & 0 deletions mfe1/federation.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const {
withNativeFederation,
shareAll,
} = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({
name: 'mfe1',

exposes: {
'./cmp': 'mfe1/src/app/app.component.ts',
},

shared: {
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
}),
},
});
23 changes: 23 additions & 0 deletions mfe1/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
export default {
displayName: 'mfe1',
preset: '../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageDirectory: '../coverage/mfe1',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
94 changes: 94 additions & 0 deletions mfe1/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"name": "mfe1",
"$schema": "../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "mfe1/src",
"prefix": "angular-architects",
"targets": {
"build": {
"executor": "@angular-architects/native-federation:build",
"options": {
"target": "mfe1:esbuild:production"
}
},
"serve": {
"executor": "@angular-architects/native-federation:build",
"options": {
"target": "mfe1:esbuild:development",
"rebuildDelay": 0,
"dev": true,
"port": 4200
}
},
"esbuild": {
"executor": "@angular-devkit/build-angular:browser-esbuild",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/mfe1",
"index": "mfe1/src/index.html",
"main": "mfe1/src/main.ts",
"polyfills": [
"zone.js",
"es-module-shims"
],
"tsConfig": "mfe1/tsconfig.app.json",
"assets": ["mfe1/src/favicon.ico", "mfe1/src/assets"],
"styles": ["mfe1/src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "mfe1/src/environments/environment.ts",
"with": "mfe1/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "mfe1:build"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": ["mfe1/**/*.ts", "mfe1/**/*.html"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/mfe1"],
"options": {
"jestConfig": "mfe1/jest.config.ts",
"passWithNoTests": true
}
},
},
"tags": []
}
Empty file added mfe1/src/app/app.component.css
Empty file.
1 change: 1 addition & 0 deletions mfe1/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Hello from MFE1</h1>
30 changes: 30 additions & 0 deletions mfe1/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { NxWelcomeComponent } from './nx-welcome.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AppComponent, NxWelcomeComponent],
}).compileComponents();
});

it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});

it(`should have as title 'mfe1'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('mfe1');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Welcome mfe1');
});
});
11 changes: 11 additions & 0 deletions mfe1/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
standalone: true,
selector: 'angular-architects-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'mfe1';
}
14 changes: 14 additions & 0 deletions mfe1/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';
import { DemoComponent } from './demo/demo.component';
import { NxWelcomeComponent } from './nx-welcome.component';

@NgModule({
declarations: [AppComponent, NxWelcomeComponent],
imports: [BrowserModule, DemoComponent],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
Empty file added mfe1/src/assets/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions mfe1/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { environment } from './environments/environment';
import { enableProdMode } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

if (environment.production) {
enableProdMode();
}

bootstrapApplication(AppComponent, {
providers: [
]
});

3 changes: 3 additions & 0 deletions mfe1/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
16 changes: 16 additions & 0 deletions mfe1/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false,
};

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
Binary file added mfe1/src/favicon.ico
Binary file not shown.
13 changes: 13 additions & 0 deletions mfe1/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mfe1</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<angular-architects-root></angular-architects-root>
</body>
</html>
5 changes: 5 additions & 0 deletions mfe1/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { initFederation } from '@angular-architects/native-federation';

initFederation()
.then(() => import('./bootstrap'))
.catch((err) => console.error(err));
53 changes: 53 additions & 0 deletions mfe1/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes recent versions of Safari, Chrome (including
* Opera), Edge on the desktop, and iOS and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/

/***************************************************************************************************
* BROWSER POLYFILLS
*/

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/

/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.

/***************************************************************************************************
* APPLICATION IMPORTS
*/
import 'es-module-shims';
1 change: 1 addition & 0 deletions mfe1/src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */
1 change: 1 addition & 0 deletions mfe1/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';
12 changes: 12 additions & 0 deletions mfe1/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"types": [],
"target": "ES2022",
"useDefineForClassFields": false
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"],
"exclude": ["**/*.test.ts", "**/*.spec.ts", "jest.config.ts"]
}
7 changes: 7 additions & 0 deletions mfe1/tsconfig.editor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"types": ["jest", "node"]
}
}
Loading

0 comments on commit 40cf82f

Please sign in to comment.