requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

How to handle anonymous modules #103

Closed gustavnikolaj closed 9 years ago

gustavnikolaj commented 9 years ago

As per @jrburke's comment (https://github.com/jrburke/almond/issues/99#issuecomment-71276072) in #99 we should discuss the potential for adding an error message in the case when almond fails because of an anonymous module.

Myself, I'm all fine with just the simplest error - as long as it is explicit, annd not implicit as the "Cannot read splice of undefined" error.

I sent a pull request doing just that, see it here: #100

@jrburke suggested in #99 that a link was added to a wiki page on this repo explaining it in more detail.

The most obvious missing feature here is the lack of ability to see the offending module in the stack trace. I'm not sure I understand why that is though... Shouldn't the next thing on the stack trace be the line where define was called illegally? I know that it isn't - but I dont understand why...

jrburke commented 9 years ago

Thank you for the pull request in #100, it pushed me to finally throwing an explicit error. I decided to be stricter on the check, and add a pointer to the README, along with a test, so I will use the fix attached to this ticket as the fix for the issue. If you see any issues with what was pushed for this ticket, please let me know. I will release a 0.3.1 today with this change.

gustavnikolaj commented 9 years ago

That looks great @jrburke. Thanks! :-)