Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
manfredsteyer committed Jun 22, 2024
2 parents afa8343 + 3d18e6d commit 2fe3dc8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion libs/mf-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@angular-architects/module-federation-runtime",
"license": "MIT",
"version": "18.0.3",
"version": "18.0.4",
"peerDependencies": {
"@angular/common": ">=18.0.0",
"@angular/core": ">=18.0.0"
Expand Down
2 changes: 1 addition & 1 deletion libs/mf-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular-architects/module-federation-tools",
"version": "18.0.3",
"version": "18.0.4",
"license": "MIT",
"peerDependencies": {},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions libs/mf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular-architects/module-federation",
"version": "18.0.3",
"version": "18.0.4",
"license": "MIT",
"repository": {
"type": "GitHub",
Expand All @@ -17,7 +17,7 @@
"schematics": "./collection.json",
"builders": "./builders.json",
"dependencies": {
"@angular-architects/module-federation-runtime": "18.0.3",
"@angular-architects/module-federation-runtime": "18.0.4",
"word-wrap": "^1.2.3",
"callsite": "^1.0.0",
"node-fetch": "^2.6.7",
Expand Down
13 changes: 4 additions & 9 deletions libs/mf/post-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs');
const path = require('path');


// const index = fs.readFileSync(path.join(__dirname, 'src/index.ts'), {
// encoding: 'utf-8',
// });
Expand All @@ -21,14 +20,10 @@ const path = require('path');
// nguniversal
// );


const webpack2 = fs.readFileSync(
path.join(__dirname, 'webpack.ts'),
{
encoding: 'utf-8',
}
);
const webpack2 = fs.readFileSync(path.join(__dirname, 'webpack.ts'), {
encoding: 'utf-8',
});
fs.writeFileSync(
path.join(__dirname, '../../dist/libs/mf/webpack.js'),
'module.exports = require("./src/webpack.js");'
);
);
21 changes: 12 additions & 9 deletions libs/mf/src/schematics/mf/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,18 @@ export default function config(options: MfSchematicSchema): Rule {
buildConfig?.builder === '@angular-devkit/build-angular:application';

if (isApplicationBuilder) {
console.warn(`\nWARNING: This package uses the tradtional webpack-based Module Federation implementation and not the fast new esbuild-based ApplicationBuilder.`)
console.warn(`\nFor new projects, consider Native Federation as an alternative: https://shorturl.at/0ZQ0j`)
console.warn(`\nHowever, if you want to add a new host or remote to an existing Module Federation-based system, this package is what you are looking for.`)
console.warn(`\nDo you want to proceeed: [y] Yes [n] No \n`)
console.warn(
`\nWARNING: This package uses the tradtional webpack-based Module Federation implementation and not the fast new esbuild-based ApplicationBuilder.`
);
console.warn(
`\nFor new projects, consider Native Federation as an alternative: https://shorturl.at/0ZQ0j`
);
console.warn(
`\nHowever, if you want to add a new host or remote to an existing Module Federation-based system, this package is what you are looking for.`
);
console.warn(`\nDo you want to proceeed: [y] Yes [n] No \n`);

for (; ;) {
for (;;) {
const key = await readKey();
if (key === 'Y' || key === 'y') {
break;
Expand All @@ -249,7 +255,6 @@ export default function config(options: MfSchematicSchema): Rule {
process.exit(0);
}
}

}

if (buildConfig?.options?.browser) {
Expand Down Expand Up @@ -436,7 +441,6 @@ async function readKey() {
process.stdin.pause();
r(key);
});

});
}

Expand Down Expand Up @@ -546,7 +550,6 @@ export function generateSsrMappings(
}

function downgradeToWebpack(build: any) {

if (!build.options) {
return;
}
Expand All @@ -565,4 +568,4 @@ function downgradeToWebpack(build: any) {
asset.output = '.';
}
}
}
}
18 changes: 13 additions & 5 deletions libs/mf/src/schematics/remove/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,32 @@ export default function remove(options: RemoveSchema): Rule {
};
}

function updateBuildConfig(normalized: { projectConfig: any; projectName: string; }) {
function updateBuildConfig(normalized: {
projectConfig: any;
projectName: string;
}) {
const build = normalized.projectConfig.architect.build;
build.builder = '@angular-devkit/build-angular:browser';
delete build.options.extraWebpackConfig;
delete build.options.customWebpackConfig;

const buildProd = build.configurations.production;
delete buildProd.extraWebpackConfig;
delete buildProd.customWebpackConfig;
}

function updateServeConfig(normalized: { projectConfig: any; projectName: string; }) {
function updateServeConfig(normalized: {
projectConfig: any;
projectName: string;
}) {
const serve = normalized.projectConfig.architect.serve;
serve.builder = '@angular-devkit/build-angular:dev-server';
delete serve.options.extraWebpackConfig;
delete serve.options.customWebpackConfig;

const serveProd = serve.configurations.production;
delete serveProd.extraWebpackConfig;
delete serveProd.customWebpackConfig;

const prodTarget = serveProd.browserTarget;
if (prodTarget) {
Expand All @@ -50,11 +61,9 @@ function updateServeConfig(normalized: { projectConfig: any; projectName: string
delete serveDev.browserTarget;
serveDev.buildTarget = devTarget;
}

}

function normalize(options: RemoveSchema, workspace: any) {

if (!options.project) {
options.project = workspace.defaultProject;
}
Expand Down Expand Up @@ -95,4 +104,3 @@ function removeBootstrap(normalized, tree) {
tree.overwrite(mainPath, content);
tree.delete(bootstrapPath);
}

5 changes: 2 additions & 3 deletions libs/mf/tutorial/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ So far, we just hardcoded the URLs pointing to our Micro Frontends. However, in
2. Adjust the shell's `main.ts` (`projects/shell/src/main.ts`) as follows:
```typescript
import { loadManifest } from '@angular-architects/module-federation';
```
```typescript
import { loadManifest } from '@angular-architects/module-federation';

loadManifest('assets/mf.manifest.json')
.catch((err) => console.error('Error loading remote entries', err))
Expand Down
1 change: 1 addition & 0 deletions libs/native-federation-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@softarc/native-federation",
"version": "2.0.9",
"type": "commonjs",
"license": "MIT",
"dependencies": {
"json5": "^2.2.0",
"npmlog": "^6.0.2",
Expand Down

0 comments on commit 2fe3dc8

Please sign in to comment.