Giter Club home page Giter Club logo

monorepo-pnpm-seed's Introduction

monorepo-pnpm-seed

This monorepo seed app demonstrates how you can use pnpm to create a monorepo that uses private github repo modules that do not have to be published to the public npm registery to be used. Why? You might want to create a monorepo with a collection of node modules that you want to remain private.

To allow us to do this, we have to use relative paths to each package, and in each use case, the import statement needs to be the same, examples below:

Example 1: When using a module from the monorepo inside another module from the monorepo, you simple import it like so:

import '@example/monorepo/packages/component-module';

Notes:

  • Our monorepo has a name of @example/monorepo, that's why, in the import statement, we then need to reference the package, like /packages/component-module

Example 2: When using a module from the monorepo in an external application

import '@example/monorepo/packages/component-module';

How was this done?

  • Using pnpm and workspaces
  • In the root of the workspace, you should have a pnpm-workspace.yaml file, with the contents
    packages:
    - "packages/*"
    - "."
  • You don't need a tsconfig.json file at the root, this is optional, but could be good if you want all package modules to extend this
  • In the root of the workspace, you should have a .npmrc file, with the contents
    node-linker=hoisted
    symlink=true
    
  • Make sure you have the correct name set in each package.json file
  • Inside the package module that will import other modules, you need to set them in the dependencies in the package.json file, something like:
    "@example/monorepo": "workspace:*",

monorepo-pnpm-seed's People

Contributors

nathan-anderson avatar nathan-andosen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.