Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions e2e-tests/adapters/cypress/e2e/headers.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { applyTrailingSlashOption } from "../../utils"
import { WorkaroundCachedResponse } from "../utils/dont-cache-responses-in-browser"

const TRAILING_SLASH = Cypress.env(`TRAILING_SLASH`) || `never`
const PATH_PREFIX = Cypress.env(`PATH_PREFIX`) || ``

describe("Headers", () => {
Expand Down Expand Up @@ -75,7 +77,10 @@ describe("Headers", () => {
}

beforeEach(() => {
cy.intercept(PATH_PREFIX + "/", WorkaroundCachedResponse).as("index")
cy.intercept(
applyTrailingSlashOption(PATH_PREFIX, TRAILING_SLASH),
WorkaroundCachedResponse
).as("index")
cy.intercept(
PATH_PREFIX + "/routes/ssg/static",
WorkaroundCachedResponse
Expand Down Expand Up @@ -114,7 +119,9 @@ describe("Headers", () => {
})

it("should contain correct headers for index page", () => {
cy.visit("/").waitForRouteChange()
cy.visit(
applyTrailingSlashOption(Cypress.config().baseUrl, TRAILING_SLASH)
).waitForRouteChange()

checkHeaders("@index", {
...defaultHeaders,
Expand All @@ -133,7 +140,12 @@ describe("Headers", () => {
})

it("should contain correct headers for ssg page", () => {
cy.visit("routes/ssg/static").waitForRouteChange()
cy.visit(
applyTrailingSlashOption(
Cypress.config().baseUrl + "/routes/ssg/static",
TRAILING_SLASH
)
).waitForRouteChange()

checkHeaders("@ssg", {
...defaultHeaders,
Expand Down
18 changes: 14 additions & 4 deletions packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,24 @@ function checkIfNeedToInstallMissingSharp(
currentTarget: IPlatformAndArch
): IBinaryPackageStatus | undefined {
try {
// check if shapr is resolvable
const { version: sharpVersion } = require(`sharp/package.json`)
// check if sharp is resolvable
const sharp: typeof import("sharp") = require(`sharp`)

if (isEqual(functionsTarget, currentTarget)) {
return undefined
// if current platform and target is the same as functions target, we need to check if vendored libvips
// exists in the current sharp installation as it will be needed in lambda
if (sharp.vendor.installed.includes(sharp.vendor.current)) {
// vendored libvips is installed, so we can use it
return undefined
}
}

return checkIfInstalledInInternalPackagesCache(
{
needToInstall: true,
packageName: `sharp`,
packageVersion: sharpVersion,
packageVersion:
sharp.versions.sharp ?? require(`sharp/package.json`).version,
},
functionsTarget
)
Expand Down Expand Up @@ -279,6 +285,10 @@ async function installMissing(
env: {
npm_config_arch: functionsTarget.arch,
npm_config_platform: functionsTarget.platform,
// force sharp to download vendored libvips and not skip it if globally installed libvips matches sharp requirements
// so that produced function is self-sufficient and doesn't rely on function execution environment having (same)
// globally available libvips
SHARP_IGNORE_GLOBAL_LIBVIPS: `1`,
},
}

Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7608,15 +7608,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001565:
version "1.0.30001692"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz"
integrity sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A==

caniuse-lite@^1.0.30001688:
version "1.0.30001712"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001712.tgz#41ee150f12de11b5f57c5889d4f30deb451deedf"
integrity sha512-MBqPpGYYdQ7/hfKiet9SCI+nmN5/hp4ZzveOJubl5DTAMa5oggjAuoi0Z4onBpKPFI2ePGnQuQIzF3VxDjDJig==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001565, caniuse-lite@^1.0.30001688:
version "1.0.30001723"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz"
integrity sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==

capital-case@^1.0.4:
version "1.0.4"
Expand Down
Loading