chore: Replace Lerna 2.x with npm workspaces#170
Merged
Conversation
npm workspaces hoists dependencies to the root node_modules/, so hardcoded paths like packages/playground/node_modules/mobx no longer exist. Use require.resolve to find packages wherever they are installed.
…ances With npm workspaces, mobx-react is hoisted to root node_modules/ and resolves react from there (React 15), while the playground source resolves its own React 16. Two React instances break the app. Pin react and react-dom aliases to the playground's local copies so all code in the bundle shares a single React instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
^2.4.0, from 2017) andlerna.jsonin favor of npm workspaces, which is built into npm 7+ and requires zero additional dependencies."workspaces": ["packages/*"]to the rootpackage.jsonso npm automatically links the three workspace packages (mobx-devtools,mobx-devtools-mst,playground).0.9.32) fromlerna.jsoninto the rootpackage.jsonversionfield.bootstrapscript fromnpm install && lerna bootstrapto justnpm install --legacy-peer-deps(npm workspaces handles hoisting and linking).buildscript fromlerna run buildtonpm run build --workspaces --if-present.scripts/bump-version.jsandscripts/webextension/prepare.jsto read version frompackage.jsoninstead oflerna.json..github/workflows/release.ymlto read version frompackage.jsoninstead oflerna.json.Motivation
Lerna 2.4.0 is from 2017 and is no longer maintained. npm workspaces (available since npm 7, included with Node 14+) provides the same monorepo capabilities -- package linking, hoisted dependencies, and cross-workspace script execution -- with zero extra dependencies. This project already requires Node 20 (per
.nvmrc), so npm workspaces is available out of the box.