Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-108207

JS module names are not recursively mapped

    Details

      Description

      The NPMRegistry has a mapModuleName() function which is used to convert module names to their real path. For example, if you write:

      require("a-package")

      It will translate it to something like:

      require("a-package/lib/index")

      Provided that the main module of "a-package" is defined as "./lib/index".

      This has worked without problems for so long, but there's a case where it fails. Say you have "./lib" as the main module of "a-package", and then you have and "index.js" file inside "lib". That should make

      require("a-package")

      be converted to:

      require("a-package/lib/index")

      But, because mapModuleName() is not calling itself recursively, it only does one mapping, when two are required: the first one to map "a-package" to "a-package/lib", and the second one to map "a-package/lib" to "a-package/lib/index".

      Steps to reproduce:

      1) Download or clone the repo at https://github.com/Gympass/poc-liferay-react
      2) Run "npm install" in that project
      3) Run "npm build" in that project
      4) Deploy the JAR file in the "dist" folder of the project
      5) Open the site in a browser and add the "gympass" portlet to the home page

      Expected results:

      1) The portlet is rendered (a button appears)

      Actual results:

      1) The portlet is not rendered and an error message appears in the JavaScript console saying: Missing dependency '@klabin-sso-security-report$gympass/yoga@1.9.0/cjs' of 'klabin-sso-security-report@1.0.0/lib/index'

        Attachments

          Activity

            People

            Assignee:
            john.co John Co
            Reporter:
            ivan.zaera Ivan Zaera
            Participants of an Issue:
            Recent user:
            Jason Pince
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              42 weeks, 4 days ago

                Packages

                Version Package
                7.2.10 DXP FP5
                7.2.10.2 DXP SP2
                7.2.X
                7.3.1 CE GA2
                7.3.2 CE GA3
                7.3.10 DXP GA1
                Master