Add Yarn Workspaces Support #9
Description
In a Yarn workspace context, most liferay-npm-scripts
will fail to run from within the workspaces.
Using the attached simple project:
From root folder
yarn install
yarn workspace Foo run build
// works!
From packages/Foo folder
npm run build
// fails!
The main problem is that liferay-npm-scripts
is the only devDependency
on the workspace, so yarn will only create that symlink in the /packages/Foo/node_modules/.bin
folder (as expected).
The binaries for this package dependencies will end up in /node_modules/liferay-npm-scripts/node_modules/.bin
, which are unreachable by npm-which that will only look in CWD
and above.
A possible fix would be to have different npm-which
resolutions:
const cwdWhich = require('npm-which')(process.cwd());
const dirnameWhich = require('npm-which')(__dirname);
let babel;
try {
babel = cwdWhich('babel');
catch () {
babel = dirnameWhich('babel');
}
Note that scripts will work if ran from the root of the project with the yarn workspace Foo run build
command.
Since I've only had limited experience with Yarn, I'm not sure what exactly should be expected... @wincent, any thoughts?