In the current native module boilerplate, we say:
//...
Elm.Native.Foo.make = function(elm) {
//...
}
Notice that this is a function expression, and thus should have been terminated with a semicolon?
I didn't, in my little vendor prefix module. I omitted the semicolon (and it passed through native code review).
In my little tests, it worked fine, and I published it. Thanks, Automatic Semicolon Insertion!
And it turns out that in some cases (I still don't know which) we see a runtime error, where the JS parser is tripping up on something in the module loader,
and lands flat on it's face right where that semicolon should have been.
Has anyone else seen this?
I've looked around and seen that a bunch of native modules (including core) are missing that precious little terminator.
I'd really like to know what is causing ASI to fail in these cases, but regardless... we shouldn't be relying on it.
So, for posterity:
The error:
Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(...) is not a function(anonymous function)
points to the module loader:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
Go home, JavaScript; you're drunk.
If you landed here because you searched for this lovely error message, please check the expression *preceding* the one that took a piss, and see if it needs a semicolon.
Thank you for programming JavaScript, and have a nice day!