function getVitePluginByName(viteConfig, pluginName) {
  const plugin = viteConfig.plugins.find(({name}) => name === pluginName);
  if (!plugin)
    throw new Error(`${pluginName} plugin couldn\u2019t be found`);
  return plugin;
}
function getViteResolvePlugin(viteConfig) {
  return getVitePluginByName(viteConfig, "vite:resolve");
}
function getViteLoadFallbackPlugin(viteConfig) {
  return getVitePluginByName(viteConfig, "vite:load-fallback");
}
function getViteResolve(viteConfig) {
  const plugin = getViteResolvePlugin(viteConfig);
  if (!plugin.resolveId)
    throw new Error(`vite:resolve has no resolveId() hook`);
  return plugin.resolveId.bind(null);
}
function getViteLoad(viteConfig) {
  const plugin = getViteLoadFallbackPlugin(viteConfig);
  if (!plugin.load)
    throw new Error(`vite:load-fallback has no load() hook`);
  return plugin.load.bind(null);
}
export {
  getViteLoad,
  getViteLoadFallbackPlugin,
  getVitePluginByName,
  getViteResolve,
  getViteResolvePlugin
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL3ZpdGUtcGx1Z2luLWJ1aWxkLWNzcy9yZXNvbHZlLnRzIl0sCiAgIm1hcHBpbmdzIjogIkFBR08sNkJBQTZCLFlBQTRCLFlBQWdDO0FBQzlGLFFBQU0sU0FBUyxXQUFXLFFBQVEsS0FBSyxDQUFDLENBQUUsVUFBVyxTQUFTO0FBQzlELE1BQUksQ0FBQztBQUFRLFVBQU0sSUFBSSxNQUFNLEdBQUc7QUFDaEMsU0FBTztBQUFBO0FBR0YsOEJBQThCLFlBQXdDO0FBQzNFLFNBQU8sb0JBQW9CLFlBQVk7QUFBQTtBQUdsQyxtQ0FBbUMsWUFBd0M7QUFDaEYsU0FBTyxvQkFBb0IsWUFBWTtBQUFBO0FBR2xDLHdCQUF3QixZQUEyQztBQUN4RSxRQUFNLFNBQVMscUJBQXFCO0FBQ3BDLE1BQUksQ0FBQyxPQUFPO0FBQVcsVUFBTSxJQUFJLE1BQU07QUFDdkMsU0FBTyxPQUFPLFVBQVUsS0FBSztBQUFBO0FBR3hCLHFCQUFxQixZQUFzQztBQUNoRSxRQUFNLFNBQVMsMEJBQTBCO0FBQ3pDLE1BQUksQ0FBQyxPQUFPO0FBQU0sVUFBTSxJQUFJLE1BQU07QUFDbEMsU0FBTyxPQUFPLEtBQUssS0FBSztBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo=
