When referencing a Typescript barrel then metadata will not be generated by ng-packagr
.
When you run
# same as: ng-packagr -p package.json
yarn build
You can see that the generated dist/ngpackagr-barrel-issue.metadata.json
misses all metadata info of the DummyModule
:
{"__symbolic":"module","version":4,"exports":[{"from":"./src"}],"metadata":{},"origins":{},"importAs":"ngpackagr-barrel-issue"}
When you change the public_api.ts
to reference the index.ts
file specifically:
export * from './src/index';
You can see that the generated dist/ngpackagr-barrel-issue.metadata.json
is generating the appropriate metadata:
{"__symbolic":"module","version":4,"exports":[{"from":"./src/sub"}],"metadata":{"DummyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":4,"character":12}]}]}],"members":{}}},"origins":{"DummyModule":"./src/dummy.module"},"importAs":"ngpackagr-barrel-issue"}
But notice that this counts for all the Typescript barrels in your application, the ./src/sub
module which is referenced in the ./src/index.ts
file also needs to be changed to explicit /index
rederences:
export * from './sub/index';
export * from './dummy.module';
So that all the metadata is generated in dist/ngpackagr-barrel-issue.metadata.json
is correct:
{"__symbolic":"module","version":4,"metadata":{"SubModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":4,"character":12}]}]}],"members":{}},"DummyModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":3,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":4,"character":12}]}]}],"members":{}}},"origins":{"SubModule":"./src/sub/sub.module","DummyModule":"./src/dummy.module"},"importAs":"ngpackagr-barrel-issue"}