You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node 16 upgrade and peer dependency cleanup (#250)
* feat: drop support for Node 12 and add support for Node 16
BREAKING CHANGE: The Open edX platform is collectively moving towards Node 16. By doing so in this repository, we can now use NPM workspaces in place of Lerna in many places. Lerna is still used for publishing to NPM, updating CHANGELOGs and package.json files upon released. But NPM workspace commands can now be used instead of Lerna commands for the developer experience, which is more performant, easier to reason about, and natively supported by NPM.
Copy file name to clipboardExpand all lines: README.rst
+7-12Lines changed: 7 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,8 @@ To get started with ``frontend-enterprise`` local development, clone the repo an
19
19
::
20
20
21
21
npm run setup
22
-
npm run dev
23
22
24
-
The above commands will install package dependencies, symlinking local packages rather than installing from NPM directly. However, since (most of) the packages in this monorepo contain a build step for Babel transpilation, it necessary to watch changes in the ``src`` directories of each package to re-run the relevant build script(s) as needed (``npm run dev``).
25
-
26
-
Each package is configured to only publish the contents of the generated ``dist`` directory to NPM; this behavior gets replicated in the local symlinking of packages as well, which is why it is necessary to watch the source files for changes and re-build the ``dist`` directory when they do change. This ensures the symlinked packages will always contain the correct packages. It is recommended to run ``npm run dev`` in a separate terminal tab or window so you may run other commands as needed while source files are still being watched/transpiled.
23
+
The above command will install package dependencies using NPM workspaces, hoisting all packages to `node_modules` at the root of the repository for performance reasons (e.g., there will only be one copy of React). By using NPM workspaces, `npm install` knows that when importing a package that is part of this monorepo (e.g., `@edx/frontend-enterprise-utils`), it should look at the local package folder and creates symlinks accordingly.
27
24
28
25
Other useful commands for linting and testing may include:
29
26
@@ -32,20 +29,18 @@ Other useful commands for linting and testing may include:
32
29
npm run lint
33
30
npm run test
34
31
35
-
The above NPM scripts are running Lerna commands behind-the-scenes. By default, it will run the associated NPM command in each package in the monorepo. However, Lerna provides a mechanism to only run tests for a specific package(s), for example:
32
+
The above NPM scripts are run via NPM workspaces behind-the-scenes. By default, it will run the associated NPM command in each package in the monorepo. However, NPM workspaces does provide a mechanism to only run tests for a specific package, for example:
36
33
37
34
::
38
35
39
-
lerna run test --scope=@edx/frontend-enterprise-catalog-search
36
+
npm run test -w @edx/frontend-enterprise-catalog-search
40
37
41
38
To clean your local monorepo of any installed ``node_modules`` and symlinked packages to start fresh, you may run:
42
39
43
40
::
44
41
45
42
npm run clean
46
43
47
-
See https://github.com/lerna/lerna for full documentation of Lerna commands.
48
-
49
44
Installing local monorepo package(s) from an edX micro-frontend
50
45
-----
51
46
@@ -83,9 +78,7 @@ Each package in the monorepo contains its own package.json file and unique set o
83
78
84
79
To get around this issue of common/shared dependencies, we can rely on how NPM finds installed packages. If a package does not exist in ``node_modules`` for an individual package, NPM will look in ``node_modules`` further up the directory tree until it finds the package, or gets to the root of the repository.
85
80
86
-
By installing these common dependencies at the root package.json file, they will be accessible to any package in the monorepo to ensure there is only one copy of them used throughout. These dependencies are still noted in each individual package.json file as a peer dependency but not as a dev dependency since they are already installed in ``node_modules`` at the root of the repository.
87
-
88
-
As such, we should pay extra attention to managing dependencies in each packages, making informed decisions about whether a dependency should be included in an individual package's package.json file or the package.json file at the root of the repository.
81
+
NPM workspaces helps with this by hoisting installed packages to the root `node_modules` folder where they will be accessible to any package in the monorepo to ensure there is only one copy used throughout. These dependencies are still noted in each individual package.json file as both a peer dependency and a dev dependency.
89
82
90
83
Writing a commit
91
84
-----
@@ -96,6 +89,8 @@ There is a precommit plugin (commitlint) which requires commit messages formatte
96
89
97
90
where type must be one of ``[build, ci, docs, feat, fix, perf, refactor, revert, style, test]``
98
91
92
+
Note: only `fix`, `feat`, and `perf` will trigger a new NPM release, as this is the default behavior for semantic-release.
93
+
99
94
Versioning and releases
100
95
*****
101
96
@@ -108,7 +103,7 @@ To publish the packages that had their versions incremented, you must manually t
108
103
Preview changed packages in CI with Github Actions
109
104
-----
110
105
111
-
As a convenience, the ``lerna changed`` command is run for each push to determine which packages in the monorepo will be published should a PR get merged.
106
+
As a convenience, a dry run of the ``lerna version`` command is run for each push to determine which packages in the monorepo will be published should a PR get merged.
0 commit comments