Skip to content

Instantly share code, notes, and snippets.

@amoretspero
Created January 23, 2019 00:47
Show Gist options
  • Save amoretspero/21561d9cd60caad2f81503783faf95e9 to your computer and use it in GitHub Desktop.
Save amoretspero/21561d9cd60caad2f81503783faf95e9 to your computer and use it in GitHub Desktop.
Configuring lerna with existing typescript packages.

Configuring lerna with existing typescript packages.

  1. Create new monorepo directory. (If needed, run git init and add appropriate .gitignore file.)
  2. Run lerna init. If versions of each packages differ from each other, remove version from lerna.json.
  3. Run npm install
  4. Copy existing packages to packages folder.
  5. Remove previous dependencies with each other from all packages.
  6. Set prepublishOnly of package.json of each file to npm run build. (If needed, make "tsconfig.json" at "packages" folder for package references, "tsconfig.settings.json" for common settings to extended by each package's tsconfig.json.)
  7. For packages referencing other package(s), set references of tsconfig.json file.
  8. Set outDir and rootDir of tsconfig.json of each package to appropriate values if needed.
  9. Set main and types of package.json of each package to appropriate values.
  10. Add new dependencies with lerna add <package_name> <glob_pattern> This will add package with name <package_name> to lerna-maintained packages matching <glob_pattern>.
  11. If needed run lerna bootstrap (For most cases, step 6 will run this.)
  12. Run lerna run build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment