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

Local generator is executing tmp index file when importing from @nx/devkit #19181

Closed
1 of 4 tasks
Roozenboom opened this issue Sep 15, 2023 · 2 comments
Closed
1 of 4 tasks
Assignees

Comments

@Roozenboom
Copy link
Contributor

Current Behavior

When you have a local (nx plugin) generator that imports from @nx/devkit it also compiles and executes the barrel file (index.ts/js) in your tmp folder. It doesn't matter if the tmp folder is ignored (git) / excluded (tsconfig).

To illustrate the issue I created an example repo (https://github.com/Roozenboom/nx-examples/tree/local-generator-tmp-index) that has a nx plugin with a simple generator and a tmp/index.ts file that only does a console.log. When the generator is executed the console.log is also displayed.
Screenshot 2023-09-15 at 11 11 14

When the imports of @nx/devkit are removed from the generator the console.log from the tmp folder is not shown anymore.
Screenshot 2023-09-15 at 11 12 55
result:
Screenshot 2023-09-15 at 11 12 42

The issue is very specific to index (barrel) files in the tmp folder. If I rename the folder to for example 'temp' or the file to main.ts the console.log is not displayed.

Expected Behavior

I would not expect the tmp/index.ts file to be compiled/executed when I run a generator.

GitHub Repo

nrwl/nx-examples#297

Steps to Reproduce

  1. Checkout branch https://github.com/Roozenboom/nx-examples/tree/local-generator-tmp-index
  2. Install dependencies: yarn install
  3. Execute generator: yarn nx g @nx-example/local-nx-plugin:example-generator test --dry-run

Files to check are:

  • tools/local-nx-plugin/src/generators/example-generator/generator.ts
  • tmp/index.ts

Nx Report

Node   : 20.6.1
   OS     : darwin-arm64
   yarn   : 1.22.19
   
   nx                 : 16.8.1
   @nx/js             : 16.8.1
   @nx/jest           : 16.8.1
   @nx/linter         : 16.8.1
   @nx/workspace      : 16.8.1
   @nx/angular        : 16.8.1
   @nx/cypress        : 16.8.1
   @nx/devkit         : 16.8.1
   @nx/eslint-plugin  : 16.8.1
   @nx/plugin         : 16.8.1
   @nx/react          : 16.8.1
   @nrwl/tao          : 16.8.1
   @nx/web            : 16.8.1
   @nx/webpack        : 16.8.1
   nx-cloud           : 16.4.0
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.1
   @ngrx/effects         : 16.0.1
   @ngrx/entity          : 16.0.1
   @ngrx/router-store    : 16.0.1
   @ngrx/store           : 16.0.1
   @ngrx/store-devtools  : 16.0.1
   ---------------------------------------
   Local workspace plugins:
         @nx-example/local-nx-plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder added the scope: core core nx functionality label Sep 22, 2023
@AgentEnder AgentEnder self-assigned this Sep 27, 2023
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! 🙏

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 May 10, 2024
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

2 participants