I am trying to create a library with multiple modules in it. My library structure is as below.
I have multiple modules like common-ui.
Problem 1
I have the module and i have index.ts files in each of the folders shown above, and from my public.ts i am doing
export * from 'export * from './common-ui';
This results in the following error
Also i see that lib.metadata.json is empty
{"__symbolic":"module","version":4,"exports":[{"from":"./node-tree/index"}],"metadata":{},"origins":{},"importAs":"@lib/client"}
But if i use barrel file explicitly as below (in all files where barrels are used)
export * from 'export * from './common-ui/index';
the error goes off and things work fine. Do i need to specify the barrel file explicitly ? Is there any way around this ?
Problem 2
After the above thing worked (using index), if i use the barrel and import the files as
import { CommonUiModule, Node } from '@lib/common';
everything works fine. But if i explicitly specify the path as
import { CommonUiModule, Node } from '@lib/common/common-ui';
It results in the following error
Is it happening because of the first error or do we need to add anything special while building the library to access the subfolders as well. Please help.
My tsconfig.lib.json file is as below
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/lib",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}