Karma and Webpack are removed

main
Shaun Dern 2020-04-02 18:06:00 +01:00
parent 469fa145a1
commit f8c9bb36ec
No known key found for this signature in database
GPG Key ID: 19E354FC9294F450
10 changed files with 96 additions and 4047 deletions

View File

@ -1,62 +0,0 @@
"use strict"; // eslint-disable-line
/* eslint no-var:0, func-names:0, import/no-extraneous-dependencies:0 */
var webpack = require('webpack')
module.exports = function createWebpackConfig(_options) {
var config
var options = _options || {}
var env = options.env || 'development'
config = {
context: options.context,
entry: options.entry,
mode: 'development',
devtool: 'inline-source-map',
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
},
}),
],
node: {
process: false,
},
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
],
},
output: {
library: 'updeep',
libraryTarget: 'umd',
},
resolve: {
extensions: ['.js'],
},
}
config.output.filename = options.filename
if (options.minify) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false,
},
})
)
}
return config
}

View File

@ -1,75 +0,0 @@
'use strict'
/* eslint strict:0, no-var:0, func-names:0 */
var createWebpackConfig = require('./createWebpackConfig')
var localLaunchers = {
ChromeNoSandboxHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
'--disable-setuid-sandbox',
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
'--no-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=9333',
],
},
}
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],
mochaReporter: {
showDiff: true,
},
files: [{ pattern: 'test/**/*.js', watched: false }],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/**/*.js': ['webpack', 'sourcemap'],
},
webpack: createWebpackConfig(),
webpackMiddleware: {
noInfo: true,
stats: 'errors-only',
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN ||
// config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: Object.keys(localLaunchers),
customLaunchers: localLaunchers,
})
}

View File

@ -27,9 +27,7 @@
"dev": "microbundle watch",
"dtslint": "dtslint --localTs node_modules/typescript/lib types",
"lint": "npm run dtslint && eslint .",
"test": "npm run test:mocha && npm run test:karma",
"test:karma": "karma start karma.conf.js --single-run",
"test:mocha": "mocha --recursive --require \"@babel/register\" test"
"test": "mocha --recursive --require \"@babel/register\" test"
},
"license": "MIT",
"bugs": {
@ -49,7 +47,6 @@
"@types/lodash": "^4.14.119",
"@types/mocha": "^7.0.1",
"@types/node": "^13.9.8",
"babel-loader": "^8.0.6",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"dtslint": "^3.4.1",
@ -58,22 +55,9 @@
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-prettier": "^3.1.2",
"exports-loader": "^0.7.0",
"karma": "^4.3.0",
"karma-babel-preprocessor": "^8.0.1",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"microbundle": "^0.11.0",
"mocha": "^7.0.0",
"prettier": "^2.0.2",
"rimraf": "^3.0.0",
"typescript": "^3.6.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.1.11",
"webpack-stream": "^5.2.1"
"typescript": "^3.6.3"
}
}

View File

@ -1,10 +0,0 @@
module.exports = {
"extends": require.resolve("../.eslintrc"),
"rules": {
"new-cap": [2, {
"capIsNewExceptions": [
"Suite"
]
}],
}
}

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>updeep perf</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>Running tests...</div>
<div id='perf'></div>
<script src='/perf/index.js'></script>
<p>Done!</p>
</body>
</html>

View File

@ -1,87 +0,0 @@
/* eslint no-console:0, no-unused-vars:0, import/no-extraneous-dependencies:0 */
/* global document */
const Benchmark = require('benchmark')
const _ = require('lodash')
const u = require('../lib')
const { curry2, curry4 } = require('../lib/util/curry')
const add4 = (a, b, c, d) => a + b + c + d
const add2 = (a, b) => a + b
const fakeCurryAdd = (x) => (y) => x + y
const lodashCurryAdd2 = _.curry(add2)
const updeepCurryAdd2 = curry2(add2)
const lodashCurryAdd4 = _.curry(add4)
const updeepCurryAdd4 = curry4(add4)
// const updeepCurryBig = curry.curryBig(add);
const array = [0, 1, 2, 3, 4, 5]
// const doUpdate = u(x => x + 1);
function log(str) {
if (typeof document !== 'undefined') {
console.log(str)
const el = document.getElementById('perf')
el.innerHTML += str
}
}
function createSuite(suiteName, tests) {
const suite = Benchmark.Suite() // eslint-disable
return () => {
log(`<h2>${suiteName}</h2><ul>`)
_.each(tests, (fn, testName) => {
suite.add(testName, fn)
})
suite
.on('cycle', (event) => {
log(`<li>${String(event.target)}</li>`)
})
.on('complete', () => {
log('</ul>')
})
.run({ async: true })
}
}
const curryVsLodash = createSuite('Curry', {
'updeep curry': () => {
updeepCurryAdd4(3)(4)(5)(6)
updeepCurryAdd4(3, 4, 5, 6)
updeepCurryAdd4(u._, 4, u._, 6)(3, 4)
updeepCurryAdd2(3)(4)
updeepCurryAdd2(3, 4)
},
'lodash curry': () => {
lodashCurryAdd4(3)(4)(5)(6)
lodashCurryAdd4(3, 4, 5, 6)
lodashCurryAdd4(_, 4, _, 6)(3, 4)
lodashCurryAdd2(3)(4)
lodashCurryAdd2(3, 4)
},
})
const mapVsLodash = createSuite('Map', {
'_.map': () => _.map(array, fakeCurryAdd(8)),
'u.map': () => u.map(fakeCurryAdd(8), array),
})
const fn = (a, b, c, d, e) => a + b + c + d + e
const fnControl = (a, b, c, d, e) => fn(a, b, c, d, e)
const fnApply = (...args) => fn(...args)
const fnDestructure = (...args) => {
const [a, b, c, d, e] = args
return fn(a, b, c, d, e)
}
const applyVsDestructure = createSuite('apply vs destructure', {
control: () => fnControl(1, 2, 3, 4, 5),
apply: () => fnApply(1, 2, 3, 4, 5),
destructure: () => fnDestructure(1, 2, 3, 4, 5),
})
curryVsLodash()
mapVsLodash()
// applyVsDestructure();

View File

@ -1,29 +0,0 @@
'use strict'
/* eslint strict:0, no-var:0, func-names:0 */
var path = require('path')
var config = require('../createWebpackConfig')({
context: __dirname,
entry: ['webpack/hot/dev-server', './index.js'],
minify: false,
env: 'production',
})
config.output = {
path: path.join(__dirname, './build'),
publicPath: '/assets/',
filename: 'perf.js',
}
config.devServer = {
contentBase: __dirname,
noInfo: true,
hot: true,
inline: true,
}
config.module.noParse = [/benchmark\.js$/]
module.exports = config

View File

@ -50,19 +50,14 @@ describe('u.freeze', () => {
expect(Object.isFrozen(object.foo)).to.be.false
})
if (typeof process !== 'undefined') {
it('does not freeze in production', () => {
process.env = {
...process.env,
NODE_ENV: 'production',
}
it('does not freeze in production', () => {
process.env.NODE_ENV = 'production'
const object = {}
u.freeze(object)
const object = {}
u.freeze(object)
expect(Object.isFrozen(object)).to.be.false
})
}
expect(Object.isFrozen(object)).to.be.false
})
it('handles null objects', () => {
const object = { foo: null }

View File

@ -1,5 +0,0 @@
'use strict'
/* eslint strict:0, no-var:0, func-names:0 */
module.exports = require('./createWebpackConfig')()

3824
yarn.lock

File diff suppressed because it is too large Load Diff