(config: SnowpackConfig)
| 23 | const localSourceCache = new WeakMap<SnowpackConfig, PackageSource>(); |
| 24 | |
| 25 | export function getPackageSource(config: SnowpackConfig): PackageSource { |
| 26 | if (config.packageOptions.source === 'remote') { |
| 27 | if (remoteSourceCache.has(config)) { |
| 28 | return remoteSourceCache.get(config)!; |
| 29 | } |
| 30 | |
| 31 | const source = new PackageSourceRemote(config); |
| 32 | remoteSourceCache.set(config, source); |
| 33 | return source; |
| 34 | } |
| 35 | |
| 36 | if (localSourceCache.has(config)) { |
| 37 | return localSourceCache.get(config)!; |
| 38 | } |
| 39 | |
| 40 | const source = new PackageSourceLocal(config); |
| 41 | localSourceCache.set(config, source); |
| 42 | return source; |
| 43 | } |
no outgoing calls
no test coverage detected