@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
52 lines (49 loc) • 2.13 kB
JavaScript
import { ADMIN_VITE_ALIAS_MODULES } from './admin-vite-alias-modules.mjs';
import { getModulePathFrom, getModulePath } from './resolve-module.mjs';
import { ADMIN_VITE_SINGLETON_MODULES } from './admin-vite-singleton-modules.mjs';
/**
* Vite resolve.alias entries for the admin bundle.
*
* Admin alias modules resolve from @strapi/admin's closure. CodeMirror singletons resolve
* from @strapi/design-system's closure (the real consumer), tolerantly: optional/transitive
* CodeMirror packages that cannot be resolved are skipped rather than crashing the build
*
* @internal
*/ const buildAdminViteResolveAliases = ()=>Object.fromEntries([
...ADMIN_VITE_ALIAS_MODULES.map((mod)=>[
mod,
getModulePath(mod)
]),
...buildSingletonAliasEntries()
]);
/**
* Resolve the CodeMirror singleton aliases from @strapi/design-system's closure, skipping any
* package that cannot be resolved (e.g. optional or transitive CodeMirror packages not installed).
*
* @internal
*/ const buildSingletonAliasEntries = ()=>{
const entries = [];
for (const mod of ADMIN_VITE_SINGLETON_MODULES){
try {
entries.push([
mod,
getModulePathFrom('@strapi/design-system', mod)
]);
} catch {
// Optional/transitive CodeMirror package not resolvable here — skip it rather than
// throwing, so a missing singleton never breaks the admin build.
}
}
return entries;
};
/**
* Names of the CodeMirror singletons that actually resolve from @strapi/design-system's closure.
*
* Mirrors buildSingletonAliasEntries so optimizeDeps.include stays in lockstep with resolve.alias:
* a singleton that cannot be aliased must not be forced into pre-bundling either, or Vite chokes
* on an unresolvable optimizeDeps.include entry.
*
* @internal
*/ const getResolvableSingletonModules = ()=>buildSingletonAliasEntries().map(([mod])=>mod);
export { buildAdminViteResolveAliases, buildSingletonAliasEntries, getResolvableSingletonModules };
//# sourceMappingURL=admin-vite-aliases.mjs.map