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

Liferay Workspace Project generate bad AMD Modules

    Details

    • Fix Priority:
      2

      Description

      The Liferay AMD Module config generator generates wrong modules if it's executed in a Liferay workspace project.

      Behavioral

      Module can be loaded in the Liferay (JPS or Webcontent Script), but it's an empty array.

      Reproduce

      log.es.js (build output)
      define("react-routing@1.0.0/utils/log.es", [], function () {
      	"use strict";
      
      	define("react-routing@1.0.0/utils/log.es", [], function () {
      		"use strict";
      
      		define("react-routing@1.0.0/utils/log.es", ["exports"], function (exports) {
      			"use strict";
      
      			Object.defineProperty(exports, "__esModule", {
      				value: true
      			});
      
      			exports.default = function (msg) {
      
      				document.getElementById("context").innerHTML += msg + ' sdfddsfasdfdsf';
      			};
      		});
      		//# sourceMappingURL=log.es.js.map
      	});
      	//# sourceMappingURL=log.es.js.map
      });
      //# sourceMappingURL=log.es.js.map
      

      Workaround

      Create a workspace with empty build.gradel and empty settings.gradle, add all Gradle stuff to the module, or just make a simple module without a workspace:

      build.gradle (Module)
      buildscript {
      	repositories {
      		maven {
      			url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
      		}
      	}
      
      	dependencies {
      		classpath group: "biz.aQute.bnd", name: "biz.aQute.bnd.gradle", version: "3.2.0"
      		classpath group: "com.liferay", name: "com.liferay.ant.bnd", version: "2.0.24"
      		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.js.module.config.generator", version: "1.0.22"
      		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.js.transpiler", version: "1.0.26"
      	}
      }
      
      apply plugin: "biz.aQute.bnd.builder"
      apply plugin: "com.liferay.js.module.config.generator"
      apply plugin: "com.liferay.js.transpiler"
      
      configJSModules {
      	configVariable = ""
      	ignorePath = true
      	moduleExtension = ""
      	moduleFormat = "/_/g,-"
      	include "**/*.js"
      }
      
      version = '1.0.0'
      

      Files

      Workspace

      build.gradle: empty

      settings.gradle
      buildscript {
      	dependencies {
      		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.39"
      	}
      
      	repositories {
      		maven {
      			url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
      		}
      	}
      }
      
      apply plugin: "com.liferay.workspace"
      

      Module

      package.json
      {
        "name": "react-routing",
        "version": "1.0.0"
      }
      
      bnd.bnd
      Bundle-SymbolicName: js.module.poc
      Bundle-Version: 1.0.0
      -includeresource: package.json
      -plugin.npm: com.liferay.ant.bnd.npm.NpmAnalyzerPlugin
      
      build.gradle
      configJSModules {
          configVariable = ""
          ignorePath = true
          moduleExtension = ""
          moduleFormat = "/_/g,-"
          include "**/*.js"
      }
      
      logger.es.js
      import logMsg from './utils/log.es';
      
      class Logger {
          constructor(shellPrompt = '|> ') {
              this.shellPrompt = shellPrompt;
          }
      
          log(msg) {
              let shellMessage = `${this.shellPrompt} ${msg}`;
      
              logMsg(shellMessage);
          }
      }
      
      export default Logger;
      
      log.es.js
      export default function(msg) {
      
      	document.getElementById("context").innerHTML += msg + ' sdfddsfasdfdsf';
      }
      

      Build output

      logger.es.js (build)
      define("react-routing@1.0.0/utils/log.es", [], function () {
      	"use strict";
      
      	define("react-routing@1.0.0/utils/log.es", [], function () {
      		"use strict";
      
      		define("react-routing@1.0.0/utils/log.es", ["exports"], function (exports) {
      			"use strict";
      
      			Object.defineProperty(exports, "__esModule", {
      				value: true
      			});
      
      			exports.default = function (msg) {
      
      				document.getElementById("context").innerHTML += msg + ' sdfddsfasdfdsf';
      			};
      		});
      		//# sourceMappingURL=log.es.js.map
      	});
      	//# sourceMappingURL=log.es.js.map
      });
      //# sourceMappingURL=log.es.js.map
      
      log.es.js (build)
      define("react-routing@1.0.0/utils/log.es", [], function () {
      	"use strict";
      
      	define("react-routing@1.0.0/utils/log.es", [], function () {
      		"use strict";
      
      		define("react-routing@1.0.0/utils/log.es", ["exports"], function (exports) {
      			"use strict";
      
      			Object.defineProperty(exports, "__esModule", {
      				value: true
      			});
      
      			exports.default = function (msg) {
      
      				document.getElementById("context").innerHTML += msg + ' sdfddsfasdfdsf';
      			};
      		});
      		//# sourceMappingURL=log.es.js.map
      	});
      	//# sourceMappingURL=log.es.js.map
      });
      //# sourceMappingURL=log.es.js.map
      

        Attachments

          Activity

            People

            • Assignee:
              support-lep@liferay.com SE Support
              Reporter:
              severin.rohner Severin Rohner
              Participants of an Issue:
              Recent user:
              Sherry Zhu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                3 years, 5 weeks ago

                Packages

                Version Package