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): use virtual modules for (a)sync-requires and match-paths.json #25057

Merged
merged 2 commits into from
Jul 3, 2020

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jun 17, 2020

Description

This avoids adding fs involved when we dynamically generate (a)sync-requires and match-paths.jsonfiles.

Why using fs is problematic?

It adds unnecessary async code to the pipeline, writing is fine (in fact I don't remove writing in this PR - see comment in requires-writer.ts for reaosns). It's about when we (or rather webpack watching) react to fs changes events - webpack watcher have some debounced/aggregation logic (200ms afaik) + any system level delays (from writing to fs, to receiving FS change event in watchpack/chokidar).

This PR on its own is not solving lot of problems, but it makes it easier for future PRs that try to coordinate our services to avoid pitfalls of some debounced state transitions

[CH9862]

@pieh pieh requested a review from a team as a code owner June 17, 2020 14:28
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 17, 2020
@pieh pieh added topic: webpack/babel Webpack or babel and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 17, 2020
instances.forEach(instance => {
instance.writeModule(adjustedFilePath, fileContents)
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really cool. i would love to have a header comment explaining what this module can do so in the future when a dev is reading this can know in what cases they might want to reuse this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add some description/context, good point

blainekasten
blainekasten previously approved these changes Jun 17, 2020
Copy link
Contributor

@blainekasten blainekasten left a comment

Choose a reason for hiding this comment

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

This is very cool! Approving cause the code looks fine, but just would love more comments explaining how this system works and why it's beneficial

oh and tests are failing i guess.. haha

@pieh pieh requested review from a team as code owners June 18, 2020 10:46
@pieh pieh force-pushed the webpack/virtual-modules branch 2 times, most recently from 4c1696e to ca13d28 Compare June 18, 2020 11:24
@pieh pieh requested a review from a team as a code owner June 18, 2020 12:49
@pieh pieh force-pushed the webpack/virtual-modules branch 2 times, most recently from 388f7fa to d8a49e3 Compare June 20, 2020 11:47
packages/gatsby/cache-dir/app.js Outdated Show resolved Hide resolved
wardpeet
wardpeet previously approved these changes Jun 25, 2020
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Tested and worked like a charm! 💪

@pieh pieh force-pushed the webpack/virtual-modules branch 3 times, most recently from 9e32e72 to 1425b55 Compare July 2, 2020 12:44
@pieh pieh force-pushed the webpack/virtual-modules branch from c4b0297 to 56d2938 Compare July 3, 2020 10:12
@gatsby-cloud-staging
Copy link

Your pull request can be previewed in Gatsby Cloud: https://build-32835a8f-a9e9-43fb-817d-78742faf3c08.staging-previews.gtsb.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: webpack/babel Webpack or babel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants