forked from rollup/plugins
/
plugin.ts
46 lines (43 loc) 路 1.3 KB
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as defaultTs from 'typescript';
import { RollupTypescriptOptions, PartialCompilerOptions } from '../../types';
import { getTsLibPath } from '../tslib';
/**
* Separate the Rollup plugin options from the Typescript compiler options,
* and normalize the Rollup options.
* @returns Object with normalized options:
* - `filter`: Checks if a file should be included.
* - `tsconfig`: Path to a tsconfig, or directive to ignore tsconfig.
* - `compilerOptions`: Custom Typescript compiler options that override tsconfig.
* - `typescript`: Instance of Typescript library (possibly custom).
* - `tslib`: ESM code from the tslib helper library (possibly custom).
*/
export const getPluginOptions = (options: RollupTypescriptOptions) => {
const {
cacheDir,
exclude,
include,
filterRoot,
noForceEmit,
transformers,
tsconfig,
tslib,
typescript,
outputToFilesystem,
compilerOptions,
// previously was compilerOptions
...extra
} = options;
return {
cacheDir,
include,
exclude,
filterRoot,
noForceEmit: noForceEmit || false,
tsconfig,
compilerOptions: { ...extra, ...compilerOptions } as PartialCompilerOptions,
typescript: typescript || defaultTs,
tslib: tslib || getTsLibPath(),
transformers,
outputToFilesystem
};
};