Why lerna does not take peerDependencies into account when build packages

Viewed 1263

Although I came across this problem in react admin but I think it is not related to react-admin itself:

I have some packages in my project as below:

enter image description here

Now imagine the ra-data-simple-rest/package.json is as follow:

{
    "name": "ra-data-simple-rest",
    "version": "3.5.5",
    "description": "Simple REST data provider for react-admin",
    "main": "lib/index.js",
    "module": "esm/index.js",
    "sideEffects": false,
    "files": [
        "*.md",
        "lib",
        "esm",
        "src"
    ],
    "authors": [
        "François Zaninotto"
    ],
    "repository": "marmelab/react-admin",
    "homepage": "https://github.com/marmelab/react-admin#readme",
    "bugs": "https://github.com/marmelab/react-admin/issues",
    "license": "MIT",
    "scripts": {
        "build": "yarn run build-cjs && yarn run build-esm",
        "build-cjs": "rimraf ./lib && tsc",
        "build-esm": "rimraf ./esm && tsc --outDir esm --module es2015",
        "watch": "tsc --outDir esm --module es2015 --watch"
    },
    "dependencies": {
        "query-string": "^5.1.1"
    },
    "devDependencies": {
        "cross-env": "^5.2.0",
        "rimraf": "^2.6.3"
    },
    "peerDependencies": {
        "ra-core": "^3.0.0"
    }
}

So it has ra-core as its peer dependency.

Now imagine my lerna.json file is as follows:

{
  "lerna": "2.5.1",
  "packages": [
    "examples/data-generator",
    "packages/*"
  ],
  "version": "3.7.0"
}

When I run lerna run build command it first build ra-data-simple-rest and because ra-core haven't been built yet it complains that ra-core does not export some modules. In my imagination lerna should first build ra-core and then ra-data-simple-rest since ra-data-simpe-rest has ra-core as its peerdependency but it does not do that why? when I put ra-core to dependecy section the problem is solved.

0 Answers
Related