chore: able to select bundler in dev

This commit is contained in:
James
2023-10-01 15:47:16 -04:00
parent f8d456d762
commit ee22a488c0
4 changed files with 29 additions and 16 deletions

View File

@@ -131,12 +131,17 @@ export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise<Inl
// TODO: need to handle this better. This is overly simple.
if (source.startsWith('.')) {
fullSourcePath = path.resolve(path.dirname(importer), source)
}
if (fullSourcePath) {
const aliasMatch = absoluteAliases[fullSourcePath]
if (aliasMatch) {
return aliasMatch
const exactMatch = absoluteAliases[fullSourcePath]
if (exactMatch) return exactMatch
const indexMatch = absoluteAliases[`${fullSourcePath}/index`]
if (indexMatch) return indexMatch
const withoutFileExtensionMatch =
absoluteAliases[`${fullSourcePath.replace(/\.[^/.]+$/, '')}`]
if (withoutFileExtensionMatch) return withoutFileExtensionMatch
}
}

View File

@@ -4,5 +4,5 @@ export { default as BlockSearch } from '../../../admin/components/forms/field-ty
export type { Props as BlocksDrawerProps } from '../../../admin/components/forms/field-types/Blocks/BlocksDrawer/types'
export { RowActions } from '../../../admin/components/forms/field-types/Blocks/RowActions'
export { default as SectionTitle } from '../../../admin/components/forms/field-types/Blocks/SectionTitle/index'
export { Props as SectionTitleProps } from '../../../admin/components/forms/field-types/Blocks/SectionTitle/types'
export type { Props as SectionTitleProps } from '../../../admin/components/forms/field-types/Blocks/SectionTitle/types'
export type { Props } from '../../../admin/components/forms/field-types/Blocks/types'

View File

@@ -62,10 +62,12 @@ export function createLexical({
export { BlockQuoteFeature } from './field/features/BlockQuote'
export { BlocksFeature } from './field/features/Blocks'
export { HeadingFeature } from './field/features/Heading'
export { LinkFeature, LinkFeatureProps } from './field/features/Link'
export { LinkFeature } from './field/features/Link'
export type { LinkFeatureProps } from './field/features/Link'
export { ParagraphFeature } from './field/features/Paragraph'
export { RelationshipFeature } from './field/features/Relationship'
export { UploadFeature, UploadFeatureProps } from './field/features/Upload'
export { UploadFeature } from './field/features/Upload'
export type { UploadFeatureProps } from './field/features/Upload'
export { AlignFeature } from './field/features/align'
export { TextDropdownSectionWithEntries } from './field/features/common/floatingSelectToolbarTextDropdownSection'
export { TreeviewFeature } from './field/features/debug/TreeView'
@@ -82,7 +84,7 @@ export { CheckListFeature } from './field/features/lists/CheckList'
export { OrderedListFeature } from './field/features/lists/OrderedList'
export { UnoderedListFeature } from './field/features/lists/UnorderedList'
export {
export type {
Feature,
FeatureProvider,
FeatureProviderMap,

View File

@@ -2,15 +2,20 @@ import path from 'path'
import type { Config, SanitizedConfig } from '../packages/payload/src/config/types'
// import { viteBundler } from '../packages/bundler-vite/src'
import { viteBundler } from '../packages/bundler-vite/src'
import { webpackBundler } from '../packages/bundler-webpack/src'
import { mongooseAdapter } from '../packages/db-mongodb/src/index'
import { postgresAdapter } from '../packages/db-postgres/src/index'
import { mongooseAdapter } from '../packages/db-mongodb/src'
import { postgresAdapter } from '../packages/db-postgres/src'
import { buildConfig as buildPayloadConfig } from '../packages/payload/src/config/build'
import { createSlate } from '../packages/richtext-slate/src'
// process.env.PAYLOAD_DATABASE = 'postgres'
const bundlerAdapters = {
vite: viteBundler(),
webpack: webpackBundler(),
}
const databaseAdapters = {
mongoose: mongooseAdapter({
url: 'mongodb://127.0.0.1/payloadtests',
@@ -46,8 +51,7 @@ export function buildConfigWithDefaults(testConfig?: Partial<Config>): Promise<S
password: 'test',
},
...(config.admin || {}),
// bundler: viteBundler(),
bundler: webpackBundler(),
bundler: bundlerAdapters[process.env.PAYLOAD_BUNDLER || 'webpack'],
webpack: (webpackConfig) => {
const existingConfig =
typeof testConfig?.admin?.webpack === 'function'
@@ -81,8 +85,10 @@ export function buildConfigWithDefaults(testConfig?: Partial<Config>): Promise<S
__dirname,
'../packages/bundler-webpack/src/mocks/emptyModule.js',
),
'@payloadcms/db-mongodb': path.resolve(__dirname, '../packages/db-mongodb/src/mock'),
'@payloadcms/db-postgres': path.resolve(__dirname, '../packages/db-postgres/src/mock'),
[path.resolve(__dirname, '../packages/bundler-vite/src/index')]: path.resolve(
__dirname,
'../packages/bundler-vite/src/mock.js',
),
react: path.resolve(__dirname, '../packages/payload/node_modules/react'),
},
},