Skip to content

Commit

Permalink
Re-update snaps
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Dec 2, 2020
1 parent 6a644a1 commit e6f94a3
Show file tree
Hide file tree
Showing 3 changed files with 446 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PROCESS_MODULE_NAME = 'process';
export function rollupPluginNodeProcessPolyfill(env = {}): Plugin {
const injectPlugin = inject({
process: PROCESS_MODULE_NAME,
include: ['*.js', '*.mjs', '*.cjs'],
include: /\.(cjs|js|jsx|mjs|ts|tsx)$/, // only target JavaScript files
});

return {
Expand Down
268 changes: 216 additions & 52 deletions test/build/config-treeshake/__snapshots__
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,215 @@ export { flatten };"
`;

exports[`snowpack build config-treeshake: build/web_modules/async.js 1`] = `
"/**
* Creates a continuation function with some arguments already applied.
*
* Useful as a shorthand when combined with other control flow functions. Any
* arguments passed to the returned function are added to the arguments
* originally passed to apply.
*
* @name apply
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {Function} fn - The function you want to eventually apply all
* arguments to. Invokes with (arguments...).
* @param {...*} arguments... - Any number of arguments to automatically apply
* when the continuation is called.
* @returns {Function} the partially-applied function
* @example
*
* // using apply
* async.parallel([
* async.apply(fs.writeFile, 'testfile1', 'test1'),
* async.apply(fs.writeFile, 'testfile2', 'test2')
* ]);
*
*
* // the same process without using apply
* async.parallel([
* function(callback) {
* fs.writeFile('testfile1', 'test1', callback);
* },
* function(callback) {
* fs.writeFile('testfile2', 'test2', callback);
* }
* ]);
*
* // It's possible to pass any number of additional arguments when calling the
* // continuation:
*
* node> var fn = async.apply(sys.puts, 'one');
* node> fn('two', 'three');
* one
* two
* three
*/
"/* SNOWPACK PROCESS POLYFILL (based on https://github.com/calvinmetcalf/node-process-es6) */
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
var cachedSetTimeout = defaultSetTimout;
var cachedClearTimeout = defaultClearTimeout;
var globalContext;
if (typeof window !== 'undefined') {
globalContext = window;
} else if (typeof self !== 'undefined') {
globalContext = self;
} else {
globalContext = {};
}
if (typeof globalContext.setTimeout === 'function') {
cachedSetTimeout = setTimeout;
}
if (typeof globalContext.clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
}
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
function nextTick(fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
}
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
var title = 'browser';
var platform = 'browser';
var browser = true;
var argv = [];
var version = ''; // empty string to avoid regexp issues
var versions = {};
var release = {};
var config = {};
function noop() {}
var on = noop;
var addListener = noop;
var once = noop;
var off = noop;
var removeListener = noop;
var removeAllListeners = noop;
var emit = noop;
function binding(name) {
throw new Error('process.binding is not supported');
}
function cwd () { return '/' }
function chdir (dir) {
throw new Error('process.chdir is not supported');
}function umask() { return 0; }
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
var performance = globalContext.performance || {};
var performanceNow =
performance.now ||
performance.mozNow ||
performance.msNow ||
performance.oNow ||
performance.webkitNow ||
function(){ return (new Date()).getTime() };
// generate timestamp or delta
// see http://nodejs.org/api/process.html#process_process_hrtime
function hrtime(previousTimestamp){
var clocktime = performanceNow.call(performance)*1e-3;
var seconds = Math.floor(clocktime);
var nanoseconds = Math.floor((clocktime%1)*1e9);
if (previousTimestamp) {
seconds = seconds - previousTimestamp[0];
nanoseconds = nanoseconds - previousTimestamp[1];
if (nanoseconds<0) {
seconds--;
nanoseconds += 1e9;
}
}
return [seconds,nanoseconds]
}
var startTime = new Date();
function uptime() {
var currentTime = new Date();
var dif = currentTime - startTime;
return dif / 1000;
}
var process = {
nextTick: nextTick,
title: title,
browser: browser,
env: {\\"NODE_ENV\\":\\"test\\"},
argv: argv,
version: version,
versions: versions,
on: on,
addListener: addListener,
once: once,
off: off,
removeListener: removeListener,
removeAllListeners: removeAllListeners,
emit: emit,
binding: binding,
cwd: cwd,
chdir: chdir,
umask: umask,
hrtime: hrtime,
platform: platform,
release: release,
config: config,
uptime: uptime
};
function initialParams (fn) {
return function (...args/*, callback*/) {
var callback = args.pop();
Expand Down Expand Up @@ -267,7 +431,7 @@ function isArrayLike(value) {
// A temporary value used to identify if the loop should be broken.
// See #1064, #1293
const breakLoop = {};
function once(fn) {
function once$1(fn) {
function wrapper (...args) {
if (fn === null) return;
var callFn = fn;
Expand Down Expand Up @@ -378,7 +542,7 @@ function asyncEachOfLimit(generator, limit, iteratee, callback) {
}
var eachOfLimit = (limit) => {
return (obj, iteratee, callback) => {
callback = once(callback);
callback = once$1(callback);
if (limit <= 0) {
throw new RangeError('concurrency limit cannot be less than 1')
}
Expand Down Expand Up @@ -461,7 +625,7 @@ function eachOfLimit$1(coll, limit, iteratee, callback) {
var eachOfLimit$2 = awaitify(eachOfLimit$1, 4);
// eachOf implementation optimized for array-likes
function eachOfArrayLike(coll, iteratee, callback) {
callback = once(callback);
callback = once$1(callback);
var index = 0,
completed = 0,
{length} = coll,
Expand Down Expand Up @@ -661,7 +825,7 @@ var mapSeries$1 = awaitify(mapSeries, 3);
* });
*/
function reduce(coll, memo, iteratee, callback) {
callback = once(callback);
callback = once$1(callback);
var _iteratee = wrapAsync(iteratee);
return eachOfSeries$1(coll, (x, i, iterCb) => {
_iteratee(memo, x, (err, v) => {
Expand Down Expand Up @@ -1416,7 +1580,7 @@ var groupByLimit$1 = awaitify(groupByLimit, 4);
* @returns {Promise} a promise, if no callback is passed
*/
function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback);
callback = once$1(callback);
var newObj = {};
var _iteratee = wrapAsync(iteratee);
return eachOfLimit(limit)(obj, (val, key, next) => {
Expand Down Expand Up @@ -1516,7 +1680,7 @@ var _parallel = awaitify((eachfn, tasks, callback) => {
* });
*/
function race(tasks, callback) {
callback = once(callback);
callback = once$1(callback);
if (!Array.isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
if (!tasks.length) return callback();
for (var i = 0, l = tasks.length; i < l; i++) {
Expand Down Expand Up @@ -1928,7 +2092,7 @@ var whilst$1 = awaitify(whilst, 3);
* }
*/
function waterfall (tasks, callback) {
callback = once(callback);
callback = once$1(callback);
if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
if (!tasks.length) return callback();
var taskIndex = 0;
Expand Down
Loading

0 comments on commit e6f94a3

Please sign in to comment.