Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Thumbs.db

# Nx
.nx/cache
.nx/workspace-data
migrations.json

# Angular
Expand Down
36 changes: 36 additions & 0 deletions apps/mfe-for-ssr/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../../.eslintrc.base.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": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
37 changes: 37 additions & 0 deletions apps/mfe-for-ssr/federation.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const {
withNativeFederation,
shareAll,
} = require('dist/libs/native-federation/src/config.js');

module.exports = withNativeFederation({
name: 'mfe-for-ssr',

exposes: {
'./AppComponent': './apps/mfe-for-ssr/src/app/app.component.ts',
},

shared: {
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
}),
},

skip: [
'@softarc/native-federation',
'@angular-architects/build_angular',
'@angular-architects/module-federation',
'@angular-architects/module-federation-runtime',
'@angular-architects/module-federation-tools',
'@angular-architects/native-federation',
'@softarc/native-federation-esbuild',
'@softarc/native-federation-runtime',
'@softarc/native-federation/build',
'@module-federation/vite',
// Add further packages you don't need at runtime
],

// Please read our FAQ about sharing libs:
// https://shorturl.at/jmzH0
});
22 changes: 22 additions & 0 deletions apps/mfe-for-ssr/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'mfe-for-ssr',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/apps/mfe-for-ssr',
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',
],
};
106 changes: 106 additions & 0 deletions apps/mfe-for-ssr/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"name": "mfe-for-ssr",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "app",
"sourceRoot": "apps/mfe-for-ssr/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-architects/native-federation:build",
"options": {},
"configurations": {
"production": {
"target": "mfe-for-ssr:esbuild:production"
},
"development": {
"target": "mfe-for-ssr:esbuild:development",
"dev": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-architects/native-federation:build",
"options": {
"target": "mfe-for-ssr:serve-original:development",
"rebuildDelay": 0,
"dev": true,
"port": 0
}
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "mfe-for-ssr:build"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/mfe-for-ssr/jest.config.ts"
}
},
"esbuild": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/mfe-for-ssr",
"index": "apps/mfe-for-ssr/src/index.html",
"browser": "apps/mfe-for-ssr/src/main.ts",
"polyfills": ["zone.js", "es-module-shims"],
"tsConfig": "apps/mfe-for-ssr/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "apps/mfe-for-ssr/public"
}
],
"styles": ["apps/mfe-for-ssr/src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve-original": {
"executor": "@angular-devkit/build-angular:dev-server",
"options": {
"port": 4201
},
"configurations": {
"production": {
"buildTarget": "mfe-for-ssr:esbuild:production"
},
"development": {
"buildTarget": "mfe-for-ssr:esbuild:development"
}
},
"defaultConfiguration": "development"
}
}
}
Binary file added apps/mfe-for-ssr/public/favicon.ico
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions apps/mfe-for-ssr/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>Mfe component</div>
27 changes: 27 additions & 0 deletions apps/mfe-for-ssr/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { NxWelcomeComponent } from './nx-welcome.component';
import { RouterModule } from '@angular/router';

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

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain(
'Welcome mfe-for-ssr'
);
});

it(`should have as title 'mfe-for-ssr'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('mfe-for-ssr');
});
});
13 changes: 13 additions & 0 deletions apps/mfe-for-ssr/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { RouterModule } from '@angular/router';

@Component({
standalone: true,
imports: [RouterModule],
selector: 'app-root-mfe',
templateUrl: './app.component.html',
styleUrl: './app.component.css',
})
export class AppComponent {
title = 'mfe-for-ssr';
}
10 changes: 10 additions & 0 deletions apps/mfe-for-ssr/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { appRoutes } from './app.routes';

export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(appRoutes),
],
};
3 changes: 3 additions & 0 deletions apps/mfe-for-ssr/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Route } from '@angular/router';

export const appRoutes: Route[] = [];
Loading