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

refactor(gatsby): Change develop command to use startWebpackServer service #24946

Merged
merged 44 commits into from
Jun 22, 2020

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jun 12, 2020

This PR extracts the nitty-gritty of the starting of the webpack dev server and CLI bootstrapping from the develop-process command into a startWebpackServer service. In the state machine branch this is spawned during bootstrap. It also extracts some of the functions used by that into seperate utils files.

@ascorbic ascorbic requested a review from a team as a code owner June 12, 2020 08:43
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 12, 2020
@ascorbic ascorbic added status: needs core review Currently awaiting review from Core team member and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 12, 2020
@pvdz pvdz marked this pull request as draft June 16, 2020 10:24
@pvdz
Copy link
Contributor

pvdz commented Jun 16, 2020

(I've put it to draft mode since that's what it is)

@ascorbic
Copy link
Contributor Author

@pvdz No, it's ready for review. It's just dependent on the other PR

@ascorbic ascorbic marked this pull request as ready for review June 16, 2020 10:40
@ascorbic ascorbic requested review from a team as code owners June 19, 2020 11:44
@pvdz
Copy link
Contributor

pvdz commented Jun 19, 2020

@ascorbic what's up with the added commits? 🤔

@ascorbic
Copy link
Contributor Author

@pvdz Merging master, via the base branch. It initally showed all of those commits before it realised the base branch had been updated too

@ascorbic ascorbic removed request for a team June 19, 2020 12:30
Base automatically changed from chore/bootstrap-refactor to master June 19, 2020 13:17
): Promise<{ gatsbyNodeGraphQLFunction: Runner }> {
): Promise<{
gatsbyNodeGraphQLFunction: Runner
workerPool: JestWorker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we just picking workerPool from context here or the workerPool is created someone in here?

If we are not creating it, it feels weird to return it from bootstrap and not just grab it from context if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting it at line 35, where we spread in the results of initialize.

@wardpeet
Copy link
Contributor

@ascorbic is it possible to add some comments to say what actually changed, it feels like it's lot of moving pieces around and I want to make sure the changed bits are thoroughly reviewed.

Also should we put some tests in place or should we just really on e2e tests?

Copy link
Contributor

@pvdz pvdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spot checked it and am assuming the new files etc are just moving code, not making actual changes.

It looks okay. I have two small issues.

packages/gatsby/src/services/start-webpack-server.ts Outdated Show resolved Hide resolved
packages/gatsby/src/services/types.ts Show resolved Hide resolved
@ascorbic
Copy link
Contributor Author

@ascorbic is it possible to add some comments to say what actually changed, it feels like it's lot of moving pieces around and I want to make sure the changed bits are thoroughly reviewed.

Also should we put some tests in place or should we just really on e2e tests?

The new files should be virtually identical code. It's annoying that there's no easy way to track that. I'm not sure the best way of testing it, because it's mostly about spinning up webpack

Comment on lines +12 to +15
import { printDeprecationWarnings } from "../utils/print-deprecation-warnings"
import { printInstructions } from "../utils/print-instructions"
import { prepareUrls } from "../utils/prepare-urls"
import { startServer } from "../utils/start-server"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bikesheddy: given how all those utils are only used by this service, could we group them in some directory and not just add 4 more files to utils?

so maybe:

 - services/
    - start-webpack-server/
       - index.ts (this file)
       - print-deprecation-warnings (utils - repeat for other util)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the cut of your jib

workerPool: JestWorker
}

export async function startServer(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I've changed the signature to accept the app and workerPool from outside, rather than creating them here

@ascorbic ascorbic requested a review from pvdz June 22, 2020 15:01
@ascorbic ascorbic merged commit 5f1e240 into master Jun 22, 2020
@delete-merged-branch delete-merged-branch bot deleted the chore/develop-command-refactor branch June 22, 2020 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs core review Currently awaiting review from Core team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants