arboleya / coffee-toaster

Minimalist build system for CoffeeScript.
114 stars 23 forks source link

Cannot use classes and folders with the same name #62

Closed timglabisch closed 11 years ago

timglabisch commented 11 years ago

hi,

i have trouble with the packaging in version 1.2.14. using version 0.2.19 it works great.

i have the classes: core.abstracModule extends core.abstracModule core.ui.abstractFacetModule.ui.facet core.ui.abstractFacetModule app.modules.somefacet extends core.ui.abstractFacetModule

if the dom is ready i create an instance of app.modules.somefacet, that creates an instance of core.ui.abstractFacetModule.ui.facet and failes. after coffeescript runs __extend core.ui.abstractFacetModule.ui is undefined.

to fix this i renamed core.ui.abstractFacetModule.ui.facet to core.ui.abstractFacetModule_.ui.facet, this is ugly but works.

any ideas? do you need a complete example?

arboleya commented 11 years ago

Hi, first of all the master/published version of Toaster is at 0.6.11. I don't know this versions you mentioned.

I didn't follow the steps you listed, can you send me a complete example of your scenario? Don't need any logic, just the folder structure you're using and some empty classes with just the extend directives in place.

arboleya commented 11 years ago

@timglabisch Any further useful info about his? If not I'll be closing this issue due to insufficient interaction / evidence to reproduce the error.

timglabisch commented 11 years ago

you can close this ticket, i tryed 3 different toaster versions and with every version i have different issues if directories have the same name like files.

arboleya commented 11 years ago

The problem is to use a class and a folder with the very same name ( specially considering capital letters ). My thoughts about it are the following:

This will works

  • The imports order and scheme outputs an app.js the works just fine.

example-ok

This will not

  • The imports are messed-up here, so it will not work.

eample-wrong

Notes

In the non-working example, note the definitions's order in the app.js file. First there is the app.ui.Button.Default definition and after that the app.ui.Button. This last end up overwriting the app.ui.Button.Default.

app.ui.Button.Default = (function() {

    function Default() {}

    Default.prototype.say = function(something) {
      return console.log(something);
    };

    return Default;

  })();

app.ui.Button = (function() {

    function Button() {}

    Button.prototype.say = function(something) {
      return console.log(something);
    };

    return Button;

  })();

Conclusion

  • You CAN use folders and files with the same name, but if your imports are not absolutely perfect and your class-chain isn't carefully crafted, you'll end up with problems.
  • Because of this weakness, I wouldn't recommend this use.

Solution

  • You can achieve success with this structure by simply NOT using folders with the same names as classes. For instance, if you use a folder name with no capital letters, it will work properly.

example-recommended

arboleya commented 11 years ago

I've changed the issue title to proper reflect the problem itself.