How to use locally modified Liferay JS Toolkit tools - liferay/liferay-js-toolkit GitHub Wiki
:warning: The contents of this wiki have been migrated to the
liferay/liferay-frontend-projects
monorepo and more specifically to the to themaintenance/projects/js-toolkit/docs
directory. Development and updates will continue there, and this repo will be archived (ie. switched to read-only mode).
If you clone this project to make some modifications to any of its sources you will then want to test what you did, probably.
Sadly, what should be an easy task turns out to be a bit hard due to interoperation between lerna
, npm
and, if used, yarn
too.
To ease this task we propose two workflows depending on the package manager being used.
npm
If the project where you want to use the locally modified Toolkit uses npm
follow these steps:
- Change any reference in your
package.json
file to Liferay JS Toolkit tools from a version number to the path to the local project. - Delete your project's
package-lock.json
. - Run
npm install
.
That should be enough, but because sometimes step 3 destroys lerna
's links in Liferay JS Toolkit (especially if you forgot to do step 2), you may need to do the following if any Toolkit tool execution fails in your project:
- Run
npm run lerna
in the local Liferay JS Toolkit. - Run
npm run build
in the local Liferay JS Toolkit (just in case). - Delete
package-lock.json
andnode_modules
in your test project. - Run
npm install
in your test project.
That should leave your test project linked to the local JS Toolkit and the local JS Toolkit correctly linked to itself as lerna
expects it to be.
yarn
If the project where you want to use the locally modified Toolkit uses yarn
you just need to follow these steps:
-
Run yarn link in every project inside
liferay-js-toolkit/packages
. This must be done just once for your life for each new project insideliferay-js-toolkit/packages
. So, as long, as no new projects are added, once you run this step you may forget about it. -
Run npm link in the
liferay-js-toolkit/resources/devtools/link-js-toolkit
project. This will install a CLI command namedlink-js-toolkit
in your machine. Again, this must be done once for the life. -
Run
link-js-toolkit
in your yarn-based project. This script will run yarn link package under the hood for each Liferay JS Toolkit dependency. Because you have made them available in step 1, your project will be connected to your local copy of the Toolkit. -
Enjoy development!