1 Commits

Author SHA1 Message Date
Nermin Karic
45b58d1d9a fix: use webpack and 1 worker for low-memory storefront builds 2026-11-23 01:48:00 +01:00
2 changed files with 72 additions and 94 deletions

View File

@@ -30,12 +30,10 @@ async function listAll<T>(fetchPage: (offset: number) => Promise<Page<T>>) {
type Entry = { handle?: string | null; updated_at?: string | Date | null } type Entry = { handle?: string | null; updated_at?: string | Date | null }
export default async function sitemap(): Promise<MetadataRoute.Sitemap> { export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const origin = await getSiteOrigin()
try {
const query = { fields: "handle,updated_at", limit: PAGE_SIZE } const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
const [regions, products, categories, collections] = await Promise.all([ const [origin, regions, products, categories, collections] = await Promise.all([
getSiteOrigin(),
listRegions(), listRegions(),
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.product sdk.store.product
@@ -45,10 +43,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.category sdk.store.category
.list({ ...query, offset }) .list({ ...query, offset })
.then((res) => ({ .then((res) => ({ items: res.product_categories, count: res.count }))
items: res.product_categories,
count: res.count,
}))
), ),
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.collection sdk.store.collection
@@ -62,9 +57,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
.filter((item) => item.handle) .filter((item) => item.handle)
.map((item) => ({ .map((item) => ({
url: `${base}/${prefix}/${item.handle}`, url: `${base}/${prefix}/${item.handle}`,
lastModified: item.updated_at lastModified: item.updated_at ? new Date(item.updated_at) : undefined,
? new Date(item.updated_at)
: undefined,
})) }))
return listCountryCodes(regions).flatMap((countryCode) => { return listCountryCodes(regions).flatMap((countryCode) => {
@@ -76,8 +69,4 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
...toEntries(base, "collections", collections), ...toEntries(base, "collections", collections),
] ]
}) })
} catch {
// During Docker build the backend is not running — return static paths only
return STATIC_PATHS.map((path) => ({ url: `${origin}${path}` }))
}
} }

View File

@@ -30,12 +30,10 @@ async function listAll<T>(fetchPage: (offset: number) => Promise<Page<T>>) {
type Entry = { handle?: string | null; updated_at?: string | Date | null } type Entry = { handle?: string | null; updated_at?: string | Date | null }
export default async function sitemap(): Promise<MetadataRoute.Sitemap> { export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const origin = await getSiteOrigin()
try {
const query = { fields: "handle,updated_at", limit: PAGE_SIZE } const query = { fields: "handle,updated_at", limit: PAGE_SIZE }
const [regions, products, categories, collections] = await Promise.all([ const [origin, regions, products, categories, collections] = await Promise.all([
getSiteOrigin(),
listRegions(), listRegions(),
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.product sdk.store.product
@@ -45,10 +43,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.category sdk.store.category
.list({ ...query, offset }) .list({ ...query, offset })
.then((res) => ({ .then((res) => ({ items: res.product_categories, count: res.count }))
items: res.product_categories,
count: res.count,
}))
), ),
listAll<Entry>((offset) => listAll<Entry>((offset) =>
sdk.store.collection sdk.store.collection
@@ -62,9 +57,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
.filter((item) => item.handle) .filter((item) => item.handle)
.map((item) => ({ .map((item) => ({
url: `${base}/${prefix}/${item.handle}`, url: `${base}/${prefix}/${item.handle}`,
lastModified: item.updated_at lastModified: item.updated_at ? new Date(item.updated_at) : undefined,
? new Date(item.updated_at)
: undefined,
})) }))
return listCountryCodes(regions).flatMap((countryCode) => { return listCountryCodes(regions).flatMap((countryCode) => {
@@ -76,8 +69,4 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
...toEntries(base, "collections", collections), ...toEntries(base, "collections", collections),
] ]
}) })
} catch {
// During Docker build the backend is not running — return static paths only
return STATIC_PATHS.map((path) => ({ url: `${origin}${path}` }))
}
} }