ui5-tooling icon indicating copy to clipboard operation
ui5-tooling copied to clipboard

Fix handling of circular dependencies between UI5 projects

Open RandomByte opened this issue 5 years ago • 0 comments

Expected Behavior

Just like https://github.com/SAP/ui5-project/pull/53 made the npm translator remove circular references from a dependency tree, the projectProcessor should also take care that the resulting tree does not contain circular references.

Current Behavior

Even when supplied with a non-circular dependency tree, the projectPreprocessor applies a different kind of deduplication, which currently re-adds circular references to the tree.

Steps to reproduce the issue

  1. Clone this repository (ui5-project)
  2. Navigate to cd test/fixtures/cyclic-deps/node_modules/application.cycle.f
  3. Execute ui5 tree and ui5 tree --dedupe to see that the npm translator correctly removes circular references in the tree
  4. Execute ui5 tree --dedupe --full --json. This should result in an error:
TypeError: Converting circular structure to JSON

This will cause infinite loops in following modules like the UI5 FS resourceFactory.

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): 1.2.0
  • Node.js Version: v11.8.0
  • npm Version: 6.8.0
  • OS/Platform: macOS

Affected components (if known)

Log Output / Stack Trace

Output from running different ui5 tree commands in ui5-project/test/fixtures/cyclic-deps/node_modules/application.cycle.f

ui5 tree

├─ id: application.cycle.f
├─ version: 1.0.0
├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/application.cycle.f
└─ dependencies
   ├─ 0
   │  ├─ id: library.cycle.c
   │  ├─ version: 1.0.0
   │  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
   │  └─ dependencies
   │     └─ 0
   │        ├─ id: library.cycle.d
   │        ├─ version: 0.9.0
   │        ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c/node_modules/library.cycle.d
   │        └─ dependencies
   │           ├─ 0
   │           │  ├─ id: library.cycle.c
   │           │  ├─ version: 1.0.0
   │           │  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
   │           │  ├─ dependencies
   │           │  └─ deduped: true
   │           └─ 1
   │              ├─ id: library.cycle.e
   │              ├─ version: 1.0.0
   │              ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
   │              └─ dependencies
   │                 └─ 0
   │                    ├─ id: library.cycle.c
   │                    ├─ version: 1.0.0
   │                    ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
   │                    ├─ dependencies
   │                    └─ deduped: true
   └─ 1
      ├─ id: library.cycle.d
      ├─ version: 1.0.0
      ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.d
      └─ dependencies
         ├─ 0
         │  ├─ id: library.cycle.c
         │  ├─ version: 1.0.0
         │  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
         │  └─ dependencies
         │     └─ 0
         │        ├─ id: library.cycle.d
         │        ├─ version: 0.9.0
         │        ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c/node_modules/library.cycle.d
         │        ├─ dependencies
         │        └─ deduped: true
         └─ 1
            ├─ id: library.cycle.e
            ├─ version: 1.0.0
            ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
            └─ dependencies
               └─ 0
                  ├─ id: library.cycle.c
                  ├─ version: 1.0.0
                  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
                  └─ dependencies
                     └─ 0
                        ├─ id: library.cycle.d
                        ├─ version: 0.9.0
                        ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c/node_modules/library.cycle.d
                        ├─ dependencies
                        └─ deduped: true
ui5 tree --dedupe

├─ id: application.cycle.f
├─ version: 1.0.0
├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/application.cycle.f
└─ dependencies
   ├─ 0
   │  ├─ id: library.cycle.c
   │  ├─ version: 1.0.0
   │  ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
   │  └─ dependencies
   │     └─ 0
   │        ├─ id: library.cycle.d
   │        ├─ version: 0.9.0
   │        ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c/node_modules/library.cycle.d
   │        └─ dependencies
   │           └─ 0
   │              ├─ id: library.cycle.e
   │              ├─ version: 1.0.0
   │              ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
   │              └─ dependencies
   └─ 1
      ├─ id: library.cycle.d
      ├─ version: 1.0.0
      ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.d
      └─ dependencies
         ├─ 0
         │  ├─ id: library.cycle.c
         │  ├─ version: 1.0.0
         │  ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
         │  └─ dependencies
         └─ 1
            ├─ id: library.cycle.e
            ├─ version: 1.0.0
            ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
            └─ dependencies
               └─ 0
                  ├─ id: library.cycle.c
                  ├─ version: 1.0.0
                  ├─ path: /ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
                  └─ dependencies
ui5 tree --dedupe --full (note the "circular ref." nodes)

├─ id: application.cycle.f
├─ version: 1.0.0
├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/application.cycle.f
├─ dependencies
│  ├─ 0
│  │  ├─ id: library.cycle.c
│  │  ├─ version: 1.0.0
│  │  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
│  │  ├─ dependencies
│  │  │  └─ 0
│  │  │     ├─ id: library.cycle.d
│  │  │     ├─ version: 1.0.0
│  │  │     ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.d
│  │  │     ├─ dependencies
│  │  │     │  ├─ 0 (circular ref.)
│  │  │     │  └─ 1
│  │  │     │     ├─ id: library.cycle.e
│  │  │     │     ├─ version: 1.0.0
│  │  │     │     ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
│  │  │     │     ├─ dependencies
│  │  │     │     │  └─ 0 (circular ref.)
│  │  │     │     ├─ specVersion: 0.1
│  │  │     │     ├─ type: library
│  │  │     │     ├─ metadata
│  │  │     │     │  ├─ name: library.cycle.e
│  │  │     │     │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│  │  │     │     ├─ kind: project
│  │  │     │     ├─ _level: 2
│  │  │     │     └─ resources
│  │  │     │        ├─ configuration
│  │  │     │        │  └─ paths
│  │  │     │        │     ├─ src: src
│  │  │     │        │     └─ test: test
│  │  │     │        └─ pathMappings
│  │  │     │           ├─ /resources/: src
│  │  │     │           └─ /test-resources/: test
│  │  │     ├─ specVersion: 0.1
│  │  │     ├─ type: library
│  │  │     ├─ metadata
│  │  │     │  ├─ name: library.cycle.d
│  │  │     │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│  │  │     ├─ kind: project
│  │  │     ├─ _level: 1
│  │  │     └─ resources
│  │  │        ├─ configuration
│  │  │        │  └─ paths
│  │  │        │     ├─ src: src
│  │  │        │     └─ test: test
│  │  │        └─ pathMappings
│  │  │           ├─ /resources/: src
│  │  │           └─ /test-resources/: test
│  │  ├─ specVersion: 0.1
│  │  ├─ type: library
│  │  ├─ metadata
│  │  │  ├─ name: library.cycle.c
│  │  │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│  │  ├─ kind: project
│  │  ├─ _level: 1
│  │  └─ resources
│  │     ├─ configuration
│  │     │  └─ paths
│  │     │     ├─ src: src
│  │     │     └─ test: test
│  │     └─ pathMappings
│  │        ├─ /resources/: src
│  │        └─ /test-resources/: test
│  └─ 1
│     ├─ id: library.cycle.d
│     ├─ version: 1.0.0
│     ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.d
│     ├─ dependencies
│     │  ├─ 0
│     │  │  ├─ id: library.cycle.c
│     │  │  ├─ version: 1.0.0
│     │  │  ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
│     │  │  ├─ dependencies
│     │  │  │  └─ 0 (circular ref.)
│     │  │  ├─ specVersion: 0.1
│     │  │  ├─ type: library
│     │  │  ├─ metadata
│     │  │  │  ├─ name: library.cycle.c
│     │  │  │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│     │  │  ├─ kind: project
│     │  │  ├─ _level: 1
│     │  │  └─ resources
│     │  │     ├─ configuration
│     │  │     │  └─ paths
│     │  │     │     ├─ src: src
│     │  │     │     └─ test: test
│     │  │     └─ pathMappings
│     │  │        ├─ /resources/: src
│     │  │        └─ /test-resources/: test
│     │  └─ 1
│     │     ├─ id: library.cycle.e
│     │     ├─ version: 1.0.0
│     │     ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.e
│     │     ├─ dependencies
│     │     │  └─ 0
│     │     │     ├─ id: library.cycle.c
│     │     │     ├─ version: 1.0.0
│     │     │     ├─ path: ui5-project/test/fixtures/cyclic-deps/node_modules/library.cycle.c
│     │     │     ├─ dependencies
│     │     │     │  └─ 0 (circular ref.)
│     │     │     ├─ specVersion: 0.1
│     │     │     ├─ type: library
│     │     │     ├─ metadata
│     │     │     │  ├─ name: library.cycle.c
│     │     │     │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│     │     │     ├─ kind: project
│     │     │     ├─ _level: 1
│     │     │     └─ resources
│     │     │        ├─ configuration
│     │     │        │  └─ paths
│     │     │        │     ├─ src: src
│     │     │        │     └─ test: test
│     │     │        └─ pathMappings
│     │     │           ├─ /resources/: src
│     │     │           └─ /test-resources/: test
│     │     ├─ specVersion: 0.1
│     │     ├─ type: library
│     │     ├─ metadata
│     │     │  ├─ name: library.cycle.e
│     │     │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│     │     ├─ kind: project
│     │     ├─ _level: 2
│     │     └─ resources
│     │        ├─ configuration
│     │        │  └─ paths
│     │        │     ├─ src: src
│     │        │     └─ test: test
│     │        └─ pathMappings
│     │           ├─ /resources/: src
│     │           └─ /test-resources/: test
│     ├─ specVersion: 0.1
│     ├─ type: library
│     ├─ metadata
│     │  ├─ name: library.cycle.d
│     │  └─ copyright: UI development toolkit for HTML5 (OpenUI5)
 * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
│     ├─ kind: project
│     ├─ _level: 1
│     └─ resources
│        ├─ configuration
│        │  └─ paths
│        │     ├─ src: src
│        │     └─ test: test
│        └─ pathMappings
│           ├─ /resources/: src
│           └─ /test-resources/: test
├─ _level: 0
├─ specVersion: 0.1
├─ type: application
├─ metadata
│  └─ name: application.cycle.f
├─ kind: project
└─ resources
   ├─ configuration
   │  └─ paths
   │     └─ webapp: webapp
   └─ pathMappings
      └─ /: webapp

RandomByte avatar Feb 14 '19 16:02 RandomByte