nrwl / nx

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

@nrwl v8 packages: losen @angular-devkit dependency versions #2661

Closed ctaepper closed 3 years ago

ctaepper commented 4 years ago

Please make sure you have read the submission guidelines before posting an issue

Expected Behavior

For @nrwl packages to use the projects version of @angular-devkit dependencies

Current Behavior

@angular-devkit dependencies are pinned to 8.3.23, which leads to type mismatches if the project has another version installed

Steps to Reproduce

  1. npx create-nx-plugin@8 my-org --pluginName my-plugin
  2. in the new workspace npm install @angular-devkit/{core,schematics}@8.3.25 to simulate existing dependencies
  3. ng build my-plugin <-- breaks

Context

I try to use the nx-plugin package to create my own plugins in an existing ng turned nx workspace. So I have angular cli and angular-devkit deps installed in the project. Also, in my case it is an angular 8 project with nx 8.12.10 dependencies

Failure Logs

➜  theproject git:(compodoc-plugin) ✗ ng build plugins-demo
Compiling TypeScript files...
libs/plugins/demo/src/schematics/plugins-demo/schematic.ts:65:5 - error TS2322: Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Rule' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Rule'.
  Types of parameters 'context' and 'context' are incompatible.
    Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>'.
      Types of property 'engine' are incompatible.
        Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Engine<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Engine<{}, {}>'.
          Types of property 'createCollection' are incompatible.
            Type '(name: string) => import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Collection<{}, {}>' is not assignable to type '(name: string) => import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Collection<{}, {}>'.
              Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Collection<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Collection<{}, {}>'.
                Types of property 'createSchematic' are incompatible.
                  Type '(name: string, allowPrivate?: boolean) => import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Schematic<{}, {}>' is not assignable to type '(name: string, allowPrivate?: boolean) => import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Schematic<{}, {}>'.
                    Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Schematic<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Schematic<{}, {}>'.
                      Types of property 'call' are incompatible.
                        Type '<OptionT extends object>(options: OptionT, host: import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable").Observable<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/tree/interface").Tree>, ...' is not assignable to type '<OptionT extends object>(options: OptionT, host: import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable").Observable<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics...'.
                          Types of parameters 'parentContext' and 'parentContext' are incompatible.
                            Type 'Partial<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>>' is not assignable to type 'Partial<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>>'.
                              Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").TypedSchematicContext<{}, {}>'.
                                Types of property 'engine' are incompatible.
                                  Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Engine<{}, {}>' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Engine<{}, {}>'.
                                    Types of property 'workflow' are incompatible.
                                      Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/workflow/interface").Workflow' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/workflow/interface").Workflow'.
                                        Types of property 'context' are incompatible.
                                          Type 'Readonly<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/workflow/interface").WorkflowExecutionContext>' is not assignable to type 'Readonly<import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/workflow/interface").WorkflowExecutionContext>'.
                                            Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/workflow/interface").WorkflowExecutionContext' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/workflow/interface").WorkflowExecutionContext'.
                                              Types of property 'logger' are incompatible.
                                                Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/core/src/logger/logger").Logger' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/core/src/logger/logger").Logger'.
                                                  Property '_subject' is protected but type 'Logger' is not a class derived from 'Logger'.

 65     updateWorkspace(workspace => {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 66       workspace.projects
    ~~~~~~~~~~~~~~~~~~~~~~~~
... 
 76         })
    ~~~~~~~~~~
 77     }),
    ~~~~~~

libs/plugins/demo/src/schematics/plugins-demo/schematic.ts:78:5 - error TS2322: Type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@nrwl/workspace/node_modules/@angular-devkit/schematics/src/engine/interface").Rule' is not assignable to type 'import("/Users/ct/projects/man/man-platform/ui/theproject/node_modules/@angular-devkit/schematics/src/engine/interface").Rule'.

78     addProjectToNxJsonInTree(normalizedOptions.projectName, { tags: normalizedOptions.parsedTags }),
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 errors.

Could not compile Typescript files    
vsavkin commented 4 years ago

We tried it earlier on and it ended up being too problematic because of devkit introducing breaking changes in patch releases. It's more stable now, so we might try it again.

The problem you are you having now is that you have two versions of the packages, so two versions of the same class. You could set up your workspace to have a single version of the package (see here: https://github.com/nrwl/nx/issues/2458). This will likely resolve your issue.

github-actions[bot] commented 3 years ago

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[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.