@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
56 lines (52 loc) • 2.3 kB
JavaScript
;
var adminViteAliasModules = require('./admin-vite-alias-modules.js');
var resolveModule = require('./resolve-module.js');
var adminViteSingletonModules = require('./admin-vite-singleton-modules.js');
/**
* 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([
...adminViteAliasModules.ADMIN_VITE_ALIAS_MODULES.map((mod)=>[
mod,
resolveModule.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 adminViteSingletonModules.ADMIN_VITE_SINGLETON_MODULES){
try {
entries.push([
mod,
resolveModule.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);
exports.buildAdminViteResolveAliases = buildAdminViteResolveAliases;
exports.buildSingletonAliasEntries = buildSingletonAliasEntries;
exports.getResolvableSingletonModules = getResolvableSingletonModules;
//# sourceMappingURL=admin-vite-aliases.js.map