import type { PartialResolvedId , Plugin } from 'rollup' ; import type { BuildOptions } from '../../utils/options' ; import { join } from 'path' ; param opts returns export function aliasPlugin ( opts ) { const alias = new Map ( [ [ '@app-data' , '@stencil/core/internal/app-data' ] , [ '@app-globals' , '@stencil/core/internal/app-globals' ] , [ '@hydrate-factory' , '@stencil/core/hydrate-factory' ] , [ '@stencil/core/mock-doc' , '@stencil/core/mock-doc' ] , [ '@stencil/core/testing' , '@stencil/core/testing' ] , [ '@sys-api-node' , './index.js' ] , [ '@dev-server-process' , './server-process.js' ] , ] ) ; const helperResolvers = new Set ( [ 'is-resolvable' , 'path-is-absolute' ] ) ; const nodeResolvers = new Map ( [ [ 'source-map' , join ( opts . nodeModulesDir , 'source-map' , 'source-map.js' ) ] ] ) ; const empty = new Set ( [ 'chalk' , ] ) ; return { name : 'aliasPlugin' , param id returns resolveId ( id ) { const externalId = alias . get ( id ) ; if ( externalId ) { return { id : externalId , external : true , } ; } if ( id === '@runtime' ) { return join ( opts . buildDir , 'runtime' , 'index.js' ) ; } if ( id === '@utils' ) { return join ( opts . buildDir , 'utils' , 'index.js' ) ; } if ( id === '@environment' ) { return join ( opts . buildDir , 'compiler' , 'sys' , 'environment.js' ) ; } if ( helperResolvers . has ( id ) ) { return join ( opts . bundleHelpersDir , `${ id }.js` ) ; } if ( empty . has ( id ) ) { return join ( opts . bundleHelpersDir , 'empty.js' ) ; } if ( nodeResolvers . has ( id ) ) { return nodeResolvers . get ( id ) ; } return null ; } , } ; }