volojs / volo

Create front end projects from templates, add dependencies, and automate the resulting projects
https://volojs.github.io/
Other
1.41k stars 99 forks source link

Hide amd module generation message for non-amd modules #108

Closed guybedford closed 11 years ago

guybedford commented 11 years ago

I just found myself writing the following in a non-amd module today:

  //make volo think this is an amd module
  if (false) define(null);

Just to stop it from providing the 'conversion' prompts when they are unnecessary.

If it was just as easy to share non-amd modules with volo (not getting prompts like this), then I think that would really help the adoption because people don't have to see it as 'amd or nothing', but can use it as 'another package manager with amd support as well'.

jrburke commented 11 years ago

If you pass -amdoff I believe it should not prompt you. If not, knowing the volo steps involved might point out why that pref is not passed down.

guybedford commented 11 years ago

Ok thanks will bear that in mind for future.

I'm using the dependency as part of a volo create template, so don't have control to turn it off without adding the above code. It's a nicety, but if the library could have a package.json indicator to inform volo to skip that message that would help, because I'd rather not provide a project template to someone where the user gets a prompt they don't know how to answer.

jrburke commented 11 years ago

Normally "amd": {} in the package.json indicates that AMD loading is in effect. Is the project template an AMD project? If not, then removing that from the package.json should be enough to avoid it. If it is an AMD project, then the answers need to be known in order for it to work with an AMD loader. It is possible to seed answers for those questions by posting an amd.json to the volojs/repos overrides, for example, the one for documentcloud/underscore:

https://github.com/volojs/repos/blob/master/documentcloud/backbone/amd.json

So it sounds like maybe the solution is to either remove the "amd" section from the template's package.json if it is not an AMD-based project, or perhaps seed the volojs/repos section with the answers for the questions.

guybedford commented 11 years ago

Ok this makes sense. It is an AMD project, but I'm loading require-inline which is not AMD by definition - but it is probably the only dependency that makes sense not to be.

It's an exception though as in most cases one would be using either an AMD project or not. So that makes complete sense - I didn't realise there was this distinction.

jrburke commented 11 years ago

OK, well feel free to do a pull request to add an amd.json to volojs/repos to avoid the prompt. The other option is to not use the package.json volo.dependencies to indicate the dependency but to either: