Skip to content

Commit 16630ae

Browse files
committed
fix: race condition with rebuilds
1 parent 9a4711a commit 16630ae

File tree

10 files changed

+40
-24
lines changed

10 files changed

+40
-24
lines changed

libs/mf-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@angular-architects/module-federation-runtime",
33
"license": "MIT",
4-
"version": "17.0.4",
4+
"version": "17.0.7",
55
"peerDependencies": {
66
"@angular/common": ">=17.0.0",
77
"@angular/core": ">=17.0.0"

libs/mf-tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/module-federation-tools",
3-
"version": "17.0.4",
3+
"version": "17.0.7",
44
"license": "MIT",
55
"peerDependencies": {},
66
"dependencies": {

libs/mf/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/module-federation",
3-
"version": "17.0.4",
3+
"version": "17.0.7",
44
"license": "MIT",
55
"repository": {
66
"type": "GitHub",
@@ -17,7 +17,7 @@
1717
"schematics": "./collection.json",
1818
"builders": "./builders.json",
1919
"dependencies": {
20-
"@angular-architects/module-federation-runtime": "17.0.4",
20+
"@angular-architects/module-federation-runtime": "17.0.7",
2121
"word-wrap": "^1.2.3",
2222
"callsite": "^1.0.0",
2323
"node-fetch": "^2.6.7",

libs/mf/src/schematics/mf/schematic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ function nxBuildersAvailable(tree: Tree): boolean {
147147
}
148148

149149
function infereNxBuilderNames(tree: Tree): { dev: string; prod: string } {
150-
151150
const dep = getPackageJsonDependency(tree, '@nx/angular');
152151

153-
const useDevServer = semver.satisfies(dep.version, '>=18.0.0');
152+
const useDevServer = dep && dep.version && semver.satisfies(semver.minVersion(dep.version), '>=17.2.0');
154153

155-
156154
const defaultResult = {
157-
dev: useDevServer ? '@nx/angular:dev-server' : '@nx/angular:webpack-dev-server',
155+
dev: useDevServer
156+
? '@nx/angular:dev-server'
157+
: '@nx/angular:webpack-dev-server',
158158
prod: '@nx/angular:webpack-browser',
159159
};
160160

libs/native-federation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/native-federation",
3-
"version": "17.1.6",
3+
"version": "17.1.7",
44
"main": "src/index.js",
55
"generators": "./collection.json",
66
"builders": "./builders.json",

libs/native-federation/src/builders/build/builder.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ export async function* runBuilder(
204204
normOuterOptions,
205205
appBuilderName,
206206
context,
207-
nfOptions.skipHtmlTransform ? {} : {
208-
indexHtml: transformIndexHtml,
209-
},
207+
nfOptions.skipHtmlTransform
208+
? {}
209+
: {
210+
indexHtml: transformIndexHtml,
211+
},
210212
{
211213
buildPlugins: plugins,
212214
middleware,

libs/native-federation/src/schematics/init/schematic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ function generateRemoteMap(workspace: any, projectName: string) {
278278
project?.architect?.serve &&
279279
project?.architect?.build
280280
) {
281-
const pPort = project.architect['serve-original']?.options?.port ??
281+
const pPort =
282+
project.architect['serve-original']?.options?.port ??
282283
project.architect.serve?.options?.port ??
283284
4200;
284285
result[

libs/native-federation/src/utils/angular-esbuild-adapter.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,16 @@ async function runEsbuild(
329329
ctx.dispose();
330330
}
331331

332-
cleanUpTsConfigForFederation(tsConfigPath);
332+
// cleanUpTsConfigForFederation(tsConfigPath);
333333

334334
return writtenFiles;
335335
}
336336

337-
function cleanUpTsConfigForFederation(tsConfigPath: string) {
338-
if (tsConfigPath.includes('.federation.')) {
339-
fs.unlinkSync(tsConfigPath);
340-
}
341-
}
337+
// function cleanUpTsConfigForFederation(tsConfigPath: string) {
338+
// if (tsConfigPath.includes('.federation.')) {
339+
// fs.unlinkSync(tsConfigPath);
340+
// }
341+
// }
342342

343343
function createTsConfigForFederation(
344344
workspaceRoot: string,
@@ -372,12 +372,25 @@ function createTsConfigForFederation(
372372
}
373373
}
374374

375+
const content = JSON.stringify(tsconfig, null, 2);
376+
375377
const tsconfigFedPath = path.join(tsconfigDir, 'tsconfig.federation.json');
376-
fs.writeFileSync(tsconfigFedPath, JSON.stringify(tsconfig, null, 2));
378+
379+
if (!doesFileExist(tsconfigFedPath,content)) {
380+
fs.writeFileSync(tsconfigFedPath, JSON.stringify(tsconfig, null, 2));
381+
}
377382
tsConfigPath = tsconfigFedPath;
378383
return tsConfigPath;
379384
}
380385

386+
function doesFileExist(path: string, content: string): boolean {
387+
if (!fs.existsSync(path)) {
388+
return false;
389+
}
390+
const currentContent = fs.readFileSync(path, 'utf-8');
391+
return currentContent === content;
392+
}
393+
381394
function writeResult(
382395
result: esbuild.BuildResult<esbuild.BuildOptions>,
383396
outdir: string,

update-local-mf.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
@REM call npm unpublish @softarc/[email protected] --registry http://localhost:4873
33
@REM call npm unpublish @softarc/[email protected] --registry http://localhost:4873
44
@REM call npm unpublish @angular-architects/[email protected] --registry http://localhost:4873
5-
call npm unpublish @angular-architects/module-federation-tools@17.0.3 --registry http://localhost:4873
6-
call npm unpublish @angular-architects/module-federation-runtime@17.0.3 --registry http://localhost:4873
7-
call npm unpublish @angular-architects/module-federation@17.0.3 --registry http://localhost:4873
5+
call npm unpublish @angular-architects/module-federation-tools@17.0.6 --registry http://localhost:4873
6+
call npm unpublish @angular-architects/module-federation-runtime@17.0.6 --registry http://localhost:4873
7+
call npm unpublish @angular-architects/module-federation@17.0.6 --registry http://localhost:4873
88

99
call npx nx build mf
1010
call npx nx build mf-runtime

update-local.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
call npm unpublish @softarc/native-federation@2.0.8 --registry http://localhost:4873
22
call npm unpublish @softarc/native-federation-runtime@2.0.8 --registry http://localhost:4873
33
call npm unpublish @softarc/native-federation-esbuild@2.0.8 --registry http://localhost:4873
4-
call npm unpublish @angular-architects/native-federation@17.1.5 --registry http://localhost:4873
4+
call npm unpublish @angular-architects/native-federation@17.1.7 --registry http://localhost:4873
55

66
call npx nx build native-federation
77
call npx nx build native-federation-core

0 commit comments

Comments
 (0)