Here's a repo that reproduces it: https://github.com/dragonflypl/ng-packagr-issue
logging. npm run build generates the library + does npm packfooGui with Angular CLI and installed library it via npm run consume that installs tgznpm run build from fooGui throws:ERROR in ./src/app/app.component.ngfactory.js
Module not found: Error: Can't resolve 'logging/src/modules/logging/logger/index' in 'C:\XXX\dev\ng-packagr-issue\fooGui\src\app'
resolve 'logging/src/modules/logging/logger/index' in 'C:\XXX\dev\ng-packagr-issue\fooGui\src\app'
Parsed request is a module
using description file: C:\XXX\dev\ng-packagr-issue\fooGui\package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\XXX\dev\ng-packagr-issue\fooGui\package.json (relative path: ./src/app)
resolve as module
C:\XXX\dev\ng-packagr-issue\fooGui\src\app\node_modules doesn't exist or is not a directory
C:\XXX\dev\ng-packagr-issue\fooGui\src\node_modules doesn't exist or is not a directory
C:\XXX\dev\ng-packagr-issue\node_modules doesn't exist or is not a directory
C:\XXX\dev\node_modules doesn't exist or is not a directory
C:\XXX\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
looking for modules in C:\XXX\dev\ng-packagr-issue\fooGui\node_modules
using description file: C:\XXX\dev\ng-packagr-issue\fooGui\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\XXX\dev\ng-packagr-issue\fooGui\package.json (relative path: ./node_modules)
using description file: C:\XXX\dev\ng-packagr-issue\fooGui\node_modules\logging\package.json (relative path: ./src/modules/logging/logger/index)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\XXX\dev\ng-packagr-issue\fooGui\node_modules\logging\src\modules\logging\logger\index doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\XXX\dev\ng-packagr-issue\fooGui\node_modules\logging\src\modules\logging\logger\index.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\XXX\dev\ng-packagr-issue\fooGui\node_modules\logging\src\modules\logging\logger\index.js doesn't exist
as directory
C:\XXX\dev\ng-packagr-issue\fooGui\node_modules\logging\src\modules\logging\logger\index doesn't exist
Any idea what I did wrong or it is a bug somewhere?
I've found the culprit: in public api file, I have:
export * from './src/modules/logging/logger'; that access index.ts.
When I replaced it with explicit it with explicit exports:
export * from './src/modules/logging/logger/logger.service';
export * from './src/modules/logging/logger/log-level.enum';
then it works. Any idea why?
Hi @dragonflypl,
I don't know why it happens.
index.ts files.Can you confirm if either of the above and, if yes, which is your issue? That'll help to put up a good repro and then try to get a fix in.
Info: user runs:
$ cd path/to/library-sources
$ npm pack dist
$ cd path/to/cli-app-project
$ npm install ../logging/dist/logging-1.0.0-rc.1.tgz
$ ng build --prod
The issue with barrels isn't usually barrels themselves but it is easy to cause
a circular dependency with them which is often times what causes this issue,
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
_This action has been performed automatically by a bot._
Most helpful comment
The issue with barrels isn't usually barrels themselves but it is easy to cause
a circular dependency with them which is often times what causes this issue,