Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local plugin resolution broken when plugin uses gatsby-browser.js but exposes exports via es6 export... #4571

Closed
busticated opened this issue Mar 16, 2018 · 2 comments
Assignees

Comments

@busticated
Copy link
Contributor

busticated commented Mar 16, 2018

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.

@m-allanson
Copy link
Contributor

m-allanson commented Mar 16, 2018

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 :)

@m-allanson
Copy link
Contributor

m-allanson commented Mar 17, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants