Skip to content

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

@Roozenboom

Description

@Roozenboom

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions