Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lightFormat and optimize size of toDate (closes #1010) #1015

Merged
merged 2 commits into from Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 25 additions & 24 deletions config/karma.js
@@ -1,11 +1,11 @@
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs'
process.env.NODE_ENV = 'test'

var webpackConfig = require('./webpack')
var countReporter = require('./_lib/countReporter')
var benchmarkJSONReporter = require('./_lib/benchmarkJSONReporter')
const webpackConfig = require('./webpack')
const countReporter = require('./_lib/countReporter')
const benchmarkJSONReporter = require('./_lib/benchmarkJSONReporter')

var sauceLabsLaunchers = {
const sauceLabsLaunchers = {
// TODO: See if Safari became more reliable
safari: {
base: 'SauceLabs',
Expand Down Expand Up @@ -83,13 +83,13 @@ var sauceLabsLaunchers = {
}
}

var localLaunchers = {
const localLaunchers = {
LocalChrome: {
base: 'Chrome'
}
}

var travisLaunchers = {
const travisLaunchers = {
ChromeTravis: {
base: 'ChromeHeadless',
// NOTE: We need to launch Chrome with --no-sandbox.
Expand All @@ -98,7 +98,7 @@ var travisLaunchers = {
}
}

function config (config) {
function config(config) {
config.set({
frameworks: getFrameworksConfig(),
files: getFilesConfig(),
Expand All @@ -119,10 +119,10 @@ function config (config) {
// so waiting time must be insanely high.
browserNoActivityTimeout: process.env.TEST_CROSS_BROWSER
? 60 * 60 * 1000 /* 1 hour */
: 10 * 1000, /* 10 sec */
: 10 * 1000 /* 10 sec */,
captureTimeout: process.env.TEST_CROSS_BROWSER
? 120 * 1000 /* 2 min */
: 60 * 1000, /* 1 min */
: 60 * 1000 /* 1 min */,

sauceLabs: {
startConnect: false,
Expand All @@ -146,48 +146,49 @@ function config (config) {
'karma-webpack',
'karma-benchmark',
'karma-benchmark-reporter',
{'reporter:count': ['type', countReporter]},
{'reporter:benchmark-json': ['type', benchmarkJSONReporter]}
{ 'reporter:count': ['type', countReporter] },
{ 'reporter:benchmark-json': ['type', benchmarkJSONReporter] }
],

customLaunchers: process.env.TEST_CROSS_BROWSER ? sauceLabsLaunchers : process.env.TRAVIS ? travisLaunchers : localLaunchers,
customLaunchers: process.env.TEST_CROSS_BROWSER
? sauceLabsLaunchers
: process.env.TRAVIS
? travisLaunchers
: localLaunchers,
browsers: getBrowsersConfig(),
reporters: getReportersConfig()
})
}

function getFrameworksConfig () {
function getFrameworksConfig() {
if (process.env.TEST_BENCHMARK) {
return ['benchmark']
} else {
return ['mocha', 'sinon']
}
}

function getFilesConfig () {
function getFilesConfig() {
if (process.env.USE_STATIC_TESTS) {
return ['../tmp/tests.js']
} else if (process.env.TEST_BENCHMARK) {
return [
'../node_modules/moment/moment.js',
'../benchmark.js'
]
return ['../node_modules/moment/moment.js', '../benchmark.js']
} else {
return ['../test.js']
}
}

function getPreprocessorsConfig () {
function getPreprocessorsConfig() {
if (process.env.USE_STATIC_TESTS) {
return {'../tmp/tests.js': ['sourcemap']}
return { '../tmp/tests.js': ['sourcemap'] }
} else if (process.env.TEST_BENCHMARK) {
return {'../benchmark.js': ['webpack', 'sourcemap']}
return { '../benchmark.js': ['webpack', 'sourcemap'] }
} else {
return {'../test.js': ['webpack', 'sourcemap']}
return { '../test.js': ['webpack', 'sourcemap'] }
}
}

function getBrowsersConfig () {
function getBrowsersConfig() {
if (process.env.TEST_CROSS_BROWSER) {
return Object.keys(sauceLabsLaunchers)
} else if (process.env.TEST_BENCHMARK) {
Expand All @@ -199,7 +200,7 @@ function getBrowsersConfig () {
}
}

function getReportersConfig () {
function getReportersConfig() {
if (process.env.TEST_CROSS_BROWSER) {
return ['dots', 'saucelabs', 'count']
} else if (process.env.TEST_BENCHMARK) {
Expand Down
33 changes: 15 additions & 18 deletions config/webpack.js
@@ -1,42 +1,41 @@
var path = require('path')
const path = require('path')

var config = {
cache: true,
devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'inline-source-map',
const isProduction = process.env.NODE_ENV === 'production'

const config = {
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'source-map' : 'inline-source-map',
entry: getEntryConfig(),
output: getOutputConfig(),
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},
{test: /\.json$/, loader: 'json'}
]
rules: [{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }]
}
}

function getEntryConfig () {
module.exports = config

function getEntryConfig() {
if (process.env.BUILD_TESTS) {
return {
'tests': './testWithoutLocales.js'
tests: './testWithoutLocales.js'
}
} else if (process.env.NODE_ENV === 'test') {
return {}
return undefined
} else {
return {
'date_fns': './tmp/umd/index.js'
date_fns: './tmp/umd/index.js'
}
}
}

function getOutputConfig () {
function getOutputConfig() {
if (process.env.BUILD_TESTS) {
return {
path: path.join(process.cwd(), 'tmp'),
filename: '[name].js'
}
} else if (process.env.NODE_ENV === 'test') {
return {
path: '/'
}
return undefined
} else {
return {
path: path.join(process.cwd(), 'dist'),
Expand All @@ -46,5 +45,3 @@ function getOutputConfig () {
}
}
}

module.exports = config
1 change: 1 addition & 0 deletions examples/babel/package.json
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"dependencies": {
"babel-core": "^6.22.1",
"babel-loader": "6",
"babel-plugin-date-fns": "^0.1.0",
"babel-preset-babili": "^0.0.11",
"babel-preset-es2015": "^6.22.0",
Expand Down