4 Replies Latest reply on Aug 29, 2012 3:05 AM by hoang_to

    Is CommonJS code possible?

    gboeve

      Hi

       

      Is it possible to use JavaScript applications written in the CommonJS module style in a GateIn portlet?

      I am trying to add the Ace editor (http://ace.ajax.org) to a portlet.

      According the RequireJS documentation it also supports the CommonJS style but the GateIn code doesn't download a regular require.js file in the portal page but combines it with other js code.

      And it also change the js files defined in the gatein-resources.xml file by adding "define" code which mixup with the CommonJS define styles.

      I am building/testing with GateIn 3.4.0 on JBoss AS 5.1.0.

      Is there somewhere documentation or example code available which will make the use of CommonJS code in GateIn clear?

       

      Regards

      Geert

        • 1. Re: Is CommonJS code possible?
          julien_viet

          Hi,

           

          you are right, for now you should take your script and adapt it to the GateIn format and reference it in the <script/> tag.

           

          We are in the process of adding support native Requires.JS module to GateIn JS support which is actually missing to allow your use case to work. It will be in GateIn 3.4 I think.

           

          We will add a <native-script> tag that will work with Requires.JS module.

           

          We understand that today GateIn HAS TO SUPPORT such use case.

           

          Once it is available in GateIn master and if you can build GateIn yourself you could use it and provide feedback to help us make this work, that's really something we want to be possible to do with GateIn asap.

          • 2. Re: Is CommonJS code possible?
            gboeve

            Thanks Julien, for your reply.

            If you have added the RequireJS native support to GateIn I will try to use it and give you feedback.

            For now I will try to find an other solution.

            • 3. Re: Is CommonJS code possible?
              hoang_to

              Julien Viet wrote:

               

              Hi,

               

              you are right, for now you should take your script and adapt it to the GateIn format and reference it in the <script/> tag.

               

              We are in the process of adding support native Requires.JS module to GateIn JS support which is actually missing to allow your use case to work. It will be in GateIn 3.4 I think.

               

              We will add a <native-script> tag that will work with Requires.JS module.

               

              We understand that today GateIn HAS TO SUPPORT such use case.

               

              Once it is available in GateIn master and if you can build GateIn yourself you could use it and provide feedback to help us make this work, that's really something we want to be possible to do with GateIn asap.

               

              The idea of <native-script> could be applied only to category of JavaScript files already in AMD format. For CommonJS stuff, the most painful work is to convert the code JS from CommonJS 's module format into AMD format.

              • 4. Re: Is CommonJS code possible?
                hoang_to

                You could find in the link basical modifications to have CommonJS works in GateIn (with <native-script> feature supported)

                 

                https://docs.jboss.org/author/display/GTNPORTAL/GDG-CommonJS