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

Create proper "main" entry points in DDM package.json files


    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Dynamic Data Mapping
    • Labels:


      Here's some context which I already shared with Bruno Basto via Slack:

      what happened is that a refactoring that we did led segments-web and i think one or two other modules to have a dependency on frontend-js-web that wasn't there before

      so their tests started failing for the reason that you describe: jest can't "see" other modules correctly, and Soy only makes it worse because we only compile soy for the current module, not other modules

      DDM didn't have that problem because you have explicit `moduleNameMapper` stuff configured

      so, i went in and made a general solution that looks at all modules, and creates mappings automatically behind the scenes. that's what you can see in this PR, where I am removing some of the DDM mappings because they happen automatically now:


      however, the thing that I am going to need follow-up from you on, is that the DDM package.json files are a bit non-standard and so I have a temporary workaround in place

      specifically, you have some in there with `"main": "./"` which is technically not valid — you are pointing at a directory and there is no `index.js`.

      and we rely on the "main" to figure out which modules should have automatic mappings created

      so right now i have a special `if`/`else` in `liferay-npm-scripts` to make DDM work

      but what is actually needed is that "main" should name an "index.es.js" that actually exists. we need to create that. it's doesn't even really matter what it exports, but it is a chance for you to effectively declare the "public" API of each project

      so i was going to create a ticket for that and send it your way

      (oh, the other thing i forgot to mention: I removed the DDM "transform" files because those happen automatically now too)

      here is an example: https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-js/frontend-js-web/src/main/resources/META-INF/resources/index.es.js

      that exports a bunch. you can export as little or as much as you want though




            • Assignee:
              bruno.basto Bruno Basto
              greg.hurrell Greg Hurrell
              Recent user:
              Greg Hurrell
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created:


                Version Package