if you look at the Network view in Chrome's Web Inspector I think you'll find 
it's trying to GET these:

/yourapp/modules.gz/dep/canvas.js
/yourapp/modules.gz/tool/util.js
/yourapp/modules.gz/tool/log.js
/yourapp/modules.gz/tool/guid.js

It's hoping to find them in META-INF/modules/ but they're not there. The 
solution is to make it look like they're there by shimming them all! For 
example:

      public static void contributeModuleManager(
                      MappedConfiguration<String, Object> configuration,
                      @Path("/META-INF/assets/a-1.0.0/a.js") Resource a,
                      @Path("/META-INF/assets/a-1.0.0/dep/canvas.js") Resource 
depCanvas,
                      @Path("/META-INF/assets/a-1.0.0/tool/util.js") Resource 
toolUtil,
                      ...)

              configuration.add("a", new JavaScriptModuleConfiguration(a));
              configuration.add("dep/canvas", new 
JavaScriptModuleConfiguration(depCanvas));
              configuration.add("tool/util", new 
JavaScriptModuleConfiguration(toolUtil));
              ...
      }

Cheers,

Geoff

On 24 Mar 2015, at 3:59 pm, Geoff Callender 
<geoff.callender.jumpst...@gmail.com> wrote:

> Very good question. It's trying to lazy load from the local context. So far 
> I've managed to sidestep modules that do that. I'll have a look into it.
> 
> On 23 Mar 2015, at 5:56 pm, Rural Hunter <ruralhun...@gmail.com> wrote:
> 
>> Hi Geoff,
>> 
>> Thanks so much for the detailed guide. My module A is AMD-compliant and has
>> no css files. I tried your solution in AppModule. It did resolved the
>> problem for A.js itself. But the A.js depends on many files in it's sub
>> directories. I checke the source of A.js and it's like this:
>>       require('./dep/excanvas');
>>       var util = require('./tool/util');
>>       var log = require('./tool/log');
>>       var guid = require('./tool/guid');
>> 
>> I got 404 for all the access to those dependencies. How to solve this?
>> 
>> 
>> 2015-03-23 10:56 GMT+08:00 Geoff Callender <
>> geoff.callender.jumpst...@gmail.com>:
>> 
>>> Let's say "a" and its associated files are in a folder called a-1.0.0. Try
>>> dropping the folder into META-INF/assets and shim it by contributing to
>>> ModuleManager:
>>> 
>>>       public static void contributeModuleManager(
>>>                       MappedConfiguration<String, Object> configuration,
>>>                       @Path("/META-INF/assets/a-1.0.0/a.js") Resource a,
>>>                       ...)
>>> 
>>>               configuration.add("a", new
>>> JavaScriptModuleConfiguration(a).dependsOn("whatever"));
>>>               ...
>>>               }
>>> 
>>> Now you can refer to it as module "a". If a.js was already an
>>> AMD-compliant module, that's fine, RequireJS will figure handle it. If a.js
>>> already does *require("whatever")* then you can leave out the
>>> .dependsOn("whatever") shown above.
>>> 
>>> If it has css files, you might like to put them in a JavaScriptStack so
>>> that their path is kept in one place.
>>> 
>>> public class ASupportStack implements JavaScriptStack {
>>> 
>>>       private final AssetSource assetSource;
>>> 
>>>       public ASupportStack(final AssetSource assetSource) {
>>>               this.assetSource = assetSource;
>>>       }
>>> 
>>>       public String getInitialization() {
>>>               return null;
>>>       }
>>> 
>>>       public List<Asset> getJavaScriptLibraries() {
>>>               List<Asset> ret = new ArrayList<>();
>>>               return ret;
>>>       }
>>> 
>>>       public List<StylesheetLink> getStylesheets() {
>>>               List<StylesheetLink> ret = new ArrayList<>();
>>> 
>>>               ret.add(new StylesheetLink(assetSource
>>> 
>>> .getClasspathAsset("/META-INF/assets/a-1.0.0/a.css")));
>>>               ret.add(new StylesheetLink(assetSource
>>> 
>>> .getClasspathAsset("/META-INF/assets/a-1.0.0/a.print.css"),
>>>                               new StylesheetOptions("print")));
>>> 
>>>               return ret;
>>>       }
>>> 
>>>       public List<String> getStacks() {
>>>               return Collections.emptyList();
>>>       }
>>> 
>>>       @Override
>>>       public List<String> getModules() {
>>>               return Collections.emptyList();
>>>       }
>>> 
>>> }
>>> 
>>> In AppModule:
>>> 
>>>       public static void
>>> contributeJavaScriptStackSource(MappedConfiguration<String,
>>> JavaScriptStack> configuration) {
>>>               configuration.addInstance("ASupportStack",
>>> ASupportStack.class);
>>>       }
>>> 
>>> In each page or component that uses module "a", either @Import the
>>> stylesheets or @Import the JavaScriptStack. I wish there was a way that
>>> would import it for you every time refer to module "a" but I don't know of
>>> one.
>>> 
>>> I hope this is helping.
>>> 
>>> Geoff
>>> 
>>> On 23 Mar 2015, at 1:06 pm, Rural Hunter <ruralhun...@gmail.com> wrote:
>>> 
>>>> I already did that. The problem is this: I have a 3rd party module A.
>>> Both
>>>> my own code and another 3rd party module B depend on it. The standard
>>>> location of module A should be at classpath:META-INF/modules/ but it
>>> brings
>>>> in a lot of js files and sub-folders and makes the module root path(
>>>> classpath:META-INF/modules) a bit messy. So I want to put module A at
>>>> classpath:META-INF/modules/A. How can I achieve it?
>>>> 
>>>> 2015-03-22 18:39 GMT+08:00 Chris Poulsen <mailingl...@nesluop.dk>:
>>>> 
>>>>> Drop the 3rd party module in the usual place for modules
>>>>> (classpath:META-INF/modules) and reference it.
>>>>> 
>>>>> http://tapestry.apache.org/javascript-rewrite.html has some info on the
>>>>> infrastructure and the tapestry source code (setup of the core
>>>>> stack/bootstrap modules etc. are good inspiration as well),
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On Sat, Mar 21, 2015 at 4:19 PM, Rural Hunter <ruralhun...@gmail.com>
>>>>> wrote:
>>>>> 
>>>>>> How to work out if I want to config the path of a third-party module
>>> if I
>>>>>> use js stack?
>>>>>> 
>>>>>> 2015-03-20 17:07 GMT+08:00 Chris Poulsen <mailingl...@nesluop.dk>:
>>>>>> 
>>>>>>> In a javascript stack?
>>>>>>> 
>>>>>>> On Fri, Mar 20, 2015 at 4:05 AM, Rural Hunter <ruralhun...@gmail.com>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> I'm testing tapestry 5.4. I'm wondering where to put the
>>>>>> requirejs.config
>>>>>>>> code for my own modules and third-party modules?
>>>>>>>> 
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>> 
>>> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to