Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Add Yarn Workspaces Support #9

Closed
@jbalsas

Description

@jbalsas

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?

yarn_workspaces.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions