Main module configuration

32 views
Skip to first unread message

guybedford

unread,
Jul 29, 2012, 9:30:33 AM7/29/12
to vol...@googlegroups.com
I'm just having some issues to get the main module volo process working (as documented here https://github.com/volojs/volo/wiki/Library-best-practices#wiki-collectionmainexample).

I have a module called 'require-selector' (https://github.com/guybedford/require-selector

My package.json is:

{
  "main": "main",
  "volo": {
    "dependencies": {
      "is": "guybedford/require-is"
    }
  }
}

I then install the module with the following command:

volo add guybedford/require-selector

It says that it will load a wrapper, and the folder. But instead all I get is a single file 'main.js' in my base folder, when I need all the files and dependencies included.

Perhaps I've completely misunderstood the process here, but what I'm looking for is to download the module into the folder, then provide a wrapper module, selector.js that will simply load the main.js file allowing for easy inclusion of the module by just using the 'selector' global.

Any advice would be appreciated.

James Burke

unread,
Jul 31, 2012, 6:55:44 PM7/31/12
to vol...@googlegroups.com
If the main.js file does not have any dependencies, then volo will try
to extract it. However, you can force volo to keep the directory by
setting volo.type to "directory" in the package.json:

https://github.com/volojs/volo/wiki/Library-best-practices#wiki-volotype

James

Guy Bedford

unread,
Aug 2, 2012, 6:22:13 PM8/2/12
to vol...@googlegroups.com
Thanks - that got the folder downloading.

I still really liked the idea of having the wrapper module automatically created in the base folder - this really minimises setup for users if we know what the global name should be for the module in advance.

I'm not seeing this wrapper module being created. Is there anything I can do to get this functionality as described in the main module section?

James Burke

unread,
Aug 3, 2012, 2:01:46 PM8/3/12
to vol...@googlegroups.com
On Thu, Aug 2, 2012 at 3:22 PM, Guy Bedford <guybe...@googlemail.com> wrote:
> Thanks - that got the folder downloading.
>
> I still really liked the idea of having the wrapper module automatically
> created in the base folder - this really minimises setup for users if we
> know what the global name should be for the module in advance.
>
> I'm not seeing this wrapper module being created. Is there anything I can do
> to get this functionality as described in the main module section?

The adapter module is only created for projects that are AMD-based. I
just tried this:

volo add guybedford/require-selector

in a project that has a package.json with "amd": {} in it (which
indicates it is an AMD-based project), and I get the adapter module.

The other option is to explicitly ask for it as an AMD dependency:

volo add -amd guybedford/require-selector

James

Guy Bedford

unread,
Aug 3, 2012, 2:12:38 PM8/3/12
to vol...@googlegroups.com
Ok, that sounds promising.

I've tried adding the "amd" parameter but it is still not adding the
wrapper though?

James Burke

unread,
Aug 3, 2012, 2:58:28 PM8/3/12
to vol...@googlegroups.com
I tried the following with volo 0.2.2:

volo create h5 html5-boilerplate
cd h5
volo add -amd guybedford/require-selector

and I see the adapter module created in h5/js/require-selector.js

I chose html5-boilerplate since it did not have a package.json so did
not have the volo.amd thing in it.

James

Guy Bedford

unread,
Aug 3, 2012, 3:03:28 PM8/3/12
to vol...@googlegroups.com
Perfect that is working for me great with the "-amd" flag!

I added the "amd" parameter to the package.json here -
https://github.com/guybedford/require-selector/blob/master/package.json

Yet this doesn't seem to be triggering the behavior for some reason?

James Burke

unread,
Aug 3, 2012, 3:08:12 PM8/3/12
to vol...@googlegroups.com
Ah: the amd: {} section goes into projects that will add the
dependency. So in the example below, if h5 had an amd: {} section.

The adapter modules are about making it easy to consume directory
dependencies in projects that use an AMD loader. So they are only
created if the project that receives the dependency is AMD-based. It
has not based on the wishes of the dependency itself.

James

guybedford

unread,
Aug 3, 2012, 6:06:40 PM8/3/12
to vol...@googlegroups.com
Ah, ok that makes complete sense - thanks very much for clarifying!

Guy
Reply all
Reply to author
Forward
0 new messages