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-projectsmonorepo and more specifically to the to themaintenance/projects/js-toolkit/docsdirectory. 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.jsonfile 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 lernain the local Liferay JS Toolkit. - Run
npm run buildin the local Liferay JS Toolkit (just in case). - Delete
package-lock.jsonandnode_modulesin your test project. - Run
npm installin 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-toolkitproject. This will install a CLI command namedlink-js-toolkitin your machine. Again, this must be done once for the life. -
Run
link-js-toolkitin 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!