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

core: build/package executors should include only implementation files for package.json#dependencies generation from project-graph #8641

Closed
Hotell opened this issue Jan 21, 2022 · 5 comments

Comments

@Hotell
Copy link
Contributor

Hotell commented Jan 21, 2022

Current Behavior

This occurs in every executor related to packaging/building. For simplicity I'd describe behaviour for @nrwl/node:package executor.

1. We have following dep-graph (contrived for simplicity)

2022-01-21 at 15 03

now when running nx run @griffel/jest-serializer:build

following package.json will be generated:

"dependencies":  {
    // repo pacakges
    "@griffel/react": "1.0.0",
    "@griffel/core": "1.0.7",
    "@griffel/hello": "0.0.1"

     // npm packages - those are used in core and react
    "stylis": "^4.0.13",
    "@emotion/hash": "^0.8.0",
    "rtl-css-js": "^1.15.0",
    "csstype": "^2.6.19"
}

💡 Note: npm packages and @griffel/react shouldn't be here as well - see #8640

based on following dependency graph creation (nx print-affected --target=build):

"dependencies": {
      "@griffel/jest-serializer": [
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/jest-dom",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:react",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/react",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "@griffel/hello",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "@griffel/core",
          "type": "static"
        }
      ],
}

2. If we remove import statements for @griffel/core from implementation files of @griffel/jest-serializer package

2022-01-21 at 15 08

following package.json will be generated:

"dependencies":  {
  "@griffel/hello": "0.0.1"
}

based on following dependency graph creation (nx print-affected --target=build):

"dependencies": {
"@griffel/jest-serializer": [
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/jest-dom",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:react",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/react",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "@griffel/hello",
          "type": "static"
        }
      ],
}

3. Now only if we remove @griffel/hello from our test file we'll get no dependencies as expected

2022-01-21 at 15 11

following package.json will be generated:

"dependencies": {}

based on following dependency graph creation (nx print-affected --target=build):

"dependencies": {
"@griffel/jest-serializer": [
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/jest-dom",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:react",
          "type": "static"
        },
        {
          "source": "@griffel/jest-serializer",
          "target": "npm:@testing-library/react",
          "type": "static"
        }
      ],
}

Expected Behavior

  • During package.json generation executed while running package/build executors, dependency graph should be filtered/processed to include only implementation files for package.json generation.

Based on our original dependency graph:
2022-01-21 at 15 03

Following package.json should be generated:

"dependencies":  {
    // repo packages
    "@griffel/core": "1.0.7",
}
  • .nxignore should be included in filtering as currently it is omitted as well.

Steps to Reproduce

Failure Logs

Environment

Node : 14.18.1
  OS   : darwin x64
  yarn : 3.1.1
  
  nx : 13.4.6
  @nrwl/angular : undefined
  @nrwl/cli : 13.4.6
  @nrwl/cypress : 13.4.6
  @nrwl/devkit : 13.4.6
  @nrwl/eslint-plugin-nx : 13.4.6
  @nrwl/express : undefined
  @nrwl/jest : 13.4.6
  @nrwl/linter : 13.4.6
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : 13.4.6
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.4.6
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.4.6
  @nrwl/web : 13.4.6
  @nrwl/workspace : 13.4.6
  @nrwl/storybook : 13.4.6
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 6.6.7
  ---------------------------------------
  Community plugins:
         @nrwl/js: 13.4.6
@Hotell Hotell changed the title core: build executors don't filter actual package dependencies from project-graph core: build/package executors should include only implementation files for package dependencies generation from project-graph Jan 21, 2022
@Hotell Hotell changed the title core: build/package executors should include only implementation files for package dependencies generation from project-graph core: build/package executors should include only implementation files for package.json#dependencies generation from project-graph Jan 21, 2022
@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Jan 29, 2022
@egorderg
Copy link

I think it's the same problem like in #8640.
Will the solution also be integrated into @nrwl/js:tsc? I have currently some npm packages where i create them with js:tsc and don't want the recursive dependencies.

@github-actions
Copy link

github-actions bot commented Sep 9, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Sep 9, 2022
@tinesoft
Copy link
Contributor

@egorderg the solution was integrated to @nrwl/js:tsc in #10600, before being reverted because it caused other issues...
No other update so far...

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@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 Apr 26, 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

4 participants