mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- treating excludes the same way
- formatting
This commit is contained in:
parent
60aa8a3132
commit
05ba8fa2c8
79
dist/rollup-plugin-typescript2.cjs.js
vendored
79
dist/rollup-plugin-typescript2.cjs.js
vendored
@ -18467,9 +18467,9 @@ var objectHash_1 = createCommonjsModule(function (module, exports) {
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
|
||||
* - `excludeValues` {true|*false} hash object keys, values ignored
|
||||
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
|
||||
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
|
||||
* - `excludeValues` {true|*false} hash object keys, values ignored
|
||||
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
|
||||
* - `ignoreUnknown` {true|*false} ignore unknown object types
|
||||
* - `replacer` optional function that replaces values before hashing
|
||||
* - `respectFunctionProperties` {*true|false} consider function properties when hashing
|
||||
@ -18532,7 +18532,6 @@ function applyDefaults(object, options){
|
||||
options.unorderedArrays = options.unorderedArrays !== true ? false : true; // default to false
|
||||
options.unorderedSets = options.unorderedSets === false ? false : true; // default to false
|
||||
options.replacer = options.replacer || undefined;
|
||||
options.excludeKeys = options.excludeKeys || undefined;
|
||||
|
||||
if(typeof object === 'undefined') {
|
||||
throw new Error('Object argument required.');
|
||||
@ -18545,7 +18544,7 @@ function applyDefaults(object, options){
|
||||
options.algorithm = hashes[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(hashes.indexOf(options.algorithm) === -1){
|
||||
throw new Error('Algorithm "' + options.algorithm + '" not supported. ' +
|
||||
'supported values: ' + hashes.join(', '));
|
||||
@ -18556,7 +18555,7 @@ function applyDefaults(object, options){
|
||||
throw new Error('Encoding "' + options.encoding + '" not supported. ' +
|
||||
'supported values: ' + encodings.join(', '));
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -18571,23 +18570,23 @@ function isNativeFunction(f) {
|
||||
|
||||
function hash(object, options) {
|
||||
var hashingStream;
|
||||
|
||||
|
||||
if (options.algorithm !== 'passthrough') {
|
||||
hashingStream = crypto.createHash(options.algorithm);
|
||||
} else {
|
||||
hashingStream = new PassThrough();
|
||||
}
|
||||
|
||||
|
||||
if (typeof hashingStream.write === 'undefined') {
|
||||
hashingStream.write = hashingStream.update;
|
||||
hashingStream.end = hashingStream.update;
|
||||
}
|
||||
|
||||
|
||||
var hasher = typeHasher(options, hashingStream);
|
||||
hasher.dispatch(object);
|
||||
if (!hashingStream.update)
|
||||
hashingStream.end('');
|
||||
|
||||
|
||||
if (hashingStream.digest) {
|
||||
return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
|
||||
}
|
||||
@ -18596,7 +18595,7 @@ function hash(object, options) {
|
||||
if (options.encoding === 'buffer') {
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return buf.toString(options.encoding);
|
||||
}
|
||||
|
||||
@ -18613,9 +18612,9 @@ exports.writeToStream = function(object, options, stream) {
|
||||
stream = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
||||
options = applyDefaults(object, options);
|
||||
|
||||
|
||||
return typeHasher(options, stream).dispatch(object);
|
||||
};
|
||||
|
||||
@ -18633,14 +18632,14 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.replacer) {
|
||||
value = options.replacer(value);
|
||||
}
|
||||
|
||||
|
||||
var type = typeof value;
|
||||
if (value === null) {
|
||||
type = 'null';
|
||||
}
|
||||
|
||||
//console.log("[DEBUG] Dispatch: ", value, "->", type, " -> ", "_" + type);
|
||||
|
||||
|
||||
return this['_' + type](value);
|
||||
},
|
||||
_object: function(object) {
|
||||
@ -18652,9 +18651,9 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
objType = objType[1]; // take only the class name
|
||||
}
|
||||
|
||||
|
||||
objType = objType.toLowerCase();
|
||||
|
||||
|
||||
var objectNumber = null;
|
||||
|
||||
if ((objectNumber = context.indexOf(object)) >= 0) {
|
||||
@ -18662,7 +18661,7 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
context.push(object);
|
||||
}
|
||||
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
||||
write('buffer:');
|
||||
return write(object);
|
||||
@ -18688,11 +18687,7 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.respectType !== false && !isNativeFunction(object)) {
|
||||
keys.splice(0, 0, 'prototype', '__proto__', 'constructor');
|
||||
}
|
||||
|
||||
if (options.excludeKeys) {
|
||||
keys = keys.filter(function(key) { return !options.excludeKeys(key); });
|
||||
}
|
||||
|
||||
|
||||
write('object:' + keys.length + ':');
|
||||
var self = this;
|
||||
return keys.forEach(function(key){
|
||||
@ -18708,7 +18703,7 @@ function typeHasher(options, writeTo, context){
|
||||
_array: function(arr, unordered){
|
||||
unordered = typeof unordered !== 'undefined' ? unordered :
|
||||
options.unorderedArrays !== false; // default to options.unorderedArrays
|
||||
|
||||
|
||||
var self = this;
|
||||
write('array:' + arr.length + ':');
|
||||
if (!unordered || arr.length <= 1) {
|
||||
@ -18716,7 +18711,7 @@ function typeHasher(options, writeTo, context){
|
||||
return self.dispatch(entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// the unordered case is a little more complicated:
|
||||
// since there is no canonical ordering on objects,
|
||||
// i.e. {a:1} < {a:2} and {a:1} > {a:2} are both false,
|
||||
@ -18770,7 +18765,7 @@ function typeHasher(options, writeTo, context){
|
||||
// have the same hash
|
||||
this.dispatch("function-name:" + String(fn.name));
|
||||
}
|
||||
|
||||
|
||||
if (options.respectFunctionProperties) {
|
||||
this._object(fn);
|
||||
}
|
||||
@ -18847,7 +18842,7 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.ignoreUnknown) {
|
||||
return write('[blob]');
|
||||
}
|
||||
|
||||
|
||||
throw Error('Hashing Blob objects is currently not supported\n' +
|
||||
'(see https://github.com/puleos/object-hash/issues/26)\n' +
|
||||
'Use "options.replacer" or "options.ignoreUnknown"\n');
|
||||
@ -19786,21 +19781,29 @@ function typescript(options) {
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info("typescript version: " + tsModule.version);
|
||||
context.debug("plugin options: " + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4));
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
context.debug("rollup config: " + JSON.stringify(rollupOptions, undefined, 4));
|
||||
parsedConfig = parseTsConfig(pluginOptions.tsconfig, context, pluginOptions);
|
||||
if (parsedConfig.options.rootDirs) {
|
||||
var includedOptions = lodash_15(parsedConfig.options.rootDirs, function (res) {
|
||||
if (pluginOptions.include instanceof Array) {
|
||||
return pluginOptions.include.map(function (inc) {
|
||||
return res + "/" + inc;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return res + "/" + pluginOptions.include;
|
||||
}
|
||||
var included = lodash_15(parsedConfig.options.rootDirs, function (root) {
|
||||
if (pluginOptions.include instanceof Array)
|
||||
return pluginOptions.include.map(function (include) { return path.join(root, include); });
|
||||
else
|
||||
return path.join(root, pluginOptions.include);
|
||||
});
|
||||
filter = createFilter(includedOptions, pluginOptions.exclude);
|
||||
var excluded = lodash_15(parsedConfig.options.rootDirs, function (root) {
|
||||
if (pluginOptions.exclude instanceof Array)
|
||||
return pluginOptions.exclude.map(function (exclude) { return path.join(root, exclude); });
|
||||
else
|
||||
return path.join(root, pluginOptions.exclude);
|
||||
});
|
||||
filter = createFilter(included, excluded);
|
||||
console.debug("included: '" + included + "'");
|
||||
console.debug("excluded: '" + excluded + "'");
|
||||
}
|
||||
else {
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
console.debug("included: '" + pluginOptions.include + "'");
|
||||
console.debug("excluded: '" + pluginOptions.exclude + "'");
|
||||
}
|
||||
servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
|
||||
|
||||
79
dist/rollup-plugin-typescript2.es.js
vendored
79
dist/rollup-plugin-typescript2.es.js
vendored
@ -18463,9 +18463,9 @@ var objectHash_1 = createCommonjsModule(function (module, exports) {
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
|
||||
* - `excludeValues` {true|*false} hash object keys, values ignored
|
||||
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
|
||||
* - `algorithm` hash algo to be used by this instance: *'sha1', 'md5'
|
||||
* - `excludeValues` {true|*false} hash object keys, values ignored
|
||||
* - `encoding` hash encoding, supports 'buffer', '*hex', 'binary', 'base64'
|
||||
* - `ignoreUnknown` {true|*false} ignore unknown object types
|
||||
* - `replacer` optional function that replaces values before hashing
|
||||
* - `respectFunctionProperties` {*true|false} consider function properties when hashing
|
||||
@ -18528,7 +18528,6 @@ function applyDefaults(object, options){
|
||||
options.unorderedArrays = options.unorderedArrays !== true ? false : true; // default to false
|
||||
options.unorderedSets = options.unorderedSets === false ? false : true; // default to false
|
||||
options.replacer = options.replacer || undefined;
|
||||
options.excludeKeys = options.excludeKeys || undefined;
|
||||
|
||||
if(typeof object === 'undefined') {
|
||||
throw new Error('Object argument required.');
|
||||
@ -18541,7 +18540,7 @@ function applyDefaults(object, options){
|
||||
options.algorithm = hashes[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(hashes.indexOf(options.algorithm) === -1){
|
||||
throw new Error('Algorithm "' + options.algorithm + '" not supported. ' +
|
||||
'supported values: ' + hashes.join(', '));
|
||||
@ -18552,7 +18551,7 @@ function applyDefaults(object, options){
|
||||
throw new Error('Encoding "' + options.encoding + '" not supported. ' +
|
||||
'supported values: ' + encodings.join(', '));
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -18567,23 +18566,23 @@ function isNativeFunction(f) {
|
||||
|
||||
function hash(object, options) {
|
||||
var hashingStream;
|
||||
|
||||
|
||||
if (options.algorithm !== 'passthrough') {
|
||||
hashingStream = crypto.createHash(options.algorithm);
|
||||
} else {
|
||||
hashingStream = new PassThrough();
|
||||
}
|
||||
|
||||
|
||||
if (typeof hashingStream.write === 'undefined') {
|
||||
hashingStream.write = hashingStream.update;
|
||||
hashingStream.end = hashingStream.update;
|
||||
}
|
||||
|
||||
|
||||
var hasher = typeHasher(options, hashingStream);
|
||||
hasher.dispatch(object);
|
||||
if (!hashingStream.update)
|
||||
hashingStream.end('');
|
||||
|
||||
|
||||
if (hashingStream.digest) {
|
||||
return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
|
||||
}
|
||||
@ -18592,7 +18591,7 @@ function hash(object, options) {
|
||||
if (options.encoding === 'buffer') {
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return buf.toString(options.encoding);
|
||||
}
|
||||
|
||||
@ -18609,9 +18608,9 @@ exports.writeToStream = function(object, options, stream) {
|
||||
stream = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
||||
options = applyDefaults(object, options);
|
||||
|
||||
|
||||
return typeHasher(options, stream).dispatch(object);
|
||||
};
|
||||
|
||||
@ -18629,14 +18628,14 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.replacer) {
|
||||
value = options.replacer(value);
|
||||
}
|
||||
|
||||
|
||||
var type = typeof value;
|
||||
if (value === null) {
|
||||
type = 'null';
|
||||
}
|
||||
|
||||
//console.log("[DEBUG] Dispatch: ", value, "->", type, " -> ", "_" + type);
|
||||
|
||||
|
||||
return this['_' + type](value);
|
||||
},
|
||||
_object: function(object) {
|
||||
@ -18648,9 +18647,9 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
objType = objType[1]; // take only the class name
|
||||
}
|
||||
|
||||
|
||||
objType = objType.toLowerCase();
|
||||
|
||||
|
||||
var objectNumber = null;
|
||||
|
||||
if ((objectNumber = context.indexOf(object)) >= 0) {
|
||||
@ -18658,7 +18657,7 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
context.push(object);
|
||||
}
|
||||
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
||||
write('buffer:');
|
||||
return write(object);
|
||||
@ -18684,11 +18683,7 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.respectType !== false && !isNativeFunction(object)) {
|
||||
keys.splice(0, 0, 'prototype', '__proto__', 'constructor');
|
||||
}
|
||||
|
||||
if (options.excludeKeys) {
|
||||
keys = keys.filter(function(key) { return !options.excludeKeys(key); });
|
||||
}
|
||||
|
||||
|
||||
write('object:' + keys.length + ':');
|
||||
var self = this;
|
||||
return keys.forEach(function(key){
|
||||
@ -18704,7 +18699,7 @@ function typeHasher(options, writeTo, context){
|
||||
_array: function(arr, unordered){
|
||||
unordered = typeof unordered !== 'undefined' ? unordered :
|
||||
options.unorderedArrays !== false; // default to options.unorderedArrays
|
||||
|
||||
|
||||
var self = this;
|
||||
write('array:' + arr.length + ':');
|
||||
if (!unordered || arr.length <= 1) {
|
||||
@ -18712,7 +18707,7 @@ function typeHasher(options, writeTo, context){
|
||||
return self.dispatch(entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// the unordered case is a little more complicated:
|
||||
// since there is no canonical ordering on objects,
|
||||
// i.e. {a:1} < {a:2} and {a:1} > {a:2} are both false,
|
||||
@ -18766,7 +18761,7 @@ function typeHasher(options, writeTo, context){
|
||||
// have the same hash
|
||||
this.dispatch("function-name:" + String(fn.name));
|
||||
}
|
||||
|
||||
|
||||
if (options.respectFunctionProperties) {
|
||||
this._object(fn);
|
||||
}
|
||||
@ -18843,7 +18838,7 @@ function typeHasher(options, writeTo, context){
|
||||
if (options.ignoreUnknown) {
|
||||
return write('[blob]');
|
||||
}
|
||||
|
||||
|
||||
throw Error('Hashing Blob objects is currently not supported\n' +
|
||||
'(see https://github.com/puleos/object-hash/issues/26)\n' +
|
||||
'Use "options.replacer" or "options.ignoreUnknown"\n');
|
||||
@ -19782,21 +19777,29 @@ function typescript(options) {
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info("typescript version: " + tsModule.version);
|
||||
context.debug("plugin options: " + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4));
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
context.debug("rollup config: " + JSON.stringify(rollupOptions, undefined, 4));
|
||||
parsedConfig = parseTsConfig(pluginOptions.tsconfig, context, pluginOptions);
|
||||
if (parsedConfig.options.rootDirs) {
|
||||
var includedOptions = lodash_15(parsedConfig.options.rootDirs, function (res) {
|
||||
if (pluginOptions.include instanceof Array) {
|
||||
return pluginOptions.include.map(function (inc) {
|
||||
return res + "/" + inc;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return res + "/" + pluginOptions.include;
|
||||
}
|
||||
var included = lodash_15(parsedConfig.options.rootDirs, function (root) {
|
||||
if (pluginOptions.include instanceof Array)
|
||||
return pluginOptions.include.map(function (include) { return join(root, include); });
|
||||
else
|
||||
return join(root, pluginOptions.include);
|
||||
});
|
||||
filter = createFilter(includedOptions, pluginOptions.exclude);
|
||||
var excluded = lodash_15(parsedConfig.options.rootDirs, function (root) {
|
||||
if (pluginOptions.exclude instanceof Array)
|
||||
return pluginOptions.exclude.map(function (exclude) { return join(root, exclude); });
|
||||
else
|
||||
return join(root, pluginOptions.exclude);
|
||||
});
|
||||
filter = createFilter(included, excluded);
|
||||
console.debug("included: '" + included + "'");
|
||||
console.debug("excluded: '" + excluded + "'");
|
||||
}
|
||||
else {
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
console.debug("included: '" + pluginOptions.include + "'");
|
||||
console.debug("excluded: '" + pluginOptions.exclude + "'");
|
||||
}
|
||||
servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry());
|
||||
|
||||
40
src/index.ts
40
src/index.ts
@ -13,7 +13,7 @@ import { parseTsConfig } from "./parse-ts-config";
|
||||
import { printDiagnostics } from "./print-diagnostics";
|
||||
import { TSLIB, tslibSource } from "./tslib";
|
||||
import { blue, red, yellow } from "colors/safe";
|
||||
import { join, relative, dirname, isAbsolute } from "path";
|
||||
import { dirname, isAbsolute, join, relative } from "path";
|
||||
import { normalize } from "./normalize";
|
||||
|
||||
export default function typescript(options?: Partial<IOptions>)
|
||||
@ -70,24 +70,36 @@ export default function typescript(options?: Partial<IOptions>)
|
||||
|
||||
context.info(`typescript version: ${tsModule.version}`);
|
||||
context.debug(`plugin options: ${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`);
|
||||
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
|
||||
context.debug(`rollup config: ${JSON.stringify(rollupOptions, undefined, 4)}`);
|
||||
|
||||
parsedConfig = parseTsConfig(pluginOptions.tsconfig, context, pluginOptions);
|
||||
|
||||
if (parsedConfig.options.rootDirs) {
|
||||
const includedOptions = _.flatMap(parsedConfig.options.rootDirs, (res) => {
|
||||
if (pluginOptions.include instanceof Array) {
|
||||
return pluginOptions.include.map((inc) => {
|
||||
return `${res}/${inc}`;
|
||||
});
|
||||
} else {
|
||||
return `${res}/${pluginOptions.include}`;
|
||||
}
|
||||
if (parsedConfig.options.rootDirs)
|
||||
{
|
||||
const included = _.flatMap(parsedConfig.options.rootDirs, (root) =>
|
||||
{
|
||||
if (pluginOptions.include instanceof Array)
|
||||
return pluginOptions.include.map((include) => join(root, include));
|
||||
else
|
||||
return join(root, pluginOptions.include);
|
||||
});
|
||||
filter = createFilter(includedOptions, pluginOptions.exclude);
|
||||
const excluded = _.flatMap(parsedConfig.options.rootDirs, (root) =>
|
||||
{
|
||||
if (pluginOptions.exclude instanceof Array)
|
||||
return pluginOptions.exclude.map((exclude) => join(root, exclude));
|
||||
else
|
||||
return join(root, pluginOptions.exclude);
|
||||
});
|
||||
|
||||
filter = createFilter(included, excluded);
|
||||
console.debug(`included: '${included}'`);
|
||||
console.debug(`excluded: '${excluded}'`);
|
||||
}
|
||||
else
|
||||
{
|
||||
filter = createFilter(pluginOptions.include, pluginOptions.exclude);
|
||||
console.debug(`included: '${pluginOptions.include}'`);
|
||||
console.debug(`excluded: '${pluginOptions.exclude}'`);
|
||||
}
|
||||
|
||||
servicesHost = new LanguageServiceHost(parsedConfig);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user