Skip to content

Commit

Permalink
minimize amount of times dependency checker runs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Sep 20, 2024
1 parent 952a775 commit 93a1d6f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 27 deletions.
8 changes: 8 additions & 0 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm turbo build"
},
"lint-staged": {
"**/package.json": "sort-package-json",
"*.{md,mdx,yml,json}": "prettier --write",
"*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint --cache --fix"
]
},
"dependencies": {
"@dnd-kit/core": "6.0.8",
"@payloadcms/graphql": "workspace:*",
Expand Down
60 changes: 35 additions & 25 deletions packages/next/src/layouts/Root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const customReactVersionParser: CustomVersionParser = (version) => {
return { parts, preReleases }
}

let checkedDependencies = false

export const RootLayout = async ({
children,
config: configPromise,
Expand All @@ -45,32 +47,40 @@ export const RootLayout = async ({
readonly config: Promise<SanitizedConfig>
readonly importMap: ImportMap
}) => {
// First load. First check if there are mismatching dependency versions of next / react packages
await checkDependencies({
dependencyGroups: [
{
name: 'react',
dependencies: ['react', 'react-dom'],
targetVersionDependency: 'react',
},
],
dependencyVersions: {
next: {
required: false,
version: '>=15.0.0-canary.160',
},
react: {
customVersionParser: customReactVersionParser,
required: false,
version: '>=19.0.0-rc-5dcb0097-20240918',
},
'react-dom': {
customVersionParser: customReactVersionParser,
required: false,
version: '>=19.0.0-rc-5dcb0097-20240918',
if (
process.env.NODE_ENV !== 'production' &&
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&
!checkedDependencies
) {
// eslint-disable-next-line react-compiler/react-compiler
checkedDependencies = true
// First check if there are mismatching dependency versions of next / react packages
await checkDependencies({
dependencyGroups: [
{
name: 'react',
dependencies: ['react', 'react-dom'],
targetVersionDependency: 'react',
},
],
dependencyVersions: {
next: {
required: false,
version: '>=15.0.0-canary.160',
},
react: {
customVersionParser: customReactVersionParser,
required: false,
version: '>=19.0.0-rc-5dcb0097-20240918',
},
'react-dom': {
customVersionParser: customReactVersionParser,
required: false,
version: '>=19.0.0-rc-5dcb0097-20240918',
},
},
},
})
})
}

const config = await configPromise

Expand Down
6 changes: 5 additions & 1 deletion packages/payload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export type TypedAuthOperations = ResolveAuthOperationsType<GeneratedTypes>
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)

let checkedDependencies = false

/**
* @description Payload
*/
Expand Down Expand Up @@ -432,8 +434,10 @@ export class BasePayload {
async init(options: InitOptions): Promise<Payload> {
if (
process.env.NODE_ENV !== 'production' &&
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true'
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&
!checkedDependencies
) {
checkedDependencies = true
await checkPayloadDependencies()
}

Expand Down
5 changes: 4 additions & 1 deletion packages/richtext-lexical/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ import { recurseNodeTree } from './utilities/recurseNodeTree.js'
import { richTextValidateHOC } from './validate/index.js'

let defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig = null
let checkedDependencies = false

export function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapterProvider {
return async ({ config, isRoot, parentIsLocalized }) => {
if (
process.env.NODE_ENV !== 'production' &&
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true'
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&
!checkedDependencies
) {
checkedDependencies = true
await checkDependencies({
dependencyGroups: [
{
Expand Down

0 comments on commit 93a1d6f

Please sign in to comment.