fix: imports (part 2/2) (#13520)
Completes https://github.com/payloadcms/payload/pull/13513 That PR fixed it for the `admin` suite, but I had also encountered the same issue in `live-preview`. When searching for instances, I found others with the same pattern within packages, which I took the opportunity to fix in case the same error occurs in the future.
This commit is contained in:
@@ -2,7 +2,7 @@ import { createServer } from 'http'
|
||||
import next from 'next'
|
||||
import { parse } from 'url'
|
||||
|
||||
const actualNext = next.default || next
|
||||
const actualNext = 'default' in next ? next.default : next
|
||||
export const bootAdminPanel = async ({ port = 3000, appDir }) => {
|
||||
const serverURL = `http://localhost:${port}`
|
||||
const app = actualNext({
|
||||
|
||||
@@ -7,7 +7,7 @@ import React from 'react'
|
||||
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export type Props = {
|
||||
appearance?: 'default' | 'none' | 'primary' | 'secondary'
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Post } from '../../../../payload-types.js'
|
||||
import { Media } from '../Media/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export const Card: React.FC<{
|
||||
alignItems?: 'center'
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Gutter } from '../Gutter/index.js'
|
||||
import { CMSLink } from '../Link/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export async function Footer() {
|
||||
const footer = await getFooter()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Gutter } from '../Gutter/index.js'
|
||||
import classes from './index.module.scss'
|
||||
import { HeaderNav } from './Nav/index.js'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export async function Header() {
|
||||
const header = await getHeader()
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Props as ButtonProps } from '../Button/index.js'
|
||||
|
||||
import { Button } from '../Button/index.js'
|
||||
|
||||
const NextLink = (NextLinkImport.default || NextLinkImport) as typeof NextLinkImport.default
|
||||
const NextLink = 'default' in NextLinkImport ? NextLinkImport.default : NextLinkImport
|
||||
|
||||
type CMSLinkType = {
|
||||
appearance?: ButtonProps['appearance']
|
||||
|
||||
@@ -13,8 +13,8 @@ import classes from './index.module.scss'
|
||||
|
||||
const { breakpoints } = cssVariables
|
||||
|
||||
const NextImage = (NextImageWithDefault.default ||
|
||||
NextImageWithDefault) as typeof NextImageWithDefault.default
|
||||
const NextImage =
|
||||
'default' in NextImageWithDefault ? NextImageWithDefault.default : NextImageWithDefault
|
||||
|
||||
export const Image: React.FC<MediaProps> = (props) => {
|
||||
const {
|
||||
|
||||
@@ -10,7 +10,7 @@ import RichText from '../../_components/RichText/index.js'
|
||||
import { formatDateTime } from '../../_utilities/formatDateTime.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export const PostHero: React.FC<{
|
||||
post: Post
|
||||
|
||||
@@ -7,7 +7,7 @@ import React from 'react'
|
||||
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export type Props = {
|
||||
appearance?: 'default' | 'none' | 'primary' | 'secondary'
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Post } from '../../../../../payload-types.js'
|
||||
import { Media } from '../Media/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export const Card: React.FC<{
|
||||
alignItems?: 'center'
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Gutter } from '../Gutter/index.js'
|
||||
import { CMSLink } from '../Link/index.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export async function Footer() {
|
||||
const footer = await getFooter()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Gutter } from '../Gutter/index.js'
|
||||
import classes from './index.module.scss'
|
||||
import { HeaderNav } from './Nav/index.js'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export async function Header() {
|
||||
const header = await getHeader()
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Props as ButtonProps } from '../Button/index.js'
|
||||
|
||||
import { Button } from '../Button/index.js'
|
||||
|
||||
const NextLink = (NextLinkImport.default || NextLinkImport) as typeof NextLinkImport.default
|
||||
const NextLink = 'default' in NextLinkImport ? NextLinkImport.default : NextLinkImport
|
||||
|
||||
type CMSLinkType = {
|
||||
appearance?: ButtonProps['appearance']
|
||||
|
||||
@@ -13,8 +13,8 @@ import classes from './index.module.scss'
|
||||
|
||||
const { breakpoints } = cssVariables
|
||||
|
||||
const NextImage = (NextImageWithDefault.default ||
|
||||
NextImageWithDefault) as typeof NextImageWithDefault.default
|
||||
const NextImage =
|
||||
'default' in NextImageWithDefault ? NextImageWithDefault.default : NextImageWithDefault
|
||||
|
||||
export const Image: React.FC<MediaProps> = (props) => {
|
||||
const {
|
||||
|
||||
@@ -10,7 +10,7 @@ import RichText from '../../_components/RichText/index.js'
|
||||
import { formatDateTime } from '../../_utilities/formatDateTime.js'
|
||||
import classes from './index.module.scss'
|
||||
|
||||
const Link = (LinkWithDefault.default || LinkWithDefault) as typeof LinkWithDefault.default
|
||||
const Link = 'default' in LinkWithDefault ? LinkWithDefault.default : LinkWithDefault
|
||||
|
||||
export const PostHero: React.FC<{
|
||||
post: Post
|
||||
|
||||
Reference in New Issue
Block a user