Skip to content

Commit 52593d2

Browse files
author
Lukas Rieder
committed
Add 'sourceMapCallback' option to enable advanced mapping use cases
1 parent af63ad3 commit 52593d2

File tree

7 files changed

+200
-162
lines changed

7 files changed

+200
-162
lines changed

dist/ioptions.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export interface IOptions {
1313
typescript: typeof tsModule;
1414
tsconfigOverride: any;
1515
tsconfigDefaults: any;
16+
sourceMapCallback: (id: string, map: string) => void;
1617
}

dist/rollup-plugin-typescript2.cjs.js

Lines changed: 96 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var lodash = createCommonjsModule(function (module, exports) {
4949
var undefined;
5050

5151
/** Used as the semantic version number. */
52-
var VERSION = '4.17.4';
52+
var VERSION = '4.17.5';
5353

5454
/** Used as the size to enable large array optimizations. */
5555
var LARGE_ARRAY_SIZE = 200;
@@ -180,7 +180,6 @@ var lodash = createCommonjsModule(function (module, exports) {
180180
/** Used to match property names within property paths. */
181181
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
182182
reIsPlainProp = /^\w*$/,
183-
reLeadingDot = /^\./,
184183
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
185184

186185
/**
@@ -280,8 +279,8 @@ var lodash = createCommonjsModule(function (module, exports) {
280279
reOptMod = rsModifier + '?',
281280
rsOptVar = '[' + rsVarRange + ']?',
282281
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
283-
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
284-
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
282+
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
283+
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
285284
rsSeq = rsOptVar + reOptMod + rsOptJoin,
286285
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
287286
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
@@ -488,34 +487,6 @@ var lodash = createCommonjsModule(function (module, exports) {
488487

489488
/*--------------------------------------------------------------------------*/
490489

491-
/**
492-
* Adds the key-value `pair` to `map`.
493-
*
494-
* @private
495-
* @param {Object} map The map to modify.
496-
* @param {Array} pair The key-value pair to add.
497-
* @returns {Object} Returns `map`.
498-
*/
499-
function addMapEntry(map, pair) {
500-
// Don't return `map.set` because it's not chainable in IE 11.
501-
map.set(pair[0], pair[1]);
502-
return map;
503-
}
504-
505-
/**
506-
* Adds `value` to `set`.
507-
*
508-
* @private
509-
* @param {Object} set The set to modify.
510-
* @param {*} value The value to add.
511-
* @returns {Object} Returns `set`.
512-
*/
513-
function addSetEntry(set, value) {
514-
// Don't return `set.add` because it's not chainable in IE 11.
515-
set.add(value);
516-
return set;
517-
}
518-
519490
/**
520491
* A faster alternative to `Function#apply`, this function invokes `func`
521492
* with the `this` binding of `thisArg` and the arguments of `args`.
@@ -1282,6 +1253,20 @@ var lodash = createCommonjsModule(function (module, exports) {
12821253
return result;
12831254
}
12841255

1256+
/**
1257+
* Gets the value at `key`, unless `key` is "__proto__".
1258+
*
1259+
* @private
1260+
* @param {Object} object The object to query.
1261+
* @param {string} key The key of the property to get.
1262+
* @returns {*} Returns the property value.
1263+
*/
1264+
function safeGet(object, key) {
1265+
return key == '__proto__'
1266+
? undefined
1267+
: object[key];
1268+
}
1269+
12851270
/**
12861271
* Converts `set` to an array of its values.
12871272
*
@@ -2714,7 +2699,7 @@ var lodash = createCommonjsModule(function (module, exports) {
27142699
if (!cloneableTags[tag]) {
27152700
return object ? value : {};
27162701
}
2717-
result = initCloneByTag(value, tag, baseClone, isDeep);
2702+
result = initCloneByTag(value, tag, isDeep);
27182703
}
27192704
}
27202705
// Check for circular references and return its corresponding clone.
@@ -2725,6 +2710,22 @@ var lodash = createCommonjsModule(function (module, exports) {
27252710
}
27262711
stack.set(value, result);
27272712

2713+
if (isSet(value)) {
2714+
value.forEach(function(subValue) {
2715+
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2716+
});
2717+
2718+
return result;
2719+
}
2720+
2721+
if (isMap(value)) {
2722+
value.forEach(function(subValue, key) {
2723+
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
2724+
});
2725+
2726+
return result;
2727+
}
2728+
27282729
var keysFunc = isFull
27292730
? (isFlat ? getAllKeysIn : getAllKeys)
27302731
: (isFlat ? keysIn : keys);
@@ -3652,7 +3653,7 @@ var lodash = createCommonjsModule(function (module, exports) {
36523653
}
36533654
else {
36543655
var newValue = customizer
3655-
? customizer(object[key], srcValue, (key + ''), object, source, stack)
3656+
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
36563657
: undefined;
36573658

36583659
if (newValue === undefined) {
@@ -3679,8 +3680,8 @@ var lodash = createCommonjsModule(function (module, exports) {
36793680
* counterparts.
36803681
*/
36813682
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
3682-
var objValue = object[key],
3683-
srcValue = source[key],
3683+
var objValue = safeGet(object, key),
3684+
srcValue = safeGet(source, key),
36843685
stacked = stack.get(srcValue);
36853686

36863687
if (stacked) {
@@ -4588,20 +4589,6 @@ var lodash = createCommonjsModule(function (module, exports) {
45884589
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
45894590
}
45904591

4591-
/**
4592-
* Creates a clone of `map`.
4593-
*
4594-
* @private
4595-
* @param {Object} map The map to clone.
4596-
* @param {Function} cloneFunc The function to clone values.
4597-
* @param {boolean} [isDeep] Specify a deep clone.
4598-
* @returns {Object} Returns the cloned map.
4599-
*/
4600-
function cloneMap(map, isDeep, cloneFunc) {
4601-
var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
4602-
return arrayReduce(array, addMapEntry, new map.constructor);
4603-
}
4604-
46054592
/**
46064593
* Creates a clone of `regexp`.
46074594
*
@@ -4615,20 +4602,6 @@ var lodash = createCommonjsModule(function (module, exports) {
46154602
return result;
46164603
}
46174604

4618-
/**
4619-
* Creates a clone of `set`.
4620-
*
4621-
* @private
4622-
* @param {Object} set The set to clone.
4623-
* @param {Function} cloneFunc The function to clone values.
4624-
* @param {boolean} [isDeep] Specify a deep clone.
4625-
* @returns {Object} Returns the cloned set.
4626-
*/
4627-
function cloneSet(set, isDeep, cloneFunc) {
4628-
var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
4629-
return arrayReduce(array, addSetEntry, new set.constructor);
4630-
}
4631-
46324605
/**
46334606
* Creates a clone of the `symbol` object.
46344607
*
@@ -6223,7 +6196,7 @@ var lodash = createCommonjsModule(function (module, exports) {
62236196
*/
62246197
function initCloneArray(array) {
62256198
var length = array.length,
6226-
result = array.constructor(length);
6199+
result = new array.constructor(length);
62276200

62286201
// Add properties assigned by `RegExp#exec`.
62296202
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
@@ -6250,16 +6223,15 @@ var lodash = createCommonjsModule(function (module, exports) {
62506223
* Initializes an object clone based on its `toStringTag`.
62516224
*
62526225
* **Note:** This function only supports cloning values with tags of
6253-
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
6226+
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
62546227
*
62556228
* @private
62566229
* @param {Object} object The object to clone.
62576230
* @param {string} tag The `toStringTag` of the object to clone.
6258-
* @param {Function} cloneFunc The function to clone values.
62596231
* @param {boolean} [isDeep] Specify a deep clone.
62606232
* @returns {Object} Returns the initialized clone.
62616233
*/
6262-
function initCloneByTag(object, tag, cloneFunc, isDeep) {
6234+
function initCloneByTag(object, tag, isDeep) {
62636235
var Ctor = object.constructor;
62646236
switch (tag) {
62656237
case arrayBufferTag:
@@ -6278,7 +6250,7 @@ var lodash = createCommonjsModule(function (module, exports) {
62786250
return cloneTypedArray(object, isDeep);
62796251

62806252
case mapTag:
6281-
return cloneMap(object, isDeep, cloneFunc);
6253+
return new Ctor;
62826254

62836255
case numberTag:
62846256
case stringTag:
@@ -6288,7 +6260,7 @@ var lodash = createCommonjsModule(function (module, exports) {
62886260
return cloneRegExp(object);
62896261

62906262
case setTag:
6291-
return cloneSet(object, isDeep, cloneFunc);
6263+
return new Ctor;
62926264

62936265
case symbolTag:
62946266
return cloneSymbol(object);
@@ -6335,10 +6307,13 @@ var lodash = createCommonjsModule(function (module, exports) {
63356307
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
63366308
*/
63376309
function isIndex(value, length) {
6310+
var type = typeof value;
63386311
length = length == null ? MAX_SAFE_INTEGER : length;
6312+
63396313
return !!length &&
6340-
(typeof value == 'number' || reIsUint.test(value)) &&
6341-
(value > -1 && value % 1 == 0 && value < length);
6314+
(type == 'number' ||
6315+
(type != 'symbol' && reIsUint.test(value))) &&
6316+
(value > -1 && value % 1 == 0 && value < length);
63426317
}
63436318

63446319
/**
@@ -6788,11 +6763,11 @@ var lodash = createCommonjsModule(function (module, exports) {
67886763
*/
67896764
var stringToPath = memoizeCapped(function(string) {
67906765
var result = [];
6791-
if (reLeadingDot.test(string)) {
6766+
if (string.charCodeAt(0) === 46 /* . */) {
67926767
result.push('');
67936768
}
6794-
string.replace(rePropName, function(match, number, quote, string) {
6795-
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
6769+
string.replace(rePropName, function(match, number, quote, subString) {
6770+
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
67966771
});
67976772
return result;
67986773
});
@@ -10400,9 +10375,11 @@ var lodash = createCommonjsModule(function (module, exports) {
1040010375
function remainingWait(time) {
1040110376
var timeSinceLastCall = time - lastCallTime,
1040210377
timeSinceLastInvoke = time - lastInvokeTime,
10403-
result = wait - timeSinceLastCall;
10378+
timeWaiting = wait - timeSinceLastCall;
1040410379

10405-
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
10380+
return maxing
10381+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
10382+
: timeWaiting;
1040610383
}
1040710384

1040810385
function shouldInvoke(time) {
@@ -12834,9 +12811,35 @@ var lodash = createCommonjsModule(function (module, exports) {
1283412811
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
1283512812
* // => { 'a': 1, 'b': 2 }
1283612813
*/
12837-
var defaults = baseRest(function(args) {
12838-
args.push(undefined, customDefaultsAssignIn);
12839-
return apply(assignInWith, undefined, args);
12814+
var defaults = baseRest(function(object, sources) {
12815+
object = Object(object);
12816+
12817+
var index = -1;
12818+
var length = sources.length;
12819+
var guard = length > 2 ? sources[2] : undefined;
12820+
12821+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
12822+
length = 1;
12823+
}
12824+
12825+
while (++index < length) {
12826+
var source = sources[index];
12827+
var props = keysIn(source);
12828+
var propsIndex = -1;
12829+
var propsLength = props.length;
12830+
12831+
while (++propsIndex < propsLength) {
12832+
var key = props[propsIndex];
12833+
var value = object[key];
12834+
12835+
if (value === undefined ||
12836+
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
12837+
object[key] = source[key];
12838+
}
12839+
}
12840+
}
12841+
12842+
return object;
1284012843
});
1284112844

1284212845
/**
@@ -13233,6 +13236,11 @@ var lodash = createCommonjsModule(function (module, exports) {
1323313236
* // => { '1': 'c', '2': 'b' }
1323413237
*/
1323513238
var invert = createInverter(function(result, value, key) {
13239+
if (value != null &&
13240+
typeof value.toString != 'function') {
13241+
value = nativeObjectToString.call(value);
13242+
}
13243+
1323613244
result[value] = key;
1323713245
}, constant(identity));
1323813246

@@ -13263,6 +13271,11 @@ var lodash = createCommonjsModule(function (module, exports) {
1326313271
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
1326413272
*/
1326513273
var invertBy = createInverter(function(result, value, key) {
13274+
if (value != null &&
13275+
typeof value.toString != 'function') {
13276+
value = nativeObjectToString.call(value);
13277+
}
13278+
1326613279
if (hasOwnProperty.call(result, value)) {
1326713280
result[value].push(key);
1326813281
} else {
@@ -19960,6 +19973,9 @@ function typescript(options) {
1996019973
var transpiled = lodash_11(output.outputFiles, function (entry) { return lodash_6(entry.name, ".js") || lodash_6(entry.name, ".jsx"); });
1996119974
var map = lodash_11(output.outputFiles, function (entry) { return lodash_6(entry.name, ".map"); });
1996219975
var dts = lodash_11(output.outputFiles, function (entry) { return lodash_6(entry.name, ".d.ts"); });
19976+
if (pluginOptions.sourceMapCallback && map) {
19977+
pluginOptions.sourceMapCallback(id, map.text);
19978+
}
1996319979
return {
1996419980
code: transpiled ? transpiled.text : undefined,
1996519981
map: map ? JSON.parse(map.text) : { mappings: "" },

dist/rollup-plugin-typescript2.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)