olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.96k stars 548 forks source link

Maybe use semicolons to complete function definitions #61

Closed shyndman closed 10 years ago

shyndman commented 10 years ago

Hi there,

I encountered a problem where after concat/minification, TokenStore.prototype.toJSON was an object, not a function. Weird, huh?

I did some digging and found that lunr was concatted into my lib file directly before another script that was using an anonymous function to avoid polluting global. Looked something like this:

lunr.TokenStore.prototype.toJSON = function () {
  return {
    root: this.root,
    length: this.length
  };
}(...other library code)();

Should have looked like this:

lunr.TokenStore.prototype.toJSON = function () {
  return {
    root: this.root,
    length: this.length
  };
}; 
(...other library code)();

Anyway, I got around it by changing my grunt config to use semicolon as a file separator, but it may be worthwhile to add semicolons directly in lunr.js to save some others some very weird debugging.

olivernn commented 10 years ago

I've just pushed version 0.4.4 with fixes for this issue, let me know if you are still having problems.

shyndman commented 10 years ago

Thanks Oliver. Looks great.