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

Change target to be node for html-build #512

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

ryanswrt
Copy link
Contributor

Certain npm plugins fail when being built with SSR (namely firebase); this patch changes the build target to node for packages that have separate node and browser versions

Certain npm plugins fail when being built with SSR (namely firebase); this patch changes the build target to node for packages that have seperate node and browser versions
@KyleAMathews
Copy link
Contributor

So I don't really understand the implications of this change. Webpack's docs are a bit vague here. Could you give a quick primer on what target does?

@ryanswrt
Copy link
Contributor Author

ryanswrt commented Oct 25, 2016

Certain "isomorphic" packages have different entry points for browser and server ( see https://github.com/defunctzombie/package-browser-field-spec ); setting the target tells webpack which file to include, ie. browser vs main, as I understand it. So far I've only found one package that this affects, namely firebase, but in the 1.0 branch it seems like componentWillMount is being evaluated on build, which breaks all of the firebase dependant code in my project that was being called there, as it was trying to use the browser version. Changing the target to node uses the node firebase package, which works fine.

I'm not 100% sure that that's the entirety of the changes, it seems to protect certain built-in node functions like fs and path (see http://jlongster.com/Backend-Apps-with-Webpack--Part-I )

@KyleAMathews
Copy link
Contributor

Thanks for the explanation! So this does seem pretty safe as nothing changes unless modules opt-in.

@KyleAMathews KyleAMathews merged commit 0f74277 into gatsbyjs:master Oct 25, 2016
@jlengstorf
Copy link
Contributor

Hiya @TheAncientGoat! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

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

Successfully merging this pull request may close these issues.

3 participants