You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a UI5 application with a third-party dependency and a UI5 library. In our current setup, we require the library and the third-party dependency ajv as a dependency in the package.json.
As soon as I integrated the library, the deployed application stopped working as the third-party dependency was not longer included in the build output - the following warning was shown in the logs of the build process:
`Skipping dependency "ajv" as it is not part of the dependencies in package.json!``
The dependencies in the package.json of the application looks like the following:
During the dependency resolution process in ui5-tooling-modules, the module looks for ajv in the node_modules directory of the library. This happens because ajv is also a dependency of eslint, which is used as a devDependency within the library. Consequently, ajv becomes a transitive dependency of the library through eslint, and the resolution process identifies it. As a result, ajv is added to depRoots, associating it with the library's path.
Later, ajv is also found as a dependency in the node_modules of the application. As this is already a known dependency, the path of the dependency is not added to the dependency roots:
if(knownDeps.indexOf(npmPackage)!==-1){continue;}
This leads to allowedDep being set to false during dependency resolution in the function addDep:
Therefore, the modules logs the warning above. For my use case, the issue is solved by removing the flag additionalDependencies. As I think that the same dependency could be required by a library and a application in a similar setup, I raise this issue so others can have a better experience setting this up.
Imo, it is necessary to push the third-party dependency to the dependencyRoots for all found occurrences, not only when it is an unkown dependency (not included in the knownDep arrray). I am sure that I only have touched the surface of the dependency resolution mechanism and there are much more side effects to consider.
To Reproduce
If required, I can provide a sample internally.
Expected behavior
The dependency resolution should recognize the dependecy correctly so that the build artefact is working and able to load the dependency during runtime.
Screenshots
N/A
Desktop (please complete the following information):
OS: macOS
Browser: Chrome
Version: 3.20.2 (of ui5-tooling-modules)
Additional context
N/A
The text was updated successfully, but these errors were encountered:
@AnsgarLichter thanks for the detailed analysis - this is indeed an issue I didn't have on the radar yet, that the transitive dependencies are found before the direct dependencies. I need to take a look into this... THX for the hint!
@petermuessig That's great to hear. One more thing to add: The transitive dependencies are only found before the direct dependencies if the library is listed before the direct dependencies in the package.json. This means if the library is listed as the last dependency, then this behavior does not occur but it is not very transparent.
@AnsgarLichter I'm changing the lookup strategy now, which is IMO nevertheless better as this will only follow the really relevant transitive dependencies - I delay the recursive findDependencies call now - fix will come a bit later as I need to implement another feature in parallel - but this is how I intend to change the lookup logic:
constdepRoots=[];constfindDeps=[];for(constdepofdependencies){constnpmPackage=npmPackageScopeRegEx.exec(dep)?.[1];if(knownDeps.indexOf(npmPackage)!==-1){continue;}knownDeps.push(npmPackage);constdepPath=findDependency(path.posix.join(npmPackage,"package.json"),cwd,depPaths);letdepRoot=depPath&&path.dirname(depPath);if(depRoot&&depRoots.indexOf(depRoot)===-1){depRoots.push(depRoot);// delay the dependency lookup to avoid finding transitive dependencies before local dependenciesfindDeps.push({cwd: depRoot, depPaths, linkedOnly, additionalDeps });}}// lookup the transitive dependenciesfor(constdepoffindDeps){depRoots.push(...findDependencies(dep,knownDeps));}
Describe the bug
I have a UI5 application with a third-party dependency and a UI5 library. In our current setup, we require the library and the third-party dependency
ajv
as a dependency in thepackage.json
.As soon as I integrated the library, the deployed application stopped working as the third-party dependency was not longer included in the build output - the following warning was shown in the logs of the build process:
`Skipping dependency "ajv" as it is not part of the dependencies in package.json!``
The
dependencies
in thepackage.json
of the application looks like the following:Currently, the library itself does not have any
dependencies
.Additionally, there was an issue in the past which required us to add
ajv
as an additional dependency in theui5.yaml
of the application itself:During the dependency resolution process in
ui5-tooling-modules
, the module looks forajv
in thenode_modules
directory of the library. This happens becauseajv
is also a dependency ofeslint
, which is used as adevDependency
within the library. Consequently,ajv
becomes a transitive dependency of the library througheslint
, and the resolution process identifies it. As a result,ajv
is added todepRoots
, associating it with the library's path.Later,
ajv
is also found as a dependency in thenode_modules
of the application. As this is already a known dependency, the path of the dependency is not added to the dependency roots:This leads to
allowedDep
being set to false during dependency resolution in the functionaddDep
:Therefore, the modules logs the warning above. For my use case, the issue is solved by removing the flag
additionalDependencies
. As I think that the same dependency could be required by a library and a application in a similar setup, I raise this issue so others can have a better experience setting this up.Imo, it is necessary to push the third-party dependency to the
dependencyRoots
for all found occurrences, not only when it is an unkown dependency (not included in theknownDep
arrray). I am sure that I only have touched the surface of the dependency resolution mechanism and there are much more side effects to consider.To Reproduce
If required, I can provide a sample internally.
Expected behavior
The dependency resolution should recognize the dependecy correctly so that the build artefact is working and able to load the dependency during runtime.
Screenshots
N/A
Desktop (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: