- refactoring

This commit is contained in:
Eugene Zolenko 2019-02-25 11:18:48 -07:00
parent 36aabef5ca
commit 9188132749
11 changed files with 1184 additions and 200 deletions

View File

@ -1,4 +1,6 @@
import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
import { IContext } from "./context";
export declare function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, preParsedTsconfig?: tsTypes.ParsedCommandLine): tsTypes.CompilerOptions;
export declare function createFilter(context: IContext, pluginOptions: IOptions, parsedConfig: tsTypes.ParsedCommandLine): any;
//# sourceMappingURL=get-options-overrides.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"get-options-overrides.d.ts","sourceRoot":"","sources":["src/get-options-overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA+B9J"}
{"version":3,"file":"get-options-overrides.d.ts","sourceRoot":"","sources":["src/get-options-overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA+B9J;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,OAsC/G"}

2
dist/index.d.ts.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,OAAO,EAAE,UAAU,EAAgG,MAAM,QAAQ,CAAC;AAElI,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAsW7C,CAAC;AAEF,eAAe,UAAU,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,OAAO,EAAE,UAAU,EAAgG,MAAM,QAAQ,CAAC;AAGlI,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAgU7C,CAAC;AAEF,eAAe,UAAU,CAAC"}

View File

@ -24947,6 +24947,8 @@ function printDiagnostics(context, diagnostics, pretty) {
});
}
// tslint:disable-next-line:no-var-requires
const createRollupFilter = require("rollup-pluginutils").createFilter;
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
@ -24972,6 +24974,36 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
overrides.sourceRoot = undefined;
}
return overrides;
}
function createFilter(context, pluginOptions, parsedConfig) {
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => path.join(root, include));
else
return path.join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => path.join(root, exclude));
else
return path.join(root, pluginOptions.exclude);
})
.uniq()
.value();
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}
else {
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
}
}
function checkTsConfig(parsedConfig) {
@ -26426,9 +26458,6 @@ var semver_38 = semver.intersects;
var semver_39 = semver.coerce;
const typescript = (options) => {
// tslint:disable-next-line:no-var-requires
const createFilter = require("rollup-pluginutils").createFilter;
// tslint:enable-next-line:no-var-requires
let watchMode = false;
let generateRound = 0;
let rollupOptions;
@ -26484,34 +26513,7 @@ const typescript = (options) => {
if (watchMode)
context.info(`running in watch mode`);
parsedConfig = parseTsConfig(context, pluginOptions);
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => path.join(root, include));
else
return path.join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => path.join(root, exclude));
else
return path.join(root, pluginOptions.exclude);
})
.uniq()
.value();
filter = createFilter(included, excluded);
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
}
else {
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
}
filter = createFilter(context, pluginOptions, parsedConfig);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers);
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
servicesHost.setLanguageService(service);

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ import crypto from 'crypto';
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync, pathExistsSync, readdirSync as readdirSync$1, statSync } from 'fs-extra';
import util from 'util';
import os from 'os';
import { normalize as normalize$1, dirname, join, isAbsolute, relative } from 'path';
import { normalize as normalize$1, join, dirname, isAbsolute, relative } from 'path';
import { sync } from 'resolve';
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@ -24943,6 +24943,8 @@ function printDiagnostics(context, diagnostics, pretty) {
});
}
// tslint:disable-next-line:no-var-requires
const createRollupFilter = require("rollup-pluginutils").createFilter;
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
@ -24968,6 +24970,36 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
overrides.sourceRoot = undefined;
}
return overrides;
}
function createFilter(context, pluginOptions, parsedConfig) {
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}
else {
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
}
}
function checkTsConfig(parsedConfig) {
@ -26422,9 +26454,6 @@ var semver_38 = semver.intersects;
var semver_39 = semver.coerce;
const typescript = (options) => {
// tslint:disable-next-line:no-var-requires
const createFilter = require("rollup-pluginutils").createFilter;
// tslint:enable-next-line:no-var-requires
let watchMode = false;
let generateRound = 0;
let rollupOptions;
@ -26480,34 +26509,7 @@ const typescript = (options) => {
if (watchMode)
context.info(`running in watch mode`);
parsedConfig = parseTsConfig(context, pluginOptions);
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();
filter = createFilter(included, excluded);
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
}
else {
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
}
filter = createFilter(context, pluginOptions, parsedConfig);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers);
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
servicesHost.setLanguageService(service);

File diff suppressed because one or more lines are too long

1154
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
"dependencies": {
"fs-extra": "7.0.1",
"resolve": "1.8.1",
"rollup-pluginutils": "2.3.3",
"rollup-pluginutils": "2.4.1",
"tslib": "1.9.3"
},
"peerDependencies": {
@ -46,7 +46,7 @@
"@types/node": "8.0.47",
"@types/object-hash": "1.2.0",
"@types/resolve": "0.0.8",
"@types/semver": "5.5.0",
"@types/semver": "5.5.0",
"colors": "1.3.3",
"graphlib": "2.1.7",
"lodash": "4.17.11",

View File

@ -2,6 +2,11 @@ import { tsModule } from "./tsproxy";
import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
import * as _ from "lodash";
import { join } from "path";
import { IContext } from "./context";
// tslint:disable-next-line:no-var-requires
const createRollupFilter = require("rollup-pluginutils").createFilter;
export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, preParsedTsconfig?: tsTypes.ParsedCommandLine): tsTypes.CompilerOptions
{
@ -35,3 +40,43 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
return overrides;
}
export function createFilter(context: IContext, pluginOptions: IOptions, parsedConfig: tsTypes.ParsedCommandLine)
{
if (parsedConfig.options.rootDirs)
{
const included = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}
else
{
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
}
}

View File

@ -17,12 +17,10 @@ import { normalize } from "./normalize";
import { satisfies } from "semver";
import { PluginImpl, PluginContext, InputOptions, OutputOptions, TransformSourceDescription, MinimalPluginContext } from "rollup";
import { createFilter } from "./get-options-overrides";
const typescript: PluginImpl<Partial<IOptions>> = (options) =>
{
// tslint:disable-next-line:no-var-requires
const createFilter = require("rollup-pluginutils").createFilter;
// tslint:enable-next-line:no-var-requires
let watchMode = false;
let generateRound = 0;
let rollupOptions: InputOptions;
@ -96,42 +94,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
parsedConfig = parseTsConfig(context, pluginOptions);
if (parsedConfig.options.rootDirs)
{
const included = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();
filter = createFilter(included, excluded);
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
}
else
{
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
}
filter = createFilter(context, pluginOptions, parsedConfig);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers);