src/index.ts   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 27
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3
mnd 1
bc 1
fnc 2
bpm 0.5
cpm 1.5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.ts ➔ skypackResolver 0 17 3
1 1
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
import { Plugin } from 'rollup'
3 1
import { getVersion, detectVersion } from './version'
4
5 1
const SKYPACK_CDN_HOST = 'https://cdn.skypack.dev'
6
7
function skypackResolver ({ modules, cdnHost = SKYPACK_CDN_HOST }: { modules: string[], cdnHost?: string }) {
8 1
  const cache = new Map<string, string>()
9
10 1
  return {
11
    name: 'skypack-resolver',
12
    async resolveId (id: string) {
13 2
      if (modules.includes(id)) {
14 1
        const version = await getVersion(this, cache, id)
15
16
        return {
17 1
          id: `${cdnHost}/${version}`,
18
          external: true
19 1
        }
20
      }
21
    }
22
  } as Plugin
23
}
24
25
export { skypackResolver, detectVersion }
26
export default skypackResolver
27