Gatsby: local plugin resolution broken when plugin uses gatsby-browser.js but exposes exports via es6 `export`...

Created on 16 Mar 2018  路  2Comments  路  Source: gatsbyjs/gatsby

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.

Most helpful comment

A fix was released in Gatsby version 1.9.235. @busticated thanks for the detailed bug report!

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikestopcontinues picture mikestopcontinues  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

ferMartz picture ferMartz  路  3Comments

signalwerk picture signalwerk  路  3Comments

totsteps picture totsteps  路  3Comments