Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Imports from a lerna shared package seem to require src at the end of the name (Typescript/javascript)

I have a simple lerna project like:

Project
 |    
 +-- packages
 |  |  
 |  +-- shared
 |  |  |
 |  |  +-- src
 |  |       |  
 |  |       +-- index.ts
 |  |       +-- someDir   
 |  |
 |  +-- usesShared
 |
 +

My index.ts has entries like:

export * from "./someDir";

When I import a class from someDir in a "usesShared" class, I am having to put /src at the end of the import like:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import {GreatClass} from "myShared/src";

I am new to Typescript, javascript, & lerna but this seems wrong to me. It seems like it should just be:

import {GreatClass} from "myShared";

Can someone point me towards how to fix this? Does this have something to do with lerna or am I missing something in package.json?

>Solution :

In "shared" or "myShared" (not sure what you named it), create index.ts:

export * from "./src";

To import the class from usesShared:

import { GreatClass } from "../myShared";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading