initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @emails oncall+js_foundation
*/
'use strict';
import type {BabelSourceMap} from '@babel/core';
jest.mock('uglify-es', () => ({
minify: jest.fn(code => {
return {
code: code.replace(/(^|\W)\s+/g, '$1'),
map: {},
};
}),
}));
const minify = require('..');
const {objectContaining} = jasmine;
function getFakeMap(): BabelSourceMap {
return {
version: 3,
sources: ['?'],
mappings: '',
names: [],
};
}
describe('Minification:', () => {
const filename = '/arbitrary/file.js';
const code = 'arbitrary(code)';
let map: BabelSourceMap;
let uglify;
beforeEach(() => {
uglify = require('uglify-es');
uglify.minify.mockClear();
uglify.minify.mockReturnValue({code: '', map: '{}'});
map = getFakeMap();
});
it('passes file name, code, and source map to `uglify`', () => {
minify.withSourceMap(code, map, filename);
expect(uglify.minify).toBeCalledWith(
code,
objectContaining({
sourceMap: {
content: map,
includeSources: false,
},
}),
);
});
it('passes code to `uglify` when minifying without source map', () => {
minify.noSourceMap(code);
expect(uglify.minify).toBeCalledWith(
code,
objectContaining({
sourceMap: {
content: undefined,
includeSources: false,
},
}),
);
});
it('returns the code provided by uglify', () => {
uglify.minify.mockReturnValue({code, map: '{}'});
const result = minify.withSourceMap('', getFakeMap(), '');
expect(result.code).toBe(code);
expect(minify.noSourceMap('')).toBe(code);
});
it('parses the source map object provided by uglify and sets the sources property', () => {
uglify.minify.mockReturnValue({map: JSON.stringify(map), code: ''});
const result = minify.withSourceMap('', getFakeMap(), filename);
expect(result.map).toEqual({...map, sources: [filename]});
});
});

77
node_modules/metro-minify-uglify/package.json generated vendored Normal file
View File

@@ -0,0 +1,77 @@
{
"_args": [
[
"metro-minify-uglify@0.30.2",
"/home/bernhard/freifunk-app/node_modules/metro"
]
],
"_from": "metro-minify-uglify@0.30.2",
"_id": "metro-minify-uglify@0.30.2",
"_inCache": true,
"_installable": true,
"_location": "/metro-minify-uglify",
"_nodeVersion": "8.9.4",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/metro-minify-uglify_0.30.2_1521165823597_0.047545389796936455"
},
"_npmUser": {
"email": "rafeca@gmail.com",
"name": "rafeca"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"name": "metro-minify-uglify",
"raw": "metro-minify-uglify@0.30.2",
"rawSpec": "0.30.2",
"scope": null,
"spec": "0.30.2",
"type": "version"
},
"_requiredBy": [
"/metro"
],
"_resolved": "https://registry.npmjs.org/metro-minify-uglify/-/metro-minify-uglify-0.30.2.tgz",
"_shasum": "7299a0376ad6340e9acf415912d54b5309702040",
"_shrinkwrap": null,
"_spec": "metro-minify-uglify@0.30.2",
"_where": "/home/bernhard/freifunk-app/node_modules/metro",
"bugs": {
"url": "https://github.com/facebook/metro/issues"
},
"dependencies": {
"uglify-es": "^3.1.9"
},
"description": "🚇 Default minifier for Metro",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 10,
"integrity": "sha512-xwqMqYYKZEqJ66Wpf5OpyPJhApOQDb8rYiO94VInlDeHpN7eKGCVILclnx9AmVM3dStmebvXa5jrdgsbnJ1bSg==",
"shasum": "7299a0376ad6340e9acf415912d54b5309702040",
"tarball": "https://registry.npmjs.org/metro-minify-uglify/-/metro-minify-uglify-0.30.2.tgz",
"unpackedSize": 9271
},
"homepage": "https://github.com/facebook/metro#readme",
"license": "MIT",
"main": "src/index.js",
"maintainers": [
{
"name": "rafeca",
"email": "rafeca@gmail.com"
}
],
"name": "metro-minify-uglify",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/facebook/metro.git"
},
"scripts": {
"cleanup-release": "test ! -e build && mv src build && mv src.real src",
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src"
},
"version": "0.30.2"
}

19
node_modules/metro-minify-uglify/src.real/index.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
const minifier = require('./minifier');
export type {MetroMinifier} from './types.js.flow';
export type {ResultWithMap} from './types.js.flow';
export type {ResultWithoutMap} from './types.js.flow';
module.exports = minifier;

69
node_modules/metro-minify-uglify/src.real/minifier.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
const uglify = require('uglify-es');
import type {MetroMinifier} from './types.js.flow';
import type {ResultWithMap} from './types.js.flow';
import type {BabelSourceMap} from '@babel/core';
function noSourceMap(code: string): string {
return minify(code).code;
}
function withSourceMap(
code: string,
sourceMap: ?BabelSourceMap,
filename: string,
): ResultWithMap {
const result = minify(code, sourceMap);
const map: BabelSourceMap = JSON.parse(result.map);
map.sources = [filename];
return {code: result.code, map};
}
function minify(inputCode: string, inputMap: ?BabelSourceMap) {
const result = uglify.minify(inputCode, {
mangle: {toplevel: true},
output: {
ascii_only: true,
quote_style: 3,
wrap_iife: true,
},
sourceMap: {
content: inputMap,
includeSources: false,
},
toplevel: true,
compress: {
// reduce_funcs inlines single-use function, which cause perf regressions.
reduce_funcs: false,
},
});
if (result.error) {
throw result.error;
}
return {
code: result.code,
map: result.map,
};
}
const metroMinifier: MetroMinifier = {
noSourceMap,
withSourceMap,
};
module.exports = metroMinifier;

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
import type {BabelSourceMap} from '@babel/core';
export type ResultWithMap = {
code: string,
map: BabelSourceMap,
};
export type ResultWithoutMap = string;
type MinifierWithSourceMap = (
code: string,
inputMap?: ?BabelSourceMap,
filename: string,
) => ResultWithMap;
type MinifierWithoutSourceMap = (code: string) => ResultWithoutMap;
export type MetroMinifier = {
noSourceMap: MinifierWithoutSourceMap,
withSourceMap: MinifierWithSourceMap,
};

19
node_modules/metro-minify-uglify/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
const minifier = require('./minifier');
module.exports = minifier;

19
node_modules/metro-minify-uglify/src/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
const minifier = require('./minifier');
export type {MetroMinifier} from './types.js.flow';
export type {ResultWithMap} from './types.js.flow';
export type {ResultWithoutMap} from './types.js.flow';
module.exports = minifier;

69
node_modules/metro-minify-uglify/src/minifier.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
const uglify = require('uglify-es');
function noSourceMap(code) {
return minify(code).code;
}
function withSourceMap(
code,
sourceMap,
filename)
{
const result = minify(code, sourceMap);
const map = JSON.parse(result.map);
map.sources = [filename];
return { code: result.code, map };
}
function minify(inputCode, inputMap) {
const result = uglify.minify(inputCode, {
mangle: { toplevel: true },
output: {
ascii_only: true,
quote_style: 3,
wrap_iife: true },
sourceMap: {
content: inputMap,
includeSources: false },
toplevel: true,
compress: {
// reduce_funcs inlines single-use function, which cause perf regressions.
reduce_funcs: false } });
if (result.error) {
throw result.error;
}
return {
code: result.code,
map: result.map };
}
const metroMinifier = {
noSourceMap,
withSourceMap };
module.exports = metroMinifier;

69
node_modules/metro-minify-uglify/src/minifier.js.flow generated vendored Normal file
View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
const uglify = require('uglify-es');
import type {MetroMinifier} from './types.js.flow';
import type {ResultWithMap} from './types.js.flow';
import type {BabelSourceMap} from '@babel/core';
function noSourceMap(code: string): string {
return minify(code).code;
}
function withSourceMap(
code: string,
sourceMap: ?BabelSourceMap,
filename: string,
): ResultWithMap {
const result = minify(code, sourceMap);
const map: BabelSourceMap = JSON.parse(result.map);
map.sources = [filename];
return {code: result.code, map};
}
function minify(inputCode: string, inputMap: ?BabelSourceMap) {
const result = uglify.minify(inputCode, {
mangle: {toplevel: true},
output: {
ascii_only: true,
quote_style: 3,
wrap_iife: true,
},
sourceMap: {
content: inputMap,
includeSources: false,
},
toplevel: true,
compress: {
// reduce_funcs inlines single-use function, which cause perf regressions.
reduce_funcs: false,
},
});
if (result.error) {
throw result.error;
}
return {
code: result.code,
map: result.map,
};
}
const metroMinifier: MetroMinifier = {
noSourceMap,
withSourceMap,
};
module.exports = metroMinifier;

33
node_modules/metro-minify-uglify/src/types.js.flow generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
import type {BabelSourceMap} from '@babel/core';
export type ResultWithMap = {
code: string,
map: BabelSourceMap,
};
export type ResultWithoutMap = string;
type MinifierWithSourceMap = (
code: string,
inputMap?: ?BabelSourceMap,
filename: string,
) => ResultWithMap;
type MinifierWithoutSourceMap = (code: string) => ResultWithoutMap;
export type MetroMinifier = {
noSourceMap: MinifierWithoutSourceMap,
withSourceMap: MinifierWithSourceMap,
};