-
Notifications
You must be signed in to change notification settings - Fork 88
fix: don't deploy metadata files to CDN #2104
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
Changes from all commits
199a442
02b19ab
7309968
271e5fe
73a757d
f24dc38
3c0147f
0566f2e
68f699a
bee62a1
c94a81c
8f28acd
c303d75
d228aed
3e9080d
0fad9fc
1bef70c
465bcda
d709eb1
3399455
a9b22fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,26 @@ import { cpus } from 'os' | |
|
||
import type { NetlifyConfig } from '@netlify/build' | ||
import { yellowBright } from 'chalk' | ||
import { existsSync, readJson, move, copy, writeJson, readFile, writeFile, ensureDir, readFileSync } from 'fs-extra' | ||
import { | ||
existsSync, | ||
readJson, | ||
move, | ||
copy, | ||
writeJson, | ||
readFile, | ||
writeFile, | ||
ensureDir, | ||
readFileSync, | ||
remove, | ||
} from 'fs-extra' | ||
import globby from 'globby' | ||
import { PrerenderManifest } from 'next/dist/build' | ||
import { outdent } from 'outdent' | ||
import pLimit from 'p-limit' | ||
import { join, resolve, dirname } from 'pathe' | ||
import slash from 'slash' | ||
|
||
import { MINIMUM_REVALIDATE_SECONDS, DIVIDER } from '../constants' | ||
import { MINIMUM_REVALIDATE_SECONDS, DIVIDER, HIDDEN_PATHS } from '../constants' | ||
|
||
import { NextConfig } from './config' | ||
import { loadPrerenderManifest } from './edge' | ||
|
@@ -138,8 +149,8 @@ export const moveStaticPages = async ({ | |
console.warn('Error moving file', source, error) | ||
} | ||
} | ||
// Move all static files, except error documents and nft manifests | ||
const pages = await globby(['{app,pages}/**/*.{html,json,rsc}', '!**/(500|404|*.js.nft).{html,json}'], { | ||
// Move all static files, except nft manifests | ||
const pages = await globby(['{app,pages}/**/*.{html,json,rsc}', '!**/*.js.nft.{html,json}'], { | ||
cwd: outputDir, | ||
dot: true, | ||
}) | ||
|
@@ -467,3 +478,15 @@ export const movePublicFiles = async ({ | |
await copy(publicDir, `${publish}${basePath}/`) | ||
} | ||
} | ||
|
||
export const removeMetadataFiles = async (publish: string) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it not be faster to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally yes, but if we don't want to do 1 by 1 for perf reasons we should still limit concurrency as otherwise some starvation might happen and doing just For files moving we do have concurency of number of cpu cores, with minimum of 2 (if on single core): So I would suggest we do the same here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swapped to |
||
// Limit concurrent deletions to number of cpus or 2 if there is only 1 | ||
const limit = pLimit(Math.max(2, cpus().length)) | ||
|
||
const removePromises = HIDDEN_PATHS.map((HIDDEN_PATH) => { | ||
const pathToDelete = join(publish, HIDDEN_PATH) | ||
return limit(() => remove(pathToDelete)) | ||
}) | ||
|
||
await Promise.all(removePromises) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is primarily for
test/e2e
as those try to check metadata files after deployment, demos + cypress tests will delete those files on the other handThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's for E2E/CI only (primarily), we already have a
CI
environment variable. See a usage of it here, https://github.com/netlify/next-runtime/blob/82c1ea371bbe2194058264d7cfad912343334809/package.json#L19.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI
env var istrue
on Netlify platform, so we can't rely on that, otherwise we won't actually delete those meta files :(