nx
nx copied to clipboard
Webpack stuck in an infinite loop while loading two libraries sharing a part of their name.
Current Behavior
on running serve app, application is stuck on Generating app bundles...
The function function collectWorkspaceLibrarySecondaryEntryPoints(library, libraryRoot, tsconfigPathAliases)
in generated node_modules@nrwl\angular\src\utils\mf\mf-webpack.js file is stuck in an infinite while loop.
I believe on tree traversal of two diff libraries that share a part of the name leads to an infinite loop. No way to break it as @examplerepo/example-lib assumes @examplerepo/lib-a is its alias and goes up the tree looking for it's source.
aliases under library @examplerepo/example-lib
: ["@examplerepo/example-lib-a"] (These are two diff libraries in two diff folders)
Path lib: C:\Users\jone-doe\source\repos\reporoot\libs\example-lib-a\src library root: C:\Users\jone-doe\source\repos\reporoot\libs\example-lib
module federation is looking for path lib of example-lib-a (C:\Users\jone-doe\source\repos\reporoot\libs\example-lib-a\src
) in example-lib (C:\Users\jone-doe\source\repos\reporoot\libs\example-lib
)
C:\Users\jone-doe\source\repos\reporoot\libs\example-lib-a
C:\Users\jone-doe\source\repos\reporoot\libs
C:\Users\jone-doe\source\repos\reporoot
C:\Users\jone-doe\source\repos
C:\Users\jone-doe\source
C:\Users\jone-doe
C:\Users
C:\
<---infinite while loop.>
Expected Behavior
Loop terminates on hitting parent directory as it wasn't supposed to be looking in the first place. The two libs are in diff folders, and the wrongly claimed alias is searched for in the next iteration anyway.
Steps to Reproduce
Create two libs, with one using the first part of the other. so lib example-lib
and lib example-lib-a
, create your app,
run npx nx g @nrwl/angular:setup-mf ourapp --mfType=host
on your app to set up module federation. Use both of these libraries in your application, serve app.
A temporary fix Peter Rosser and I found has been to add
const parentDir = (0, path_1.dirname)(searchDir);
if (parentDir === searchDir) {
break;
}
in the generate mf-webpack.js in the while loop in the collectWorkspaceLibrarySecondaryEntryPoints
function. This can't ship in our deploy environment as it's a local fix.
This issue may not be prioritized if details are not provided to help us reproduce the issue.
Failure Logs
No failure log. Just an infinite loop.
Environment
> NX Report complete - copy this into the issue template
Node : 16.15.0
OS : win32 x64
npm : 8.5.5
nx : 13.8.8
@nrwl/angular : 14.5.2
@nrwl/cli : 13.8.8
@nrwl/cypress : 13.8.8
@nrwl/detox : undefined
@nrwl/devkit : 13.8.8
@nrwl/eslint-plugin-nx : 13.8.8
@nrwl/express : undefined
@nrwl/jest : 13.8.8
@nrwl/js : 14.5.2
@nrwl/linter : 13.8.8
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 14.5.2
@nrwl/tao : 13.8.8
@nrwl/web : 14.5.2
@nrwl/workspace : 13.8.8
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
@angular/animations: 13.2.6
@angular/common: 13.2.6
@angular/compiler: 13.2.6
@angular/core: 13.2.6
@angular/forms: 13.2.6
@angular/platform-browser: 13.2.6
@angular/platform-browser-dynamic: 13.2.6
@angular/router: 13.2.6
@ngrx/component-store: 13.0.2
@ngrx/data: 13.0.2
@ngrx/effects: 13.0.2
@ngrx/entity: 13.0.2
@ngrx/router-store: 13.0.2
@ngrx/schematics: 13.0.2
@ngrx/store: 13.0.2
@ngrx/store-devtools: 13.0.2
@angular-devkit/build-angular: 13.3.1
@angular/cli: 13.3.1
@angular/compiler-cli: 13.2.6
@angular/language-service: 13.2.6
@ngrx/schematics: 13.0.2
@ngrx/store-devtools: 13.0.2
@ns3/nx-jest-playwright: 2.6.0
(node:10984) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at C:\Users\t-bngacho\source\repos\mix.ingestionux\node_modules\tslib\package.json.
Update this package.json to use a subpath pattern like "./*".