Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensureNxProject doesn't link together sub dependencies from the same (self) Nx project. #5639

Closed
Brian-McBride opened this issue May 12, 2021 · 6 comments

Comments

@Brian-McBride
Copy link

Current Behavior

In a plugin mono repo, I have a published package @anatine/esbuild-decorators and then a second package @anatine/esbuildnx that requires it.

When running the e2e tests utilizing the devkit tools ensureNxProject will result in the @anatine/esbuild-decorators not being found.

Expected Behavior

The ensureNxProject should properly link up all dependences within the monorepo. That or the docs should specify commands that will link these all properly.

Steps to Reproduce

You can check out the test:
https://github.com/anatine/esbuildnx/blob/main/e2e/esbuildnx-e2e/tests/esbuildnx.spec.ts

TEMP FIX

For now, I've been using the fs-extra lib to create a symbolic link then removing it. Not ideal, but it works most of the time.

  const projectRoot = `${process.cwd()}/tmp/nx-e2e/proj`;
  const esbuildnxPluginModules = `${process.cwd()}/dist/packages/esbuildnx/node_modules`;
  const esbuildnxDecoratorsPlugin = `${process.cwd()}/dist/packages/esbuild-decorators`;

  beforeAll(() => {
    ensureNxProject('@anatine/esbuildnx', 'dist/packages/esbuildnx');
    ensureDirSync(esbuildnxPluginModules);
    ensureSymlinkSync(
      esbuildnxDecoratorsPlugin,
      `${esbuildnxPluginModules}/@anatine/esbuild-decorators`
    );
  });

  afterAll(() => {
    removeSync(esbuildnxPluginModules);
  });

Environment

Node : 16.0.0
OS : darwin x64
npm : 7.10.0

nx : Not Found
@nrwl/angular : Not Found
@nrwl/cli : 12.2.0
@nrwl/cypress : Not Found
@nrwl/devkit : 12.2.0
@nrwl/eslint-plugin-nx : 12.2.0
@nrwl/express : Not Found
@nrwl/jest : 12.2.0
@nrwl/linter : 12.2.0
@nrwl/nest : 12.2.0
@nrwl/next : Not Found
@nrwl/node : 12.2.0
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.2.0
@nrwl/web : Not Found
@nrwl/workspace : 12.2.0
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.1.5

@tinesoft
Copy link
Contributor

Any update on that issue @FrozenPandaz @vsavkin ?

I'm facing a similar problem as @Brian-McBride on my repo tinesoft/nxrocks#79 ... 😐

Having ensureNxProject support sub dependencies would be terrific.

@ronnetzer
Copy link

Facing the same problem,
I was able to overcome it by using patchPackageJsonForPlugin and runPackageManagerInstall after ensureNxProject

@tinesoft
Copy link
Contributor

Hi @ronnetzer

Can you elaborate your solution?
Because ensureNxProject internally called newNxProject which in turn, does already call patchPackageJsonForPlugin followed by runPackageManagerInstall. So I'm wondering why/how does your workaround work...🤔

@ronnetzer
Copy link

@tinesoft Sure,

I was using the patch and install methods to add the dependent packages after the ensure.

So first you have the ensureNxProject for the package you want to test,

Then patchPackageJsonForPlugin to add the missing dependent package and ending with runPackageManagerInstall to install that added package.

It works a little weird as you'll see the npm install running twice, and throws warning for the missing dependent package for the first run (by ensureNxProject)

@AgentEnder AgentEnder self-assigned this Feb 22, 2022
@AgentEnder
Copy link
Member

This issue is a duplicate of #4851, so I'm going to close it. There is some good info here but the link should still show 👍. I'm going to check on this stuff after working on local plugin support.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants