- build for 34.0

This commit is contained in:
ezolenko 2022-09-12 10:18:56 -06:00
parent ba262937f8
commit 0b99f8ec62
21 changed files with 350 additions and 355 deletions

View File

@ -1,3 +0,0 @@
import * as tsTypes from "typescript";
export declare function checkTsConfig(parsedConfig: tsTypes.ParsedCommandLine): void;
//# sourceMappingURL=check-tsconfig.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"check-tsconfig.d.ts","sourceRoot":"","sources":["../src/check-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,wBAAgB,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAM3E"}

20
dist/context.d.ts vendored
View File

@ -1,35 +1,19 @@
import { PluginContext } from "rollup";
export interface IContext {
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}
export declare enum VerbosityLevel {
Error = 0,
Warning = 1,
Info = 2,
Debug = 3
}
/** mainly to be used in options hook, but can be used in other hooks too */
export declare class ConsoleContext implements IContext {
private verbosity;
private prefix;
constructor(verbosity: VerbosityLevel, prefix?: string);
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}
/** cannot be used in options hook (which does not have this.warn and this.error), but can be in other hooks */
export declare class RollupContext implements IContext {
export declare class RollupContext {
private verbosity;
private bail;
private context;
private prefix;
constructor(verbosity: VerbosityLevel, bail: boolean, context: PluginContext, prefix?: string);
warn(message: string | (() => string)): void;
error(message: string | (() => string)): void;
error(message: string | (() => string)): void | never;
info(message: string | (() => string)): void;
debug(message: string | (() => string)): void;
}

View File

@ -1 +1 @@
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,WAAW,QAAQ;IAExB,IAAI,CAAC,OAAO,E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OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAW7C,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAO5C,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;CAMpD"}
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,oBAAY,cAAc;IAEzB,KAAK,IAAI;IACT,OAAO,IAAA;IACP,IAAI,IAAA;IACJ,KAAK,IAAA;CACL;AAMD,+GAA+G;AAC/G,qBAAa,aAAa;IAEb,OAAO,CAAC,SAAS;IAAkB,OAAO,CAAC,IAAI;IAAW,OAAO,CAAC,OAAO;IAAiB,OAAO,CAAC,MAAM;gBAAhG,SAAS,EAAE,cAAc,EAAU,IAAI,EAAE,OAAO,EAAU,OAAO,EAAE,aAAa,EAAU,MAAM,GAAE,MAAW;IAI1H,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAO5C,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI,GAAG,KAAK;IAWrD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;IAO5C,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI;CAMpD"}

13
dist/diagnostics.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
import * as tsTypes from "typescript";
import { RollupContext } from "./context";
export interface IDiagnostics {
flatMessage: string;
formatted: string;
fileLine?: string;
category: tsTypes.DiagnosticCategory;
code: number;
type: string;
}
export declare function convertDiagnostic(type: string, data: tsTypes.Diagnostic[]): IDiagnostics[];
export declare function printDiagnostics(context: RollupContext, diagnostics: IDiagnostics[], pretty?: boolean): void;
//# sourceMappingURL=diagnostics.d.ts.map

1
dist/diagnostics.d.ts.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,WAAW,YAAY;IAE5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,GAAG,YAAY,EAAE,CAoB1F;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,MAAM,UAAO,GAAG,IAAI,CAqCzG"}

View File

@ -1,6 +1,6 @@
import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
import { IContext } from "./context";
import { RollupContext } 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): (id: unknown) => boolean;
export declare function createFilter(context: RollupContext, pluginOptions: IOptions, parsedConfig: tsTypes.ParsedCommandLine): (id: unknown) => boolean;
//# 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;AAItC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA8B9J;AAeD,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,4BAoB/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;AAItC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,wBAAgB,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,CA8B9J;AAeD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,iBAAiB,4BAoBpH"}

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

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoD,MAAM,QAAQ,CAAC;AAStF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC,aAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,WAAW,CAmXvC,CAAC;AAEF,eAAe,UAAU,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoD,MAAM,QAAQ,CAAC;AAStF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC,aAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,WAAW,CAmYvC,CAAC;AAEF,eAAe,UAAU,CAAC"}

View File

@ -1,6 +1,6 @@
import { IContext } from "./context";
import { RollupContext } from "./context";
import { IOptions } from "./ioptions";
export declare function parseTsConfig(context: IContext, pluginOptions: IOptions): {
export declare function parseTsConfig(context: RollupContext, pluginOptions: IOptions): {
parsedTsConfig: import("typescript").ParsedCommandLine;
fileName: string | undefined;
};

View File

@ -1 +1 @@
{"version":3,"file":"parse-tsconfig.d.ts","sourceRoot":"","sources":["../src/parse-tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ;;;EA2CvE"}
{"version":3,"file":"parse-tsconfig.d.ts","sourceRoot":"","sources":["../src/parse-tsconfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ;;;EA8C5E"}

View File

@ -1,4 +0,0 @@
import { IContext } from "./context";
import { IDiagnostics } from "./tscache";
export declare function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty?: boolean): void;
//# sourceMappingURL=print-diagnostics.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"print-diagnostics.d.ts","sourceRoot":"","sources":["../src/print-diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,MAAM,UAAO,GAAG,IAAI,CAqCpG"}

View File

@ -12,21 +12,21 @@ var require$$0$3 = require('crypto');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
@ -37,6 +37,31 @@ var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
var fs__namespace = /*#__PURE__*/_interopNamespace(fs$4);
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var safe = {exports: {}};
@ -3006,34 +3031,6 @@ var VerbosityLevel;
function getText(message) {
return typeof message === "string" ? message : message();
}
/* tslint:disable:max-classes-per-file -- generally a good rule to follow, but these two classes could basically be one */
/** mainly to be used in options hook, but can be used in other hooks too */
class ConsoleContext {
constructor(verbosity, prefix = "") {
this.verbosity = verbosity;
this.prefix = prefix;
}
warn(message) {
if (this.verbosity < VerbosityLevel.Warning)
return;
console.log(`${this.prefix}${getText(message)}`);
}
error(message) {
if (this.verbosity < VerbosityLevel.Error)
return;
console.log(`${this.prefix}${getText(message)}`);
}
info(message) {
if (this.verbosity < VerbosityLevel.Info)
return;
console.log(`${this.prefix}${getText(message)}`);
}
debug(message) {
if (this.verbosity < VerbosityLevel.Debug)
return;
console.log(`${this.prefix}${getText(message)}`);
}
}
/** cannot be used in options hook (which does not have this.warn and this.error), but can be in other hooks */
class RollupContext {
constructor(verbosity, bail, context, prefix = "") {
@ -29192,6 +29189,54 @@ class FormatHost {
}
const formatHost = new FormatHost();
function convertDiagnostic(type, data) {
return data.map((diagnostic) => {
const entry = {
flatMessage: tsModule.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()),
formatted: tsModule.formatDiagnosticsWithColorAndContext(data, formatHost),
category: diagnostic.category,
code: diagnostic.code,
type,
};
if (diagnostic.file && diagnostic.start !== undefined) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
entry.fileLine = `${diagnostic.file.fileName}(${line + 1},${character + 1})`;
}
return entry;
});
}
function printDiagnostics(context, diagnostics, pretty = true) {
diagnostics.forEach((diagnostic) => {
let print;
let color;
let category;
switch (diagnostic.category) {
case tsModule.DiagnosticCategory.Message:
print = context.info;
color = safe.exports.white;
category = "";
break;
case tsModule.DiagnosticCategory.Error:
print = context.error;
color = safe.exports.red;
category = "error";
break;
case tsModule.DiagnosticCategory.Warning:
default:
print = context.warn;
color = safe.exports.yellow;
category = "warning";
break;
}
const type = diagnostic.type + " ";
if (pretty)
return print.call(context, `${diagnostic.formatted}`);
if (diagnostic.fileLine !== undefined)
return print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
return print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
});
}
function convertEmitOutput(output, references) {
const out = { code: "", references };
output.outputFiles.forEach((e) => {
@ -29216,22 +29261,6 @@ function getAllReferences(importer, snapshot, options) {
return (_a = resolved.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
}));
}
function convertDiagnostic(type, data) {
return data.map((diagnostic) => {
const entry = {
flatMessage: tsModule.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
formatted: tsModule.formatDiagnosticsWithColorAndContext(data, formatHost),
category: diagnostic.category,
code: diagnostic.code,
type,
};
if (diagnostic.file && diagnostic.start !== undefined) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
entry.fileLine = `${diagnostic.file.fileName}(${line + 1},${character + 1})`;
}
return entry;
});
}
class TsCache {
constructor(noCache, hashIgnoreUnknown, host, cacheRoot, options, rollupConfig, rootFilenames, context) {
this.noCache = noCache;
@ -29395,38 +29424,6 @@ class TsCache {
}
}
function printDiagnostics(context, diagnostics, pretty = true) {
diagnostics.forEach((diagnostic) => {
let print;
let color;
let category;
switch (diagnostic.category) {
case tsModule.DiagnosticCategory.Message:
print = context.info;
color = safe.exports.white;
category = "";
break;
case tsModule.DiagnosticCategory.Error:
print = context.error;
color = safe.exports.red;
category = "error";
break;
case tsModule.DiagnosticCategory.Warning:
default:
print = context.warn;
color = safe.exports.yellow;
category = "warning";
break;
}
const type = diagnostic.type + " ";
if (pretty)
return print.call(context, `${diagnostic.formatted}`);
if (diagnostic.fileLine !== undefined)
return print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
return print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
});
}
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
@ -29478,18 +29475,12 @@ function createFilter(context, pluginOptions, parsedConfig) {
return pluginutils.createFilter(included, excluded, { resolve: parsedConfig.options.rootDir });
}
function checkTsConfig(parsedConfig) {
const module = parsedConfig.options.module;
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ES2020 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`rpt2: Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
}
function parseTsConfig(context, pluginOptions) {
var _a, _b;
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(`rpt2: failed to open '${pluginOptions.tsconfig}'`);
context.error(`failed to open '${pluginOptions.tsconfig}'`);
let loadedConfig = {};
let baseDir = pluginOptions.cwd;
let configFileName;
@ -29500,7 +29491,7 @@ function parseTsConfig(context, pluginOptions) {
pretty = (_b = (_a = result.config) === null || _a === void 0 ? void 0 : _a.pretty) !== null && _b !== void 0 ? _b : pretty;
if (result.error !== undefined) {
printDiagnostics(context, convertDiagnostic("config", [result.error]), pretty);
throw new Error(`rpt2: failed to parse '${fileName}'`);
context.error(`failed to parse '${fileName}'`);
}
loadedConfig = result.config;
baseDir = require$$0$1.dirname(fileName);
@ -29511,7 +29502,9 @@ function parseTsConfig(context, pluginOptions) {
const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);
checkTsConfig(parsedTsConfig);
const module = parsedTsConfig.options.module;
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ES2020 && module !== tsModule.ModuleKind.ESNext)
context.error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
printDiagnostics(context, convertDiagnostic("config", parsedTsConfig.errors), pretty);
context.debug(`built-in options overrides: ${JSON.stringify(compilerOptionsOverride, undefined, 4)}`);
context.debug(`parsed tsconfig: ${JSON.stringify(parsedTsConfig, undefined, 4)}`);
@ -29546,19 +29539,15 @@ const typescript = (options) => {
let servicesHost;
let service;
let documentRegistry; // keep the same DocumentRegistry between watch cycles
let cache;
let noErrors = true;
let transformedFiles;
const declarations = {};
const checkedFiles = new Set();
let _cache;
const cache = () => {
if (!_cache)
_cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
return _cache;
};
const getDiagnostics = (id, snapshot) => {
return cache().getSyntacticDiagnostics(id, snapshot, () => {
return cache.getSyntacticDiagnostics(id, snapshot, () => {
return service.getSyntacticDiagnostics(id);
}).concat(cache().getSemanticDiagnostics(id, snapshot, () => {
}).concat(cache.getSemanticDiagnostics(id, snapshot, () => {
return service.getSemanticDiagnostics(id);
}));
};
@ -29583,7 +29572,7 @@ const typescript = (options) => {
const buildDone = () => {
if (!watchMode && !noErrors)
context.info(safe.exports.yellow("there were errors or warnings."));
cache().done();
cache.done();
};
const pluginOptions = Object.assign({}, {
check: true,
@ -29611,14 +29600,17 @@ const typescript = (options) => {
name: "rpt2",
options(config) {
rollupOptions = Object.assign({}, config);
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
return config;
},
buildStart() {
context = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
watchMode = process.env.ROLLUP_WATCH === "true" || !!this.meta.watchMode; // meta.watchMode was added in 2.14.0 to capture watch via Rollup API (i.e. no env var) (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2140)
({ parsedTsConfig: parsedConfig, fileName: tsConfigPath } = parseTsConfig(context, pluginOptions));
// print out all versions and configurations
context.info(`typescript version: ${tsModule.version}`);
context.info(`tslib version: ${tslibVersion}`);
context.info(`rollup version: ${this.meta.rollupVersion}`);
context.info(`rollup-plugin-typescript2 version: 0.33.0`);
context.info(`rollup-plugin-typescript2 version: 0.34.0`);
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
context.debug(() => `tsconfig path: ${tsConfigPath}`);
@ -29632,6 +29624,9 @@ const typescript = (options) => {
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
service = tsModule.createLanguageService(servicesHost, documentRegistry);
servicesHost.setLanguageService(service);
cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
// reset transformedFiles Set on each watch cycle
transformedFiles = new Set();
// printing compiler option errors
if (pluginOptions.check) {
const diagnostics = convertDiagnostic("options", service.getCompilerOptionsDiagnostics());
@ -29639,7 +29634,6 @@ const typescript = (options) => {
if (diagnostics.length > 0)
noErrors = false;
}
return config;
},
watchChange(id) {
const key = pluginutils.normalizePath(id);
@ -29659,7 +29653,7 @@ const typescript = (options) => {
if (!resolved)
return;
if (filter(resolved))
cache().setDependency(resolved, importer);
cache.setDependency(resolved, importer);
if (resolved.endsWith(".d.ts"))
return;
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
@ -29673,46 +29667,61 @@ const typescript = (options) => {
},
transform(code, id) {
var _a;
if (!filter(id))
return undefined;
const contextWrapper = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
const snapshot = servicesHost.setSnapshot(id, code);
// getting compiled file from cache or from ts
const result = cache().getCompiled(id, snapshot, () => {
const output = service.getEmitOutput(id);
if (output.emitSkipped) {
noErrors = false;
// always checking on fatal errors, even if options.check is set to false
typecheckFile(id, snapshot, contextWrapper);
// since no output was generated, aborting compilation
this.error(safe.exports.red(`Emit skipped for '${id}'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur`));
return __awaiter(this, void 0, void 0, function* () {
transformedFiles.add(id); // note: this does not need normalization as we only compare Rollup <-> Rollup, and not Rollup <-> TS
if (!filter(id))
return undefined;
const snapshot = servicesHost.setSnapshot(id, code);
// getting compiled file from cache or from ts
const result = cache.getCompiled(id, snapshot, () => {
const output = service.getEmitOutput(id);
if (output.emitSkipped) {
noErrors = false;
// always checking on fatal errors, even if options.check is set to false
typecheckFile(id, snapshot, context);
// since no output was generated, aborting compilation
this.error(safe.exports.red(`Emit skipped for '${id}'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur`));
}
const references = getAllReferences(id, snapshot, parsedConfig.options);
return convertEmitOutput(output, references);
});
if (pluginOptions.check)
typecheckFile(id, snapshot, context);
if (!result)
return undefined;
if (watchMode && result.references) {
if (tsConfigPath)
this.addWatchFile(tsConfigPath);
result.references.map(this.addWatchFile, this);
context.debug(() => `${safe.exports.green(" watching")}: ${result.references.join("\nrpt2: ")}`);
}
const references = getAllReferences(id, snapshot, parsedConfig.options);
return convertEmitOutput(output, references);
addDeclaration(id, result);
// handle all type-only imports by resolving + loading all of TS's references
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
if (result.references) {
for (const ref of result.references) {
if (ref.endsWith(".d.ts"))
continue;
const module = yield this.resolve(ref, id);
if (!module || transformedFiles.has(module.id)) // check for circular references (per https://rollupjs.org/guide/en/#thisload)
continue;
// wait for all to be loaded (otherwise, as this is async, some may end up only loading after `generateBundle`)
yield this.load({ id: module.id });
}
}
// if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
// note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
if (parsedConfig.options.emitDeclarationOnly) {
context.debug(() => `${safe.exports.blue("emitDeclarationOnly")} enabled, not transforming TS`);
return undefined;
}
const transformResult = { code: result.code, map: { mappings: "" } };
if (result.map) {
(_a = pluginOptions.sourceMapCallback) === null || _a === void 0 ? void 0 : _a.call(pluginOptions, id, result.map);
transformResult.map = JSON.parse(result.map);
}
return transformResult;
});
if (pluginOptions.check)
typecheckFile(id, snapshot, contextWrapper);
if (!result)
return undefined;
if (watchMode && result.references) {
if (tsConfigPath)
this.addWatchFile(tsConfigPath);
result.references.map(this.addWatchFile, this);
context.debug(() => `${safe.exports.green(" watching")}: ${result.references.join("\nrpt2: ")}`);
}
addDeclaration(id, result);
// if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
// note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
if (parsedConfig.options.emitDeclarationOnly) {
context.debug(() => `${safe.exports.blue("emitDeclarationOnly")} enabled, not transforming TS'`);
return undefined;
}
const transformResult = { code: result.code, map: { mappings: "" } };
if (result.map) {
(_a = pluginOptions.sourceMapCallback) === null || _a === void 0 ? void 0 : _a.call(pluginOptions, id, result.map);
transformResult.map = JSON.parse(result.map);
}
return transformResult;
},
buildEnd(err) {
var _a;
@ -29730,14 +29739,13 @@ const typescript = (options) => {
return buildDone();
// walkTree once on each cycle when in watch mode
if (watchMode) {
cache().walkTree((id) => {
cache.walkTree((id) => {
if (!filter(id))
return;
const snapshot = servicesHost.getScriptSnapshot(id);
typecheckFile(id, snapshot, context);
});
}
const contextWrapper = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
// type-check missed files as well
parsedConfig.fileNames.forEach((name) => {
const key = pluginutils.normalizePath(name);
@ -29745,7 +29753,7 @@ const typescript = (options) => {
return;
context.debug(() => `type-checking missed '${key}'`);
const snapshot = servicesHost.getScriptSnapshot(key);
typecheckFile(key, snapshot, contextWrapper);
typecheckFile(key, snapshot, context);
});
buildDone();
},

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,31 @@ import * as fs$4 from 'fs-extra';
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync } from 'fs-extra';
import require$$0$3 from 'crypto';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var safe = {exports: {}};
@ -2978,34 +3003,6 @@ var VerbosityLevel;
function getText(message) {
return typeof message === "string" ? message : message();
}
/* tslint:disable:max-classes-per-file -- generally a good rule to follow, but these two classes could basically be one */
/** mainly to be used in options hook, but can be used in other hooks too */
class ConsoleContext {
constructor(verbosity, prefix = "") {
this.verbosity = verbosity;
this.prefix = prefix;
}
warn(message) {
if (this.verbosity < VerbosityLevel.Warning)
return;
console.log(`${this.prefix}${getText(message)}`);
}
error(message) {
if (this.verbosity < VerbosityLevel.Error)
return;
console.log(`${this.prefix}${getText(message)}`);
}
info(message) {
if (this.verbosity < VerbosityLevel.Info)
return;
console.log(`${this.prefix}${getText(message)}`);
}
debug(message) {
if (this.verbosity < VerbosityLevel.Debug)
return;
console.log(`${this.prefix}${getText(message)}`);
}
}
/** cannot be used in options hook (which does not have this.warn and this.error), but can be in other hooks */
class RollupContext {
constructor(verbosity, bail, context, prefix = "") {
@ -29164,6 +29161,54 @@ class FormatHost {
}
const formatHost = new FormatHost();
function convertDiagnostic(type, data) {
return data.map((diagnostic) => {
const entry = {
flatMessage: tsModule.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()),
formatted: tsModule.formatDiagnosticsWithColorAndContext(data, formatHost),
category: diagnostic.category,
code: diagnostic.code,
type,
};
if (diagnostic.file && diagnostic.start !== undefined) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
entry.fileLine = `${diagnostic.file.fileName}(${line + 1},${character + 1})`;
}
return entry;
});
}
function printDiagnostics(context, diagnostics, pretty = true) {
diagnostics.forEach((diagnostic) => {
let print;
let color;
let category;
switch (diagnostic.category) {
case tsModule.DiagnosticCategory.Message:
print = context.info;
color = safe.exports.white;
category = "";
break;
case tsModule.DiagnosticCategory.Error:
print = context.error;
color = safe.exports.red;
category = "error";
break;
case tsModule.DiagnosticCategory.Warning:
default:
print = context.warn;
color = safe.exports.yellow;
category = "warning";
break;
}
const type = diagnostic.type + " ";
if (pretty)
return print.call(context, `${diagnostic.formatted}`);
if (diagnostic.fileLine !== undefined)
return print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
return print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
});
}
function convertEmitOutput(output, references) {
const out = { code: "", references };
output.outputFiles.forEach((e) => {
@ -29188,22 +29233,6 @@ function getAllReferences(importer, snapshot, options) {
return (_a = resolved.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
}));
}
function convertDiagnostic(type, data) {
return data.map((diagnostic) => {
const entry = {
flatMessage: tsModule.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
formatted: tsModule.formatDiagnosticsWithColorAndContext(data, formatHost),
category: diagnostic.category,
code: diagnostic.code,
type,
};
if (diagnostic.file && diagnostic.start !== undefined) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
entry.fileLine = `${diagnostic.file.fileName}(${line + 1},${character + 1})`;
}
return entry;
});
}
class TsCache {
constructor(noCache, hashIgnoreUnknown, host, cacheRoot, options, rollupConfig, rootFilenames, context) {
this.noCache = noCache;
@ -29367,38 +29396,6 @@ class TsCache {
}
}
function printDiagnostics(context, diagnostics, pretty = true) {
diagnostics.forEach((diagnostic) => {
let print;
let color;
let category;
switch (diagnostic.category) {
case tsModule.DiagnosticCategory.Message:
print = context.info;
color = safe.exports.white;
category = "";
break;
case tsModule.DiagnosticCategory.Error:
print = context.error;
color = safe.exports.red;
category = "error";
break;
case tsModule.DiagnosticCategory.Warning:
default:
print = context.warn;
color = safe.exports.yellow;
category = "warning";
break;
}
const type = diagnostic.type + " ";
if (pretty)
return print.call(context, `${diagnostic.formatted}`);
if (diagnostic.fileLine !== undefined)
return print.call(context, `${diagnostic.fileLine}: ${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
return print.call(context, `${type}${category} TS${diagnostic.code}: ${color(diagnostic.flatMessage)}`);
});
}
function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsedTsconfig) {
const overrides = {
noEmitHelpers: false,
@ -29450,18 +29447,12 @@ function createFilter(context, pluginOptions, parsedConfig) {
return createFilter$1(included, excluded, { resolve: parsedConfig.options.rootDir });
}
function checkTsConfig(parsedConfig) {
const module = parsedConfig.options.module;
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ES2020 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`rpt2: Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
}
function parseTsConfig(context, pluginOptions) {
var _a, _b;
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(`rpt2: failed to open '${pluginOptions.tsconfig}'`);
context.error(`failed to open '${pluginOptions.tsconfig}'`);
let loadedConfig = {};
let baseDir = pluginOptions.cwd;
let configFileName;
@ -29472,7 +29463,7 @@ function parseTsConfig(context, pluginOptions) {
pretty = (_b = (_a = result.config) === null || _a === void 0 ? void 0 : _a.pretty) !== null && _b !== void 0 ? _b : pretty;
if (result.error !== undefined) {
printDiagnostics(context, convertDiagnostic("config", [result.error]), pretty);
throw new Error(`rpt2: failed to parse '${fileName}'`);
context.error(`failed to parse '${fileName}'`);
}
loadedConfig = result.config;
baseDir = dirname(fileName);
@ -29483,7 +29474,9 @@ function parseTsConfig(context, pluginOptions) {
const preParsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, getOptionsOverrides(pluginOptions), configFileName);
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);
checkTsConfig(parsedTsConfig);
const module = parsedTsConfig.options.module;
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ES2020 && module !== tsModule.ModuleKind.ESNext)
context.error(`Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);
printDiagnostics(context, convertDiagnostic("config", parsedTsConfig.errors), pretty);
context.debug(`built-in options overrides: ${JSON.stringify(compilerOptionsOverride, undefined, 4)}`);
context.debug(`parsed tsconfig: ${JSON.stringify(parsedTsConfig, undefined, 4)}`);
@ -29518,19 +29511,15 @@ const typescript = (options) => {
let servicesHost;
let service;
let documentRegistry; // keep the same DocumentRegistry between watch cycles
let cache;
let noErrors = true;
let transformedFiles;
const declarations = {};
const checkedFiles = new Set();
let _cache;
const cache = () => {
if (!_cache)
_cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
return _cache;
};
const getDiagnostics = (id, snapshot) => {
return cache().getSyntacticDiagnostics(id, snapshot, () => {
return cache.getSyntacticDiagnostics(id, snapshot, () => {
return service.getSyntacticDiagnostics(id);
}).concat(cache().getSemanticDiagnostics(id, snapshot, () => {
}).concat(cache.getSemanticDiagnostics(id, snapshot, () => {
return service.getSemanticDiagnostics(id);
}));
};
@ -29555,7 +29544,7 @@ const typescript = (options) => {
const buildDone = () => {
if (!watchMode && !noErrors)
context.info(safe.exports.yellow("there were errors or warnings."));
cache().done();
cache.done();
};
const pluginOptions = Object.assign({}, {
check: true,
@ -29583,14 +29572,17 @@ const typescript = (options) => {
name: "rpt2",
options(config) {
rollupOptions = Object.assign({}, config);
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
return config;
},
buildStart() {
context = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
watchMode = process.env.ROLLUP_WATCH === "true" || !!this.meta.watchMode; // meta.watchMode was added in 2.14.0 to capture watch via Rollup API (i.e. no env var) (c.f. https://github.com/rollup/rollup/blob/master/CHANGELOG.md#2140)
({ parsedTsConfig: parsedConfig, fileName: tsConfigPath } = parseTsConfig(context, pluginOptions));
// print out all versions and configurations
context.info(`typescript version: ${tsModule.version}`);
context.info(`tslib version: ${tslibVersion}`);
context.info(`rollup version: ${this.meta.rollupVersion}`);
context.info(`rollup-plugin-typescript2 version: 0.33.0`);
context.info(`rollup-plugin-typescript2 version: 0.34.0`);
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
context.debug(() => `tsconfig path: ${tsConfigPath}`);
@ -29604,6 +29596,9 @@ const typescript = (options) => {
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
service = tsModule.createLanguageService(servicesHost, documentRegistry);
servicesHost.setLanguageService(service);
cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
// reset transformedFiles Set on each watch cycle
transformedFiles = new Set();
// printing compiler option errors
if (pluginOptions.check) {
const diagnostics = convertDiagnostic("options", service.getCompilerOptionsDiagnostics());
@ -29611,7 +29606,6 @@ const typescript = (options) => {
if (diagnostics.length > 0)
noErrors = false;
}
return config;
},
watchChange(id) {
const key = normalizePath(id);
@ -29631,7 +29625,7 @@ const typescript = (options) => {
if (!resolved)
return;
if (filter(resolved))
cache().setDependency(resolved, importer);
cache.setDependency(resolved, importer);
if (resolved.endsWith(".d.ts"))
return;
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
@ -29645,46 +29639,61 @@ const typescript = (options) => {
},
transform(code, id) {
var _a;
if (!filter(id))
return undefined;
const contextWrapper = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
const snapshot = servicesHost.setSnapshot(id, code);
// getting compiled file from cache or from ts
const result = cache().getCompiled(id, snapshot, () => {
const output = service.getEmitOutput(id);
if (output.emitSkipped) {
noErrors = false;
// always checking on fatal errors, even if options.check is set to false
typecheckFile(id, snapshot, contextWrapper);
// since no output was generated, aborting compilation
this.error(safe.exports.red(`Emit skipped for '${id}'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur`));
return __awaiter(this, void 0, void 0, function* () {
transformedFiles.add(id); // note: this does not need normalization as we only compare Rollup <-> Rollup, and not Rollup <-> TS
if (!filter(id))
return undefined;
const snapshot = servicesHost.setSnapshot(id, code);
// getting compiled file from cache or from ts
const result = cache.getCompiled(id, snapshot, () => {
const output = service.getEmitOutput(id);
if (output.emitSkipped) {
noErrors = false;
// always checking on fatal errors, even if options.check is set to false
typecheckFile(id, snapshot, context);
// since no output was generated, aborting compilation
this.error(safe.exports.red(`Emit skipped for '${id}'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur`));
}
const references = getAllReferences(id, snapshot, parsedConfig.options);
return convertEmitOutput(output, references);
});
if (pluginOptions.check)
typecheckFile(id, snapshot, context);
if (!result)
return undefined;
if (watchMode && result.references) {
if (tsConfigPath)
this.addWatchFile(tsConfigPath);
result.references.map(this.addWatchFile, this);
context.debug(() => `${safe.exports.green(" watching")}: ${result.references.join("\nrpt2: ")}`);
}
const references = getAllReferences(id, snapshot, parsedConfig.options);
return convertEmitOutput(output, references);
addDeclaration(id, result);
// handle all type-only imports by resolving + loading all of TS's references
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
if (result.references) {
for (const ref of result.references) {
if (ref.endsWith(".d.ts"))
continue;
const module = yield this.resolve(ref, id);
if (!module || transformedFiles.has(module.id)) // check for circular references (per https://rollupjs.org/guide/en/#thisload)
continue;
// wait for all to be loaded (otherwise, as this is async, some may end up only loading after `generateBundle`)
yield this.load({ id: module.id });
}
}
// if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
// note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
if (parsedConfig.options.emitDeclarationOnly) {
context.debug(() => `${safe.exports.blue("emitDeclarationOnly")} enabled, not transforming TS`);
return undefined;
}
const transformResult = { code: result.code, map: { mappings: "" } };
if (result.map) {
(_a = pluginOptions.sourceMapCallback) === null || _a === void 0 ? void 0 : _a.call(pluginOptions, id, result.map);
transformResult.map = JSON.parse(result.map);
}
return transformResult;
});
if (pluginOptions.check)
typecheckFile(id, snapshot, contextWrapper);
if (!result)
return undefined;
if (watchMode && result.references) {
if (tsConfigPath)
this.addWatchFile(tsConfigPath);
result.references.map(this.addWatchFile, this);
context.debug(() => `${safe.exports.green(" watching")}: ${result.references.join("\nrpt2: ")}`);
}
addDeclaration(id, result);
// if a user sets this compilerOption, they probably want another plugin (e.g. Babel, ESBuild) to transform their TS instead, while rpt2 just type-checks and/or outputs declarations
// note that result.code is non-existent if emitDeclarationOnly per https://github.com/ezolenko/rollup-plugin-typescript2/issues/268
if (parsedConfig.options.emitDeclarationOnly) {
context.debug(() => `${safe.exports.blue("emitDeclarationOnly")} enabled, not transforming TS'`);
return undefined;
}
const transformResult = { code: result.code, map: { mappings: "" } };
if (result.map) {
(_a = pluginOptions.sourceMapCallback) === null || _a === void 0 ? void 0 : _a.call(pluginOptions, id, result.map);
transformResult.map = JSON.parse(result.map);
}
return transformResult;
},
buildEnd(err) {
var _a;
@ -29702,14 +29711,13 @@ const typescript = (options) => {
return buildDone();
// walkTree once on each cycle when in watch mode
if (watchMode) {
cache().walkTree((id) => {
cache.walkTree((id) => {
if (!filter(id))
return;
const snapshot = servicesHost.getScriptSnapshot(id);
typecheckFile(id, snapshot, context);
});
}
const contextWrapper = new RollupContext(pluginOptions.verbosity, pluginOptions.abortOnError, this, "rpt2: ");
// type-check missed files as well
parsedConfig.fileNames.forEach((name) => {
const key = normalizePath(name);
@ -29717,7 +29725,7 @@ const typescript = (options) => {
return;
context.debug(() => `type-checking missed '${key}'`);
const snapshot = servicesHost.getScriptSnapshot(key);
typecheckFile(key, snapshot, contextWrapper);
typecheckFile(key, snapshot, context);
});
buildDone();
},

File diff suppressed because one or more lines are too long

14
dist/tscache.d.ts vendored
View File

@ -1,5 +1,6 @@
import * as tsTypes from "typescript";
import { IContext } from "./context";
import { RollupContext } from "./context";
import { IDiagnostics } from "./diagnostics";
export interface ICode {
code: string;
map?: string;
@ -7,17 +8,8 @@ export interface ICode {
dtsmap?: tsTypes.OutputFile;
references?: string[];
}
export interface IDiagnostics {
flatMessage: string;
formatted: string;
fileLine?: string;
category: tsTypes.DiagnosticCategory;
code: number;
type: string;
}
export declare function convertEmitOutput(output: tsTypes.EmitOutput, references?: string[]): ICode;
export declare function getAllReferences(importer: string, snapshot: tsTypes.IScriptSnapshot | undefined, options: tsTypes.CompilerOptions): string[];
export declare function convertDiagnostic(type: string, data: tsTypes.Diagnostic[]): IDiagnostics[];
export declare class TsCache {
private noCache;
private host;
@ -36,7 +28,7 @@ export declare class TsCache {
private semanticDiagnosticsCache;
private syntacticDiagnosticsCache;
private hashOptions;
constructor(noCache: boolean, hashIgnoreUnknown: boolean, host: tsTypes.LanguageServiceHost, cacheRoot: string, options: tsTypes.CompilerOptions, rollupConfig: any, rootFilenames: string[], context: IContext);
constructor(noCache: boolean, hashIgnoreUnknown: boolean, host: tsTypes.LanguageServiceHost, cacheRoot: string, options: tsTypes.CompilerOptions, rollupConfig: any, rootFilenames: string[], context: RollupContext);
private clean;
setDependency(importee: string, importer: string): void;
walkTree(cb: (id: string) => void | false): void;

View File

@ -1 +1 @@
{"version":3,"file":"tscache.d.ts","sourceRoot":"","sources":["../src/tscache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAOtC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAMrC,MAAM,WAAW,KAAK;IAErB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAOD,MAAM,WAAW,YAAY;IAE5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAQD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAiB1F;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,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MAAM,OAAO,CAAC,UAAU,EAAE,GAAG,YAAY,EAAE;IAKzH,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,GAAG,YAAY,EAAE;IAK/H,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,SAAS;IA8BjB,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,WAAW;IAKnB,8EAA8E;IAC9E,OAAO,CAAC,OAAO;IA+Bf,8EAA8E;IAC9E,OAAO,CAAC,UAAU;CAKlB"}

20
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.32.2",
"version": "0.34.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "rollup-plugin-typescript2",
"version": "0.32.2",
"version": "0.34.0",
"license": "MIT",
"dependencies": {
"@rollup/pluginutils": "^4.1.2",
@ -35,7 +35,7 @@
"rimraf": "3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-re": "1.0.7",
"rollup-plugin-typescript2": "0.32.1",
"rollup-plugin-typescript2": "0.33.0",
"ts-jest": "^28.0.0",
"tslint": "6.1.3",
"typescript": "^4.6.3"
@ -5178,15 +5178,14 @@
}
},
"node_modules/rollup-plugin-typescript2": {
"version": "0.32.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.32.1.tgz",
"integrity": "sha512-RanO8bp1WbeMv0bVlgcbsFNCn+Y3rX7wF97SQLDxf0fMLsg0B/QFF005t4AsGUcDgF3aKJHoqt4JF2xVaABeKw==",
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.33.0.tgz",
"integrity": "sha512-7ZXoZeX93kNb4/ICzOi2AlperVV6cAsNz8THqrbz+KNvpn47P2F/nFdK/BGhkoOsOwuYDuY57vccdZZrcd8/dA==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^4.1.2",
"find-cache-dir": "^3.3.2",
"fs-extra": "^10.0.0",
"resolve": "^1.20.0",
"tslib": "^2.4.0"
},
"peerDependencies": {
@ -9633,15 +9632,14 @@
}
},
"rollup-plugin-typescript2": {
"version": "0.32.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.32.1.tgz",
"integrity": "sha512-RanO8bp1WbeMv0bVlgcbsFNCn+Y3rX7wF97SQLDxf0fMLsg0B/QFF005t4AsGUcDgF3aKJHoqt4JF2xVaABeKw==",
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.33.0.tgz",
"integrity": "sha512-7ZXoZeX93kNb4/ICzOi2AlperVV6cAsNz8THqrbz+KNvpn47P2F/nFdK/BGhkoOsOwuYDuY57vccdZZrcd8/dA==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^4.1.2",
"find-cache-dir": "^3.3.2",
"fs-extra": "^10.0.0",
"resolve": "^1.20.0",
"tslib": "^2.4.0"
}
},

View File

@ -1,6 +1,6 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.33.0",
"version": "0.34.0",
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
"main": "dist/rollup-plugin-typescript2.cjs.js",
"module": "dist/rollup-plugin-typescript2.es.js",
@ -62,7 +62,7 @@
"rimraf": "3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-re": "1.0.7",
"rollup-plugin-typescript2": "0.32.1",
"rollup-plugin-typescript2": "0.33.0",
"ts-jest": "^28.0.0",
"tslint": "6.1.3",
"typescript": "^4.6.3"