import type * as d from '../../declarations' ; import type { Plugin } from 'rollup' ; import { USER_INDEX_ENTRY_ID } from './entry-alias-ids' ; import { join } from 'path' ; export const userIndexPlugin = ( config , compilerCtx ) : Plugin => { return { name : 'userIndexPlugin' , async resolveId ( importee ) { if ( importee === USER_INDEX_ENTRY_ID ) { const usersIndexJsPath = join ( config . srcDir , 'index.ts' ) ; const hasUserIndex = await compilerCtx . fs . access ( usersIndexJsPath ) ; if ( hasUserIndex ) { return usersIndexJsPath ; } return importee ; } return null ; } , async load ( id ) { if ( id === USER_INDEX_ENTRY_ID ) { return `//! Autogenerated index` ; } return null ; } , } ; } ;