mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- npm script for self building with output of previous build
- own version in debug output
This commit is contained in:
parent
c9ade22853
commit
388b5da6a1
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,4 +3,5 @@
|
||||
/typings
|
||||
/.rpt2_cache
|
||||
/.vscode
|
||||
/.idea
|
||||
/.idea
|
||||
/build-self
|
||||
50
dist/rollup-plugin-typescript2.cjs.js
vendored
50
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,6 +18532,7 @@ 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.');
|
||||
@ -18544,7 +18545,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(', '));
|
||||
@ -18555,7 +18556,7 @@ function applyDefaults(object, options){
|
||||
throw new Error('Encoding "' + options.encoding + '" not supported. ' +
|
||||
'supported values: ' + encodings.join(', '));
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -18570,23 +18571,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);
|
||||
}
|
||||
@ -18595,7 +18596,7 @@ function hash(object, options) {
|
||||
if (options.encoding === 'buffer') {
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return buf.toString(options.encoding);
|
||||
}
|
||||
|
||||
@ -18612,9 +18613,9 @@ exports.writeToStream = function(object, options, stream) {
|
||||
stream = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
||||
options = applyDefaults(object, options);
|
||||
|
||||
|
||||
return typeHasher(options, stream).dispatch(object);
|
||||
};
|
||||
|
||||
@ -18632,14 +18633,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) {
|
||||
@ -18651,9 +18652,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) {
|
||||
@ -18661,7 +18662,7 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
context.push(object);
|
||||
}
|
||||
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
||||
write('buffer:');
|
||||
return write(object);
|
||||
@ -18687,7 +18688,11 @@ 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){
|
||||
@ -18703,7 +18708,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) {
|
||||
@ -18711,7 +18716,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,
|
||||
@ -18765,7 +18770,7 @@ function typeHasher(options, writeTo, context){
|
||||
// have the same hash
|
||||
this.dispatch("function-name:" + String(fn.name));
|
||||
}
|
||||
|
||||
|
||||
if (options.respectFunctionProperties) {
|
||||
this._object(fn);
|
||||
}
|
||||
@ -18842,7 +18847,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');
|
||||
@ -19780,6 +19785,7 @@ function typescript(options) {
|
||||
rollupOptions = config;
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info("typescript version: " + tsModule.version);
|
||||
context.info("rollup-plugin-typescript2 version: 0.8.0");
|
||||
context.debug("plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4));
|
||||
context.debug("rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4));
|
||||
parsedConfig = parseTsConfig(pluginOptions.tsconfig, context, pluginOptions);
|
||||
|
||||
50
dist/rollup-plugin-typescript2.es.js
vendored
50
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,6 +18528,7 @@ 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.');
|
||||
@ -18540,7 +18541,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(', '));
|
||||
@ -18551,7 +18552,7 @@ function applyDefaults(object, options){
|
||||
throw new Error('Encoding "' + options.encoding + '" not supported. ' +
|
||||
'supported values: ' + encodings.join(', '));
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -18566,23 +18567,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);
|
||||
}
|
||||
@ -18591,7 +18592,7 @@ function hash(object, options) {
|
||||
if (options.encoding === 'buffer') {
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return buf.toString(options.encoding);
|
||||
}
|
||||
|
||||
@ -18608,9 +18609,9 @@ exports.writeToStream = function(object, options, stream) {
|
||||
stream = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
||||
options = applyDefaults(object, options);
|
||||
|
||||
|
||||
return typeHasher(options, stream).dispatch(object);
|
||||
};
|
||||
|
||||
@ -18628,14 +18629,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) {
|
||||
@ -18647,9 +18648,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) {
|
||||
@ -18657,7 +18658,7 @@ function typeHasher(options, writeTo, context){
|
||||
} else {
|
||||
context.push(object);
|
||||
}
|
||||
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
||||
write('buffer:');
|
||||
return write(object);
|
||||
@ -18683,7 +18684,11 @@ 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){
|
||||
@ -18699,7 +18704,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) {
|
||||
@ -18707,7 +18712,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,
|
||||
@ -18761,7 +18766,7 @@ function typeHasher(options, writeTo, context){
|
||||
// have the same hash
|
||||
this.dispatch("function-name:" + String(fn.name));
|
||||
}
|
||||
|
||||
|
||||
if (options.respectFunctionProperties) {
|
||||
this._object(fn);
|
||||
}
|
||||
@ -18838,7 +18843,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');
|
||||
@ -19776,6 +19781,7 @@ function typescript(options) {
|
||||
rollupOptions = config;
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info("typescript version: " + tsModule.version);
|
||||
context.info("rollup-plugin-typescript2 version: 0.8.0");
|
||||
context.debug("plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4));
|
||||
context.debug("rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4));
|
||||
parsedConfig = parseTsConfig(pluginOptions.tsconfig, context, pluginOptions);
|
||||
|
||||
18
package.json
18
package.json
@ -25,11 +25,12 @@
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist/*",
|
||||
"build": "rollup -c",
|
||||
"build-self": "rollup -c rollup.config.self.js",
|
||||
"lint": "tslint -c ./tslint.json src/*.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^4.0.2",
|
||||
"tslib": "^1.7.1",
|
||||
"tslib": "^1.8.0",
|
||||
"resolve": "^1.4.0",
|
||||
"rollup-pluginutils": "^2.0.1"
|
||||
},
|
||||
@ -39,24 +40,25 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.5.3",
|
||||
"object-hash": "^1.1.8",
|
||||
"object-hash": "^1.2.0",
|
||||
"colors": "^1.1.2",
|
||||
"graphlib": "^2.1.1",
|
||||
"lodash": "^4.17.4",
|
||||
"@types/colors": "^1.1.3",
|
||||
"@types/fs-extra": "^3.0.3",
|
||||
"@types/fs-extra": "^4.0.2",
|
||||
"@types/graphlib": "^2.1.4",
|
||||
"@types/lodash": "^4.14.76",
|
||||
"@types/node": "^8.0.31",
|
||||
"@types/object-hash": "^0.5.29",
|
||||
"@types/lodash": "^4.14.78",
|
||||
"@types/node": "^8.0.46",
|
||||
"@types/object-hash": "^1.1.0",
|
||||
"@types/resolve": "^0.0.4",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.50.0",
|
||||
"rollup-plugin-typescript2": "github:ezolenko/rollup-plugin-typescript2#master",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-commonjs": "^8.2.1",
|
||||
"rollup-plugin-commonjs": "^8.2.4",
|
||||
"rollup-plugin-re": "^1.0.6",
|
||||
"rollup-watch": "^4.3.1",
|
||||
"tslint": "^5.7.0"
|
||||
"tslint": "^5.8.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
58
rollup.config.base.js
Normal file
58
rollup.config.base.js
Normal file
@ -0,0 +1,58 @@
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import replace from 'rollup-plugin-re';
|
||||
|
||||
const pkg = require('./package.json');
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
|
||||
external: [
|
||||
"fs",
|
||||
"fs-extra",
|
||||
"resolve",
|
||||
"crypto",
|
||||
"path",
|
||||
"constants",
|
||||
"stream",
|
||||
"util",
|
||||
"assert",
|
||||
"os",
|
||||
],
|
||||
|
||||
plugins: [
|
||||
replace
|
||||
({
|
||||
replaces: { "$RPT2_VERSION": pkg.version },
|
||||
}),
|
||||
resolve({ jsnext: true, preferBuiltins: true }),
|
||||
commonjs
|
||||
({
|
||||
include: "node_modules/**",
|
||||
namedExports:
|
||||
{
|
||||
"graphlib": [ "alg", "Graph" ],
|
||||
"colors/safe": [ "green", "white", "red", "yellow", "blue" ],
|
||||
"lodash": [ "get", "each", "isEqual", "some", "filter", "endsWith", "map", "has", "isFunction", "concat", "find", "defaults", "assign", "merge", "flatMap", "chain" ],
|
||||
// "fs-extra": [ "renameSync", "removeSync", "ensureFileSync", "writeJsonSync", "readJsonSync", "existsSync", "readdirSync", "emptyDirSync" ],
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
banner: '/* eslint-disable */',
|
||||
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
file: pkg.main
|
||||
},
|
||||
{
|
||||
format: 'es',
|
||||
file: pkg.module
|
||||
},
|
||||
{
|
||||
format: 'es',
|
||||
file: 'build-self/' + pkg.module
|
||||
}
|
||||
]
|
||||
};
|
||||
@ -1,52 +1,7 @@
|
||||
import ts from 'rollup-plugin-typescript2';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
|
||||
const pkg = require('./package.json');
|
||||
import config from "./rollup.config.base"
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
config.plugins.push(ts({ verbosity: 2, abortOnError: false }));
|
||||
|
||||
external: [
|
||||
"fs",
|
||||
"fs-extra",
|
||||
"resolve",
|
||||
"crypto",
|
||||
"path",
|
||||
"constants",
|
||||
"stream",
|
||||
"util",
|
||||
"assert",
|
||||
"os",
|
||||
],
|
||||
|
||||
plugins: [
|
||||
resolve({ jsnext: true, preferBuiltins: true }),
|
||||
commonjs(
|
||||
{
|
||||
include: "node_modules/**",
|
||||
namedExports:
|
||||
{
|
||||
"graphlib": [ "alg", "Graph" ],
|
||||
"colors/safe": [ "green", "white", "red", "yellow", "blue" ],
|
||||
"lodash": [ "get", "each", "isEqual", "some", "filter", "endsWith", "map", "has", "isFunction", "concat", "find", "defaults", "assign", "merge", "flatMap", "chain" ],
|
||||
// "fs-extra": [ "renameSync", "removeSync", "ensureFileSync", "writeJsonSync", "readJsonSync", "existsSync", "readdirSync", "emptyDirSync" ],
|
||||
},
|
||||
}
|
||||
),
|
||||
ts({ verbosity: 2, abortOnError: false }),
|
||||
],
|
||||
|
||||
banner: '/* eslint-disable */',
|
||||
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
file: pkg.main
|
||||
},
|
||||
{
|
||||
format: 'es',
|
||||
file: pkg.module
|
||||
}
|
||||
]
|
||||
};
|
||||
export default config;
|
||||
|
||||
7
rollup.config.self.js
Normal file
7
rollup.config.self.js
Normal file
@ -0,0 +1,7 @@
|
||||
import ts from './build-self/dist/rollup-plugin-typescript2.es';
|
||||
|
||||
import config from "./rollup.config.base"
|
||||
|
||||
config.plugins.push(ts({ verbosity: 2, abortOnError: false }));
|
||||
|
||||
export default config;
|
||||
@ -69,6 +69,7 @@ export default function typescript(options?: Partial<IOptions>)
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
|
||||
context.info(`typescript version: ${tsModule.version}`);
|
||||
context.info(`rollup-plugin-typescript2 version: $RPT2_VERSION`);
|
||||
context.debug(`plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${(value as typeof tsModule).version}` : value, 4)}`);
|
||||
context.debug(`rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user