Conditions | 3 |
Total Lines | 19 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | 1 | /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ |
|
6 | |||
7 | function pikaResolver ({ modules, cdnHost = PIKA_CDN_HOST }: { modules: string[], cdnHost: string }) { |
||
8 | 1 | const cache = new Map<string, string>() |
|
9 | |||
10 | 1 | return { |
|
11 | name: 'pika-resolver', |
||
12 | async resolveId (id: string) { |
||
13 | 2 | if (!modules.includes(id)) { |
|
14 | 1 | return id |
|
15 | } |
||
16 | |||
17 | 1 | const version = await getVersion(this, cache, id) |
|
18 | |||
19 | 1 | return { |
|
20 | id: `${cdnHost}/${version}`, |
||
21 | external: true |
||
22 | } |
||
23 | } |
||
24 | } as Plugin |
||
25 | } |
||
29 |