nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.58k stars 2.36k forks source link

Cannot import default exported generators #12434

Closed BartKoppelmans closed 2 years ago

BartKoppelmans commented 2 years ago

Current Behavior

When importing a default-exported generator such as the @nrwl/angular:remote generator, it cannot be found as exported through the barrel. The import import { remote } from '@nrwl/angular/generators' thus fails to load. Generators that are both exported and default exported (such as @nrwl/workspace:library) seem to work just fine.

Deep exports such as import remote from '@nrwl/angular/src/generators/remote/remote' or import { remote } from '@nrwl/angular/src/generators/remote/remote' seem to fail as will, since the package.json does not export them (as was expected).

Upon first inspection, this seems to also apply other generators following the same export style:

Expected Behavior

The import should be exported normally, as well as default-exported.

Steps to Reproduce

  1. Create a new plugin with generator.
  2. Import the remote generator.
  3. Fails

Failure Logs

TypeError: (0 , _generators.remote) is not a function
    at mcAngularRemoteGeneratorImplementationStep (C:\Users\s155643\Documents\Side_projects\CryptoSimulator\mimicry\packages\workspace\src\generators\angular\remote\generator.ts:49:36)
    at mcAngularRemoteGenerator (C:\Users\s155643\Documents\Side_projects\CryptoSimulator\mimicry\packages\workspace\src\generators\angular\remote\generator.ts:77:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Environment

pnx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.14.0
   OS   : win32 x64
   pnpm : 7.12.2

   nx : 14.7.17
   @nrwl/angular : 14.7.17
   @nrwl/cypress : 14.7.17
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.7.17
   @nrwl/eslint-plugin-nx : 14.7.17
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.7.17
   @nrwl/js : 14.7.17
   @nrwl/linter : 14.7.17
   @nrwl/nest : 14.7.17
   @nrwl/next : Not Found
   @nrwl/node : 14.7.17
   @nrwl/nx-cloud : 14.6.2
   @nrwl/nx-plugin : 14.7.17
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.7.17
   @nrwl/web : 14.7.5
   @nrwl/workspace : 14.7.17
   typescript : 4.8.3
   ---------------------------------------
   Local workspace plugins:
         @mimicry/workspace
         @mimicry/devkit
   ---------------------------------------
   Community plugins:
         @ng-bootstrap/ng-bootstrap: 13.0.0
         @ngrx/component-store: 14.3.1
         @ngrx/effects: 14.3.1
         @ngrx/entity: 14.3.1
         @ngrx/router-store: 14.3.1
         @ngrx/store: 14.3.1
         @ngrx/schematics: 14.3.1
         @ngrx/store-devtools: 14.3.1
         ng-mocks: 14.2.1
neilsoult commented 2 years ago

I was just noticing this today as I was attempting to create a custom generator that would use the angular remote generator.

github-actions[bot] commented 1 year ago

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.