I have two libraries, mat-text-editor
and mat-text-editor-select
, the former uses the component of the latter, which works fine. mat-text-editor-select
also includes a regular typescript class, mat-text-editor-select-option
, which I want to export alongside the mat-text-editor-select-component
so I can use it in the mat-text-editor
module.
I can import the file like this:
import { MatTextEditorSelectOption } from "projects/mat-text-editor-select/src/mat-text-editor-select-option";
This is recognized but throws an error when I try to build the text-editor library: File 'D:/Documents/Websites/angular-material-extension/projects/mat-text-editor-select/src/mat-text-editor-select-option.ts' is not under 'rootDir' 'D:\Documents\Websites\angular-material-extension\projects\mat-text-editor\src'. 'rootDir' is expected to contain all source files.
I've added export * from './mat-text-editor-select-option';
to the public-api.ts of the mat-text-editor-select
library and tried to import the class like this:
import { MatTextEditorSelectOption } from "mat-text-editor-select/mat-text-editor-select-option";
but VS Code complains it cannot find the module. I've also tried:
import { MatTextEditorSelectOption } from "mat-text-editor-select";
but it says mat-text-editor-select has no exported member named MatTextEditorSelectOption, which I'm surprised because shouldn't it have now? What else do I need to do to export/import the class from one library to the other?
It seems like an exported regular typescript class is part of the package, but not of the module, thus I couldn't import the class from the mat-text-editor
library by targeting the module. You need to target the package, i.e. the one in the dist folder after building the exported library.
Instead of:
import { MatTextEditorSelectOption } from "mat-text-editor-select/mat-text-editor-select-option";
You have to write:
import { MatTextEditorSelectOption } from "dist/mat-text-editor-select/mat-text-editor-select-option";