i just noticed my local plugin was no longer being included in the api-runner-browser.js file shipped to the browser. digging in, i've found:
v1.9.216 was the last good version of gatsby for me
as of v1.9.218 my plugin was no longer included.
using v1.9.233 (latest as i'm writing this) and tracing thru the code, i've found that the resolve-module-exports.js utility no longer recognizes my exported api methods (see here)
my plugin is dead-simple
export const onRouteUpdate = ({ location }) => {
if (!window.analytics || typeof window.analytics.page !== 'function') {
return;
}
window.analytics.page();
};
if i change the above to: exports.onRouteUpdate (instead of export const onRouteUpdate), it passes the api usage check and gets included in my build.
interestingly, module.exports.onRouteUpdate doesn't work either.
seems like there's something funky in the babel transform and / or the code is enforcing incorrect assumptions about the transpiled output.
That's probably something from #3889, I'll do some digging.
Edit: Oh, I just realised you posted the exact line that causes the problem, thanks :)
A fix was released in Gatsby version 1.9.235. @busticated thanks for the detailed bug report!
Most helpful comment
A fix was released in Gatsby version 1.9.235. @busticated thanks for the detailed bug report!