mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- fix for options typings
This commit is contained in:
parent
ae7262f253
commit
c204a3ec92
20
dist/index.d.ts
vendored
20
dist/index.d.ts
vendored
@ -1,17 +1,17 @@
|
||||
import { IRollupContext } from "./context";
|
||||
import { ICode } from "./tscache";
|
||||
export interface IOptions {
|
||||
include: string;
|
||||
exclude: string;
|
||||
check: boolean;
|
||||
verbosity: number;
|
||||
clean: boolean;
|
||||
cacheRoot: string;
|
||||
abortOnError: boolean;
|
||||
rollupCommonJSResolveHack: boolean;
|
||||
tsconfig: string;
|
||||
include?: string;
|
||||
exclude?: string;
|
||||
check?: boolean;
|
||||
verbosity?: number;
|
||||
clean?: boolean;
|
||||
cacheRoot?: string;
|
||||
abortOnError?: boolean;
|
||||
rollupCommonJSResolveHack?: boolean;
|
||||
tsconfig?: string;
|
||||
}
|
||||
export default function typescript(options: IOptions): {
|
||||
export default function typescript(options?: IOptions): {
|
||||
options(config: any): void;
|
||||
resolveId(importee: string, importer: string): string | null;
|
||||
load(id: string): string | undefined;
|
||||
|
||||
2
dist/rollup-plugin-typescript2.cjs.js
vendored
2
dist/rollup-plugin-typescript2.cjs.js
vendored
@ -473,7 +473,7 @@ function typescript(options) {
|
||||
exclude: ["*.d.ts", "**/*.d.ts"],
|
||||
abortOnError: true,
|
||||
rollupCommonJSResolveHack: false,
|
||||
tsconfig: "tsconfig.json"
|
||||
tsconfig: "tsconfig.json",
|
||||
});
|
||||
var rollupConfig;
|
||||
var watchMode = false;
|
||||
|
||||
2
dist/rollup-plugin-typescript2.es.js
vendored
2
dist/rollup-plugin-typescript2.es.js
vendored
@ -479,7 +479,7 @@ function typescript(options) {
|
||||
exclude: ["*.d.ts", "**/*.d.ts"],
|
||||
abortOnError: true,
|
||||
rollupCommonJSResolveHack: false,
|
||||
tsconfig: "tsconfig.json"
|
||||
tsconfig: "tsconfig.json",
|
||||
});
|
||||
var rollupConfig;
|
||||
var watchMode = false;
|
||||
|
||||
34
src/index.ts
34
src/index.ts
@ -96,18 +96,18 @@ function printDiagnostics(context: IContext, diagnostics: IDiagnostics[])
|
||||
|
||||
export interface IOptions
|
||||
{
|
||||
include: string;
|
||||
exclude: string;
|
||||
check: boolean;
|
||||
verbosity: number;
|
||||
clean: boolean;
|
||||
cacheRoot: string;
|
||||
abortOnError: boolean;
|
||||
rollupCommonJSResolveHack: boolean;
|
||||
tsconfig: string;
|
||||
include?: string;
|
||||
exclude?: string;
|
||||
check?: boolean;
|
||||
verbosity?: number;
|
||||
clean?: boolean;
|
||||
cacheRoot?: string;
|
||||
abortOnError?: boolean;
|
||||
rollupCommonJSResolveHack?: boolean;
|
||||
tsconfig?: string;
|
||||
}
|
||||
|
||||
export default function typescript(options: IOptions)
|
||||
export default function typescript(options?: IOptions)
|
||||
{
|
||||
options = { ... options };
|
||||
|
||||
@ -130,14 +130,14 @@ export default function typescript(options: IOptions)
|
||||
let round = 0;
|
||||
let targetCount = 0;
|
||||
|
||||
const context = new ConsoleContext(options.verbosity, "rpt2: ");
|
||||
const context = new ConsoleContext(options.verbosity!, "rpt2: ");
|
||||
|
||||
context.info(`Typescript version: ${ts.version}`);
|
||||
context.debug(`Options: ${JSON.stringify(options, undefined, 4)}`);
|
||||
|
||||
const filter = createFilter(options.include, options.exclude);
|
||||
|
||||
const parsedConfig = parseTsConfig(options.tsconfig, context);
|
||||
const parsedConfig = parseTsConfig(options.tsconfig!, context);
|
||||
|
||||
const servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
|
||||
@ -148,7 +148,7 @@ export default function typescript(options: IOptions)
|
||||
const cache = (): TsCache =>
|
||||
{
|
||||
if (!_cache)
|
||||
_cache = new TsCache(servicesHost, options.cacheRoot, parsedConfig.options, rollupConfig, parsedConfig.fileNames, context);
|
||||
_cache = new TsCache(servicesHost, options!.cacheRoot!, parsedConfig.options, rollupConfig, parsedConfig.fileNames, context);
|
||||
return _cache;
|
||||
};
|
||||
|
||||
@ -168,7 +168,7 @@ export default function typescript(options: IOptions)
|
||||
|
||||
context.debug(`rollupConfig: ${JSON.stringify(rollupConfig, undefined, 4)}`);
|
||||
|
||||
if (options.clean)
|
||||
if (options!.clean)
|
||||
cache().clean();
|
||||
},
|
||||
|
||||
@ -193,7 +193,7 @@ export default function typescript(options: IOptions)
|
||||
if (_.endsWith(result.resolvedModule.resolvedFileName, ".d.ts"))
|
||||
return null;
|
||||
|
||||
const resolved = options.rollupCommonJSResolveHack
|
||||
const resolved = options!.rollupCommonJSResolveHack
|
||||
? resolve.sync(result.resolvedModule.resolvedFileName)
|
||||
: result.resolvedModule.resolvedFileName;
|
||||
|
||||
@ -219,7 +219,7 @@ export default function typescript(options: IOptions)
|
||||
if (!filter(id))
|
||||
return undefined;
|
||||
|
||||
const contextWrapper = new RollupContext(options.verbosity, options.abortOnError, this, "rpt2: ");
|
||||
const contextWrapper = new RollupContext(options!.verbosity!, options!.abortOnError!, this, "rpt2: ");
|
||||
|
||||
const snapshot = servicesHost.setSnapshot(id, code);
|
||||
|
||||
@ -262,7 +262,7 @@ export default function typescript(options: IOptions)
|
||||
};
|
||||
});
|
||||
|
||||
if (options.check)
|
||||
if (options!.check)
|
||||
{
|
||||
const diagnostics = _.concat(
|
||||
cache().getSyntacticDiagnostics(id, snapshot, () =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user