esperantojs / esperanto

DEPRECATED: An easier way to convert ES6 modules to AMD and CommonJS
http://esperantojs.org
234 stars 21 forks source link

name:false param for UMD wrapper #96

Open jamesplease opened 9 years ago

jamesplease commented 9 years ago

Not all libraries export variables. For instance, if I'm writing a plugin for momentjs, I will likely just modify the moment library and not return anything.

Would you be willing to support a feature where the module doesn't export anything? For the UMD case, it might cause bugs if you just let the name go undefined, so maybe requiring an explicit false to be set would help prevent those problems while also adding in this functionality.

jamesplease commented 9 years ago

Oh, you know what, I just tried typing a variable that isn't explicitly defined in the code ("moment") and it ended up returning nothing without any problems. That's a combination of awesome, because it does what I want it to do, but maybe not so awesome, 'cause that might be unexpected behavior.

Maybe the updated behavior should be:

  1. Throw an error if the variable doesn't exist
  2. Don't export anything if name is set to false.
Rich-Harris commented 9 years ago

+1, I've been meaning to do this. I think the rule should be that if something is exported, you have to supply a name, otherwise the name will be ignored.

jamesplease commented 9 years ago

Sounds good to me. Should I try to whip up a PR?

Rich-Harris commented 9 years ago

That'd be great! Thanks. Shout if anything in the code doesn't make sense

jamesplease commented 9 years ago

Shout if anything in the code doesn't make sense

Tabs? Tabs?

jkjkjk

:stuck_out_tongue:

eventualbuddha commented 9 years ago

I know, right? It isn't really the default choice these days. That said, if your editor has an EditorConfig plugin then you don't really have to even think about it.

jamesplease commented 9 years ago

That said, if your editor has an EditorConfig plugin then you don't really have to even think about it.

Good point!

I was just messin' around, though :wink:

Rich-Harris commented 9 years ago

ldnwkgp

jamesplease commented 9 years ago

looool

on another note...

template strings :open_mouth: :open_hands:

jamesplease commented 9 years ago

My favorite old hack – setting the name property to be a nonexistent variable – seems to no longer work to get around this. Shucks :stuck_out_tongue: