ui5-tooling
ui5-tooling copied to clipboard
Fix handling of circular dependencies between UI5 projects
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
- Clone this repository (ui5-project)
- Navigate to
cd test/fixtures/cyclic-deps/node_modules/application.cycle.f
- Execute
ui5 tree
andui5 tree --dedupe
to see that the npm translator correctly removes circular references in the tree - 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)
- [ ] ui5-builder
- [ ] ui5-server
- [ ] ui5-cli
- [ ] ui5-fs
- [x] ui5-project
- [ ] ui5-logger
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