Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Improve recognition of main module in case of bundles #341

Merged
merged 7 commits into from
Sep 30, 2019

Conversation

codeworrior
Copy link
Member

@codeworrior codeworrior commented Sep 26, 2019

This is a port of several changes from the Maven tooling, which have been made after the initial migration of the bundle tooling. Additionally, code coverage has been slightly improved by adding additional unit and integration tests. Errors that have been revealed by the new tests have been fixed.

Details about the changes:


Change 3312369 (improve recognition of main module in case of bundles):

So far, the module analyzer always assumed the first module definition to be the main definition. This failed at least for CVOM bundles but might also fail for others.

The analysis has been improved and now accepts a module as main module only in the following cases:

  • if it is an unnamed module
  • if it is a named module whose name matches the external name
  • if it is a named module and there's only one module (no bundle)

If multiple module definitions match the above criteria, this is
reported as an error.

Additionally, AMD special dependencies ('require', 'exports', 'module') are no longer reported in the dependency info.


Change 3945349 (JSModuleAnalyzer fails on modules that don't declare a name)

Basically, the JavaScript implementation was less sensitive to this issue. But if a resource could have a dependency to another resource named "null", the JavaScript tooling would fail, too. Although this looked like a purely theoretical scenario, adding a protective 'if' was trivial enough to just do it.


Change 3562114 (fix dep. analysis of new evo bundles)

  • recognize and evaluate sap.ui.require.preload calls
  • write and extract bundle name and raw module names

This is a port of the corresponding changes from the Maven tooling,
which have been made after the migration of the bundle tooling.

See (SAP internal) changes
    3101244 adapt merge tooling to the renaming of ui5loader.js
    3312369 improve recognition of main module in case of bundles
    3945349 JSModuleAnalyzer fails on modules that don't declare a name
and 3562114 fix dep. analysis of new evo bundles

Commit 1: migrate tests for TDD
[FIX] Infra: improve recognition of main module in case of bundles

So far, the module analyzer always assumed the first module definition
to be the main definition. This failed at least for CVOM bundles but
might also fail for others.

The analysis has been improved and now accepts a module as main module
only in the following cases:
- if it is an unnamed module
- if it is a named module whose name matches the external name
- if it is a named module and there's only one module (no bundle)

If multiple module definitions match the above criteria, this is
reported as an error.

Additionally, AMD special dependencies ('require', 'exports', 'module')
are no longer reported in the dependency info.

This fixes all test, except the EVO bundle test.
FIX] Infra: JSModuleAnalyzer fails on modules that don't declare a name

Basically, the JavaScript implementation was less sensitive to this
issue. But if a resource could have a dependency to another resource
named "null", the JavaScript tooling would fail, too. Although this
looked like a purely theoretical scenario, adding a protective 'if' was
trivial enough to just do it.
[INTERNAL] Infra: fix dep. analysis of new evo bundles

- recognize and evaluate sap.ui.require.preload calls
- write and extract bundle name and raw module names
@coveralls
Copy link

coveralls commented Sep 28, 2019

Coverage Status

Coverage increased (+2.4%) to 89.064% when pulling ba32daa on fix-module-name-detection-in-analyzer into e8e27f8 on master.

@codeworrior codeworrior requested a review from matz3 September 29, 2019 18:08
@codeworrior codeworrior changed the title [WIP][FIX] Improve recognition of main module in case of bundles [FIX] Improve recognition of main module in case of bundles Sep 29, 2019
Copy link
Member

@matz3 matz3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Not sure how we wanna merge this. Sqashing all of them into one commit would be the best option I think. Or do you wanna keep the individual commits?

@codeworrior
Copy link
Member Author

I intended to squash them. That's why I already updated the initial comment with a 'squashed' commit message.

@codeworrior codeworrior merged commit 7a560b4 into master Sep 30, 2019
@matz3 matz3 deleted the fix-module-name-detection-in-analyzer branch October 1, 2019 05:46
@matz3
Copy link
Member

matz3 commented Oct 1, 2019

👍

matz3 added a commit that referenced this pull request Feb 5, 2020
The UI5 core library contains dynamic calls to sap.ui.require.preload.
Those calls should not result into a warning in the build log, as they
are correct and should just be skipped.

This has been introducted with #341.
matz3 added a commit that referenced this pull request Feb 6, 2020
The UI5 core library contains dynamic calls to sap.ui.require.preload.
Those calls should not result into a warning in the build log, as they
are correct and should just be skipped.

This has been introducted with #341.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants