mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
feat: improve test & bundler (#14434)
#### PR Dependency Tree * **PR #14434** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced rspack bundler as an alternative to webpack for optimized builds. * **Tests & Quality** * Added comprehensive editor semantic tests covering markdown, hotkeys, and slash-menu operations. * Expanded CI cross-browser testing to Chromium, Firefox, and WebKit; improved shape-rendering tests to account for zoom. * **Bug Fixes** * Corrected CSS overlay styling for development servers. * Fixed TypeScript typings for build tooling. * **Other** * Document duplication now produces consistent "(n)" suffixes. * French i18n completeness increased to 100%. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export const SUPPORTED_BUNDLERS = ['webpack', 'rspack'] as const;
|
||||
|
||||
export type Bundler = (typeof SUPPORTED_BUNDLERS)[number];
|
||||
|
||||
export const DEFAULT_BUNDLER: Bundler = 'rspack';
|
||||
|
||||
function isBundler(value: string): value is Bundler {
|
||||
return SUPPORTED_BUNDLERS.includes(value as Bundler);
|
||||
}
|
||||
|
||||
export function normalizeBundler(input: string | undefined | null): Bundler {
|
||||
const value = input?.trim().toLowerCase();
|
||||
if (!value) {
|
||||
return DEFAULT_BUNDLER;
|
||||
}
|
||||
if (isBundler(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Unsupported AFFINE_BUNDLER: "${input}". Expected one of: ${SUPPORTED_BUNDLERS.join(', ')}.`
|
||||
);
|
||||
}
|
||||
|
||||
export function getBundler(env: NodeJS.ProcessEnv = process.env): Bundler {
|
||||
return normalizeBundler(env.AFFINE_BUNDLER);
|
||||
}
|
||||
Reference in New Issue
Block a user