nx
nx copied to clipboard
Module Federation not working without barrel imports?
Current Behavior
When I removed barrel imports (index.ts) from tsconfig.base.json and replace it by asterisk I got errors Error: Module not found: Error: Can't resolve '@ng-mf/my-button/*' in
Expected Behavior
No errors when compiling without barrel imports
GitHub Repo
https://github.com/aswarcewicz/nx-ng-dyn-fed/blob/no-barrel-imports-tests/tsconfig.base.json
Steps to Reproduce
- Clone repository https://github.com/aswarcewicz/nx-ng-dyn-fed
- switch to branch
no-barrel-imports-tests - run
npx nx serve dashboard - In console you get
Error: Module not found: Error: Can't resolve '@ng-mf/my-button/*' in '...'
Nx Report
Node : 20.12.2
OS : linux-x64
yarn : 1.22.22
nx (global) : 18.3.4
nx : 18.2.3
@nx/js : 18.2.3
@nx/jest : 18.2.3
@nx/linter : 18.2.3
@nx/eslint : 18.2.3
@nx/workspace : 18.2.3
@nx/angular : 18.2.3
@nx/cypress : 18.2.3
@nx/devkit : 18.2.3
@nx/eslint-plugin : 18.2.3
@nrwl/tao : 18.2.3
@nx/web : 18.2.3
@nx/webpack : 18.2.3
typescript : 5.4.5
---------------------------------------
Registered Plugins:
@nx/cypress/plugin
@nx/eslint/plugin
Failure Logs
Error: Module not found: Error: Can't resolve '@ng-mf/my-button/*' in '...'
Package Manager Version
No response
Operating System
- [ ] macOS
- [X] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
When barrel file is used (index.ts) in tsconfig.base.json like below:
"paths": { ... "@ng-mf/my-button": ["libs/shared/my-button/src/index.ts"],
Everything works as expected