GaryB432 / gb-generators

my Yeoman generators
ISC License
9 stars 2 forks source link

The main purpose of lerna, that is, using one package from another, is there an example for that to ,Add a package as a dependency to one of your package #13

Closed debender495 closed 4 years ago

debender495 commented 4 years ago

Let's say package greeting has function returning 'hi', and I want to use this function from other package say B. how can I add the dependencies of the greeting in the package B

GaryB432 commented 4 years ago

This would work

yo lerna-typescript:package @demo/adder yo lerna-typescript:package @demo/calculator lerna add @demo/adder --scope=@demo/calculator

// packages/calculator/src/index.ts
import { add } from '@demo/adder';

function multiply(a: number, b: number): number {
  return add(a, b) * 2;
}

console.log(multiply(2, 3));

lerna bootstrap node ./packages/calculator

see 10