This commit is contained in:
Eugene Zolenko 2019-12-03 10:24:39 -07:00
parent 4217346054
commit 23f63b4da2
12 changed files with 27 additions and 26 deletions

View File

@ -1,6 +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 getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot, cwd }: 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,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;AAiBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,OAoB/G"}
{"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,GAAG,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA+BnK;AAiBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,OAoB/G"}

2
dist/host.d.ts vendored
View File

@ -8,7 +8,7 @@ export declare class LanguageServiceHost implements tsTypes.LanguageServiceHost
private versions;
private service?;
private fileNames;
constructor(parsedConfig: tsTypes.ParsedCommandLine, transformers: TransformerFactoryCreator[]);
constructor(parsedConfig: tsTypes.ParsedCommandLine, transformers: TransformerFactoryCreator[], cwd: string);
reset(): void;
setLanguageService(service: tsTypes.LanguageService): void;
setSnapshot(fileName: string, data: string): tsTypes.IScriptSnapshot;

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

@ -1 +1 @@
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["src/host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,qBAAa,mBAAoB,YAAW,OAAO,CAAC,mBAAmB;IAQ1D,OAAO,CAAC,YAAY;IAA6B,OAAO,CAAC,YAAY;IANjF,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAuD;IACxE,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,OAAO,CAAC,CAA0B;IAC1C,OAAO,CAAC,SAAS,CAAc;gBAEX,YAAY,EAAE,OAAO,CAAC,iBAAiB,EAAU,YAAY,EAAE,yBAAyB,EAAE;IAKvG,KAAK;IAML,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe;IAKnD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe;IAWpE,iBAAiB,CAA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UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAqW7C,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,CAsW7C,CAAC;AAEF,eAAe,UAAU,CAAC"}

1
dist/ioptions.d.ts vendored
View File

@ -7,6 +7,7 @@ export interface ICustomTransformer {
}
export declare type TransformerFactoryCreator = (ls: tsTypes.LanguageService) => tsTypes.CustomTransformers | ICustomTransformer;
export interface IOptions {
cwd: string;
include: string | string[];
exclude: string | string[];
check: boolean;

View File

@ -1 +1 @@
{"version":3,"file":"ioptions.d.ts","sourceRoot":"","sources":["src/ioptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IAElC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpF;AAED,oBAAY,yBAAyB,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,eAAe,KAAK,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAEzH,MAAM,WAAW,QAAQ;IAExB,OAAO,EAAE,MAAM,GAAC,MAAM,EAAE,CAA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,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,yBAAyB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB,EAAE,OAAO,CAAC;IACnC,UAAU,EAAE,OAAO,QAAQ,CAAC;IAC5B,gBAAgB,EAAE,GAAG,CAAC;IACtB,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,gBAAgB,EAAE,GAAG,CAAC;IACtB,iBAAiB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,2BAA2B,EAAE,OAAO,CAAC;CACrC"}

View File

@ -17222,13 +17222,13 @@ function normalize(fileName) {
}
class LanguageServiceHost {
constructor(parsedConfig, transformers) {
constructor(parsedConfig, transformers, cwd) {
this.parsedConfig = parsedConfig;
this.transformers = transformers;
this.cwd = process.cwd();
this.snapshots = {};
this.versions = {};
this.fileNames = new Set(parsedConfig.fileNames);
this.cwd = cwd;
}
reset() {
this.snapshots = {};
@ -24964,7 +24964,7 @@ function printDiagnostics(context, diagnostics, pretty) {
// tslint:disable-next-line:no-var-requires
const createRollupFilter = require("rollup-pluginutils").createFilter;
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot, cwd }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
importHelpers: true,
@ -24982,7 +24982,7 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
if (!declaration)
overrides.declarationDir = undefined;
if (declaration && !useTsconfigDeclarationDir)
overrides.declarationDir = process.cwd();
overrides.declarationDir = cwd;
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
@ -25024,12 +25024,12 @@ function checkTsConfig(parsedConfig) {
}
function parseTsConfig(context, pluginOptions) {
const fileName = tsModule.findConfigFile(process.cwd(), tsModule.sys.fileExists, pluginOptions.tsconfig);
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
// if the value was provided, but no file, fail hard
if (pluginOptions.tsconfig !== undefined && !fileName)
throw new Error(`failed to open '${fileName}'`);
let loadedConfig = {};
let baseDir = process.cwd();
let baseDir = pluginOptions.cwd;
let configFileName;
let pretty = false;
if (fileName) {
@ -27263,6 +27263,7 @@ const typescript = (options) => {
transformers: [],
tsconfigDefaults: {},
objectHashIgnoreUnknownHack: false,
cwd: process.cwd(),
});
if (!pluginOptions.typescript) {
pluginOptions.typescript = require("typescript");
@ -27291,7 +27292,7 @@ const typescript = (options) => {
context.info(`running in watch mode`);
}
filter = createFilter(context, pluginOptions, parsedConfig);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
servicesHost.setLanguageService(service);
// printing compiler option errors
@ -27455,7 +27456,7 @@ const typescript = (options) => {
tsModule.sys.writeFile(fileName, entry.text, entry.writeByteOrderMark);
}
else {
const relativePath = path.relative(process.cwd(), fileName);
const relativePath = path.relative(pluginOptions.cwd, fileName);
context.debug(() => `${safe_5("emitting declarations")} for '${key}' to '${relativePath}'`);
this.emitFile({
type: "asset",

File diff suppressed because one or more lines are too long

View File

@ -17216,13 +17216,13 @@ function normalize(fileName) {
}
class LanguageServiceHost {
constructor(parsedConfig, transformers) {
constructor(parsedConfig, transformers, cwd) {
this.parsedConfig = parsedConfig;
this.transformers = transformers;
this.cwd = process.cwd();
this.snapshots = {};
this.versions = {};
this.fileNames = new Set(parsedConfig.fileNames);
this.cwd = cwd;
}
reset() {
this.snapshots = {};
@ -24958,7 +24958,7 @@ function printDiagnostics(context, diagnostics, pretty) {
// tslint:disable-next-line:no-var-requires
const createRollupFilter = require("rollup-pluginutils").createFilter;
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot, cwd }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
importHelpers: true,
@ -24976,7 +24976,7 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
if (!declaration)
overrides.declarationDir = undefined;
if (declaration && !useTsconfigDeclarationDir)
overrides.declarationDir = process.cwd();
overrides.declarationDir = cwd;
// unsetting sourceRoot if sourceMap is not enabled (in case original tsconfig had inlineSourceMap set that is being unset and would cause TS5051)
const sourceMap = preParsedTsconfig.options.sourceMap;
if (!sourceMap)
@ -25018,12 +25018,12 @@ function checkTsConfig(parsedConfig) {
}
function parseTsConfig(context, pluginOptions) {
const fileName = tsModule.findConfigFile(process.cwd(), tsModule.sys.fileExists, pluginOptions.tsconfig);
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
// if the value was provided, but no file, fail hard
if (pluginOptions.tsconfig !== undefined && !fileName)
throw new Error(`failed to open '${fileName}'`);
let loadedConfig = {};
let baseDir = process.cwd();
let baseDir = pluginOptions.cwd;
let configFileName;
let pretty = false;
if (fileName) {
@ -27257,6 +27257,7 @@ const typescript = (options) => {
transformers: [],
tsconfigDefaults: {},
objectHashIgnoreUnknownHack: false,
cwd: process.cwd(),
});
if (!pluginOptions.typescript) {
pluginOptions.typescript = require("typescript");
@ -27285,7 +27286,7 @@ const typescript = (options) => {
context.info(`running in watch mode`);
}
filter = createFilter(context, pluginOptions, parsedConfig);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers);
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
servicesHost.setLanguageService(service);
// printing compiler option errors
@ -27449,7 +27450,7 @@ const typescript = (options) => {
tsModule.sys.writeFile(fileName, entry.text, entry.writeByteOrderMark);
}
else {
const relativePath = relative(process.cwd(), fileName);
const relativePath = relative(pluginOptions.cwd, fileName);
context.debug(() => `${safe_5("emitting declarations")} for '${key}' to '${relativePath}'`);
this.emitFile({
type: "asset",

File diff suppressed because one or more lines are too long

View File

@ -359,7 +359,6 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
else
{
const relativePath = relative(pluginOptions.cwd, fileName);
console.log('>>> DEBUG2', pluginOptions.cwd, relativePath, fileName);
context.debug(() => `${blue("emitting declarations")} for '${key}' to '${relativePath}'`);
this.emitFile({
type: "asset",
@ -369,7 +368,6 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
}
};
console.log('>>> DEBUG', 'declarations', declarations);
_.each(declarations, ({ type, map }, key) =>
{
emitDeclaration(key, ".d.ts", type);