Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2cf91b5e25134a7d260d8baaa62d6545a1dd9d72
Choose a base ref
...
head repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 59e7e0eadfea90ef844b53c0b53d098ad3d51c7a
Choose a head ref
  • 3 commits
  • 31 files changed
  • 2 contributors

Commits on Mar 9, 2022

  1. Copy the full SHA
    fba82a3 View commit details
  2. fix(gatsby-core-utils): multiple requests with different outputdir (#…

    …35039) (#35043)
    
    Co-authored-by: Ward Peeters <ward@coding-tech.com>
    LekoArts and wardpeet authored Mar 9, 2022
    Copy the full SHA
    3c38128 View commit details
  3. chore(release): Publish

     - babel-plugin-remove-graphql-queries@4.9.1
     - babel-preset-gatsby@2.9.1
     - gatsby-cli@4.9.1
     - gatsby-core-utils@3.9.1
     - gatsby-link@4.9.1
     - gatsby-page-utils@2.9.1
     - gatsby-plugin-benchmark-reporting@2.9.1
     - gatsby-plugin-gatsby-cloud@4.9.1
     - gatsby-plugin-image@2.9.1
     - gatsby-plugin-manifest@4.9.1
     - gatsby-plugin-mdx@3.9.1
     - gatsby-plugin-offline@5.9.1
     - gatsby-plugin-page-creator@4.9.1
     - gatsby-plugin-preload-fonts@3.9.1
     - gatsby-plugin-sharp@4.9.1
     - gatsby-plugin-typescript@4.9.1
     - gatsby-remark-images@6.9.1
     - gatsby-source-contentful@7.7.2
     - gatsby-source-drupal@5.9.1
     - gatsby-source-filesystem@4.9.1
     - gatsby-source-graphql@4.9.1
     - gatsby-source-shopify@6.9.1
     - gatsby-source-wordpress@6.9.1
     - gatsby-telemetry@3.9.1
     - gatsby-transformer-remark@5.9.1
     - gatsby-transformer-sqip@4.9.1
     - gatsby@4.9.3
    LekoArts committed Mar 9, 2022
    Copy the full SHA
    59e7e0e View commit details
Showing with 189 additions and 124 deletions.
  1. +2 −2 packages/babel-plugin-remove-graphql-queries/package.json
  2. +2 −2 packages/babel-preset-gatsby/package.json
  3. +3 −3 packages/gatsby-cli/package.json
  4. +1 −1 packages/gatsby-core-utils/package.json
  5. +32 −1 packages/gatsby-core-utils/src/__tests__/fetch-remote-file.js
  6. +59 −39 packages/gatsby-core-utils/src/fetch-remote-file.ts
  7. +2 −2 packages/gatsby-link/package.json
  8. +2 −2 packages/gatsby-page-utils/package.json
  9. +2 −2 packages/gatsby-plugin-benchmark-reporting/package.json
  10. +3 −3 packages/gatsby-plugin-gatsby-cloud/package.json
  11. +3 −3 packages/gatsby-plugin-image/package.json
  12. +2 −2 packages/gatsby-plugin-manifest/package.json
  13. +2 −2 packages/gatsby-plugin-mdx/package.json
  14. +2 −2 packages/gatsby-plugin-offline/package.json
  15. +4 −4 packages/gatsby-plugin-page-creator/package.json
  16. +2 −2 packages/gatsby-plugin-preload-fonts/package.json
  17. +4 −4 packages/gatsby-plugin-sharp/package.json
  18. +2 −2 packages/gatsby-plugin-typescript/package.json
  19. +2 −2 packages/gatsby-remark-images/package.json
  20. +3 −3 packages/gatsby-source-contentful/package.json
  21. +2 −2 packages/gatsby-source-drupal/package.json
  22. +2 −2 packages/gatsby-source-filesystem/package.json
  23. +2 −2 packages/gatsby-source-graphql/package.json
  24. +4 −4 packages/gatsby-source-shopify/package.json
  25. +5 −5 packages/gatsby-source-wordpress/package.json
  26. +2 −2 packages/gatsby-telemetry/package.json
  27. +2 −2 packages/gatsby-transformer-remark/package.json
  28. +2 −2 packages/gatsby-transformer-sqip/package.json
  29. +10 −10 packages/gatsby/package.json
  30. +4 −2 packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts
  31. +20 −8 packages/gatsby/src/schema/graphql-engine/lmdb-bundling-patch.ts
4 changes: 2 additions & 2 deletions packages/babel-plugin-remove-graphql-queries/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-remove-graphql-queries",
"version": "4.9.0",
"version": "4.9.1",
"author": "Jason Quense <monastic.panic@gmail.com>",
"repository": {
"type": "git",
@@ -10,7 +10,7 @@
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/babel-plugin-remove-graphql-queries#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"gatsby-core-utils": "^3.9.0"
"gatsby-core-utils": "^3.9.1"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
4 changes: 2 additions & 2 deletions packages/babel-preset-gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-gatsby",
"version": "2.9.0",
"version": "2.9.1",
"author": "Philipp Spiess <hello@philippspiess.com>",
"repository": {
"type": "git",
@@ -22,7 +22,7 @@
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-macros": "^2.8.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"gatsby-legacy-polyfills": "^2.9.0"
},
"peerDependencies": {
6 changes: 3 additions & 3 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-cli",
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands",
"version": "4.9.0",
"version": "4.9.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "cli.js"
@@ -30,8 +30,8 @@
"execa": "^5.1.1",
"fs-exists-cached": "^1.0.0",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "^3.9.0",
"gatsby-telemetry": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"gatsby-telemetry": "^3.9.1",
"hosted-git-info": "^3.0.8",
"is-valid-path": "^0.1.1",
"joi": "^17.4.2",
2 changes: 1 addition & 1 deletion packages/gatsby-core-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-core-utils",
"version": "3.9.0",
"version": "3.9.1",
"description": "A collection of gatsby utils used in different gatsby packages",
"keywords": [
"gatsby",
33 changes: 32 additions & 1 deletion packages/gatsby-core-utils/src/__tests__/fetch-remote-file.js
Original file line number Diff line number Diff line change
@@ -513,7 +513,38 @@ Fetch details:
expect(cachedFilePath).toStartWith(path.join(cache.directory, `public`))
expect(gotStream).toBeCalledTimes(1)
expect(fs.pathExists).toBeCalledTimes(1)
expect(fs.copy).toBeCalled()
expect(fs.copy).toBeCalledTimes(1)
expect(await fs.pathExists(cachedFilePath)).toBe(true)
global.__GATSBY = currentGlobal
})

it(`should not re-download but copy file to public folder when the same url is requested`, async () => {
const currentGlobal = global.__GATSBY
global.__GATSBY = {
root: cache.directory,
}
await fs.ensureDir(path.join(cache.directory, `public`))
const filePathPromise = fetchRemoteFile({
url: `http://external.com/dog.jpg?v=4`,
directory: cache.directory,
cacheKey: `4`,
})
const cachedFilePathPromise = fetchRemoteFile({
url: `http://external.com/dog.jpg?v=4`,
directory: path.join(cache.directory, `public`),
cacheKey: `4`,
})

const [filePath, cachedFilePath] = await Promise.all([
filePathPromise,
cachedFilePathPromise,
])

expect(filePath).not.toBe(cachedFilePath)
expect(cachedFilePath).toStartWith(path.join(cache.directory, `public`))
expect(gotStream).toBeCalledTimes(1)
expect(fs.pathExists).toBeCalledTimes(0)
expect(fs.copy).toBeCalledTimes(1)
global.__GATSBY = currentGlobal
})

98 changes: 59 additions & 39 deletions packages/gatsby-core-utils/src/fetch-remote-file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fileType from "file-type"
import path from "path"
import fs, { pathExists } from "fs-extra"
import fs from "fs-extra"
import Queue from "fastq"
import { createContentDigest } from "./create-content-digest"
import {
@@ -49,39 +49,51 @@ export async function fetchRemoteFile(
if (await fs.pathExists(cachedPath)) {
// If the cached directory is not part of the public directory, we don't need to copy it
// as it won't be part of the build.
if (
!downloadPath.startsWith(
path.join(global.__GATSBY?.root ?? process.cwd(), `public`)
)
) {
return cachedPath
if (isPublicPath(downloadPath)) {
return copyCachedPathToDownloadPath({ cachedPath, downloadPath })
}

// Create a mutex to do our copy - we could do a md5 hash check as well but that's also expensive
if (!alreadyCopiedFiles.has(downloadPath)) {
const copyFileMutex = createMutex(
`gatsby-core-utils:copy-fetch:${downloadPath}`,
200
)
await copyFileMutex.acquire()
if (!alreadyCopiedFiles.has(downloadPath)) {
await fs.copy(cachedPath, downloadPath, {
overwrite: true,
})
}

alreadyCopiedFiles.add(downloadPath)
await copyFileMutex.release()
}

return downloadPath
return cachedPath
}
}
}

return pushTask({ args })
}

function isPublicPath(downloadPath: string): boolean {
return downloadPath.startsWith(
path.join(global.__GATSBY?.root ?? process.cwd(), `public`)
)
}

async function copyCachedPathToDownloadPath({
cachedPath,
downloadPath,
}: {
cachedPath: string
downloadPath: string
}): Promise<string> {
// Create a mutex to do our copy - we could do a md5 hash check as well but that's also expensive
if (!alreadyCopiedFiles.has(downloadPath)) {
const copyFileMutex = createMutex(
`gatsby-core-utils:copy-fetch:${downloadPath}`,
200
)
await copyFileMutex.acquire()
if (!alreadyCopiedFiles.has(downloadPath)) {
await fs.copy(cachedPath, downloadPath, {
overwrite: true,
})
}

alreadyCopiedFiles.add(downloadPath)
await copyFileMutex.release()
}

return downloadPath
}

const queue = Queue<null, ITask, string>(
/**
* fetchWorker
@@ -143,13 +155,30 @@ async function fetchFile({

// Fetch the file.
try {
const inFlightValue = getInFlightObject(url, BUILD_ID)
if (inFlightValue) {
return inFlightValue
if (!name) {
name = getRemoteFileName(url)
}

if (!ext) {
ext = getRemoteFileExtension(url)
}

const digest = createContentDigest(url)
const finalDirectory = path.join(fileDirectory, digest)
const cachedEntry = await storage.remoteFileInfo.get(url)

const inFlightValue = getInFlightObject(url, BUILD_ID)
if (inFlightValue) {
if (!isPublicPath(finalDirectory)) {
return inFlightValue
}

return await copyCachedPathToDownloadPath({
cachedPath: inFlightValue,
downloadPath: createFilePath(finalDirectory, name, ext),
})
}

// Add htaccess authentication if passed in. This isn't particularly
// extensible. We should define a proper API that we validate.
const httpOptions: Options = {}
@@ -158,24 +187,15 @@ async function fetchFile({
httpOptions.password = auth.htaccess_pass
}

if (!name) {
name = getRemoteFileName(url)
}

if (!ext) {
ext = getRemoteFileExtension(url)
}

const digest = createContentDigest(url)
await fs.ensureDir(path.join(fileDirectory, digest))
await fs.ensureDir(finalDirectory)

const tmpFilename = createFilePath(fileDirectory, `tmp-${digest}`, ext)
let filename = createFilePath(path.join(fileDirectory, digest), name, ext)

// See if there's response headers for this url
// from a previous request.
const headers = { ...httpHeaders }
if (cachedEntry?.headers?.etag && (await pathExists(filename))) {
if (cachedEntry?.headers?.etag && (await fs.pathExists(filename))) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
headers[`If-None-Match`] = cachedEntry.headers.etag
}
4 changes: 2 additions & 2 deletions packages/gatsby-link/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "gatsby-link",
"description": "An enhanced Link component for Gatsby sites with support for resource prefetching",
"version": "4.9.0",
"version": "4.9.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"@types/reach__router": "^1.3.10",
"gatsby-page-utils": "^2.9.0",
"gatsby-page-utils": "^2.9.1",
"prop-types": "^15.7.2"
},
"devDependencies": {
4 changes: 2 additions & 2 deletions packages/gatsby-page-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-page-utils",
"version": "2.9.0",
"version": "2.9.1",
"description": "Gatsby library that helps creating pages",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
"bluebird": "^3.7.2",
"chokidar": "^3.5.2",
"fs-exists-cached": "^1.0.0",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"glob": "^7.2.0",
"lodash": "^4.17.21",
"micromatch": "^4.0.4"
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-benchmark-reporting/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-plugin-benchmark-reporting",
"description": "Gatsby Benchmark Reporting",
"version": "2.9.0",
"version": "2.9.1",
"author": "Peter van der Zee <pvdz@github>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -21,7 +21,7 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"fast-glob": "^3.2.11",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"node-fetch": "^2.6.7"
},
"scripts": {
6 changes: 3 additions & 3 deletions packages/gatsby-plugin-gatsby-cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-plugin-gatsby-cloud",
"description": "A Gatsby plugin which optimizes working with Gatsby Cloud",
"version": "4.9.0",
"version": "4.9.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -10,8 +10,8 @@
"@babel/runtime": "^7.15.4",
"date-fns": "^2.28.0",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "^3.9.0",
"gatsby-telemetry": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"gatsby-telemetry": "^3.9.1",
"js-cookie": "^3.0.1",
"kebab-hash": "^0.1.2",
"lodash": "^4.17.21",
6 changes: 3 additions & 3 deletions packages/gatsby-plugin-image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-image",
"version": "2.9.0",
"version": "2.9.1",
"scripts": {
"build": "npm-run-all -s clean -p build:*",
"build:gatsby-node": "tsc --jsx react --downlevelIteration true --skipLibCheck true --esModuleInterop true --outDir dist/ src/gatsby-node.ts src/babel-plugin-parse-static-images.ts src/resolver-utils.ts src/types.d.ts -d --declarationDir dist/src",
@@ -77,12 +77,12 @@
"@babel/runtime": "^7.15.4",
"@babel/traverse": "^7.15.4",
"babel-jsx-utils": "^1.1.0",
"babel-plugin-remove-graphql-queries": "^4.9.0",
"babel-plugin-remove-graphql-queries": "^4.9.1",
"camelcase": "^5.3.1",
"chokidar": "^3.5.2",
"common-tags": "^1.8.2",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"objectFitPolyfill": "^2.3.5",
"prop-types": "^15.7.2"
},
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "gatsby-plugin-manifest",
"description": "Gatsby plugin which adds a manifest.webmanifest to make sites progressive web apps",
"version": "4.9.0",
"version": "4.9.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"gatsby-plugin-utils": "^3.3.0",
"semver": "^7.3.5",
"sharp": "^0.30.1"
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-mdx",
"version": "3.9.0",
"version": "3.9.1",
"description": "MDX integration for Gatsby",
"main": "index.js",
"license": "MIT",
@@ -37,7 +37,7 @@
"escape-string-regexp": "^1.0.5",
"eval": "^0.1.4",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"gray-matter": "^4.0.2",
"json5": "^2.1.3",
"loader-utils": "^1.4.0",
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-offline/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "gatsby-plugin-offline",
"description": "Gatsby plugin which sets up a site to be able to run offline",
"version": "5.9.0",
"version": "5.9.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"cheerio": "^1.0.0-rc.10",
"gatsby-core-utils": "^3.9.0",
"gatsby-core-utils": "^3.9.1",
"glob": "^7.2.0",
"idb-keyval": "^3.2.0",
"lodash": "^4.17.21",
Loading