Skip to content

Commit

Permalink
feat: drop core-js and babel where possible
Browse files Browse the repository at this point in the history
Now that the minimum version of Node that we support is 4,
we can stop shimming things everyhwere on the server side code.
  • Loading branch information
dignifiedquire committed Nov 25, 2017
1 parent 0e1907d commit 60dfc5c
Show file tree
Hide file tree
Showing 34 changed files with 231 additions and 599 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion gruntfile.js
Expand Up @@ -31,7 +31,6 @@ module.exports = function (grunt) {
},
mochaTest: {
options: {
require: 'babel-register',
reporter: 'dot',
ui: 'bdd',
quiet: false,
Expand Down
7 changes: 2 additions & 5 deletions lib/file-list.js
Expand Up @@ -7,9 +7,6 @@
// Dependencies
// ------------

var Map = require('core-js/library/fn/map')
var Set = require('core-js/library/fn/set')
var from = require('core-js/library/fn/array/from')
var Promise = require('bluebird')
var mm = require('minimatch')
var Glob = require('glob').Glob
Expand Down Expand Up @@ -120,7 +117,7 @@ List.prototype._findFile = function (path, pattern) {
if (!path || !pattern) return
if (!this.buckets.has(pattern.pattern)) return

return _.find(from(this.buckets.get(pattern.pattern)), function (file) {
return _.find(Array.from(this.buckets.get(pattern.pattern)), function (file) {
return file.originalPath === path
})
}
Expand Down Expand Up @@ -229,7 +226,7 @@ Object.defineProperty(List.prototype, 'files', {
}

var expandPattern = function (p) {
return from(self.buckets.get(p.pattern) || []).sort(byPath)
return Array.from(self.buckets.get(p.pattern) || []).sort(byPath)
}

var served = this._patterns.filter(function (pattern) {
Expand Down
3 changes: 1 addition & 2 deletions lib/middleware/source_files.js
@@ -1,4 +1,3 @@
var from = require('core-js/library/fn/array/from')
var querystring = require('querystring')
var _ = require('lodash')

Expand All @@ -8,7 +7,7 @@ var log = logger.create('middleware:source-files')

// Files is a Set
var findByPath = function (files, path) {
return _.find(from(files), function (file) {
return _.find(Array.from(files), function (file) {
return file.path === path
})
}
Expand Down
1 change: 0 additions & 1 deletion lib/reporter.js
@@ -1,7 +1,6 @@
var util = require('util')
var resolve = require('url').resolve
var SourceMapConsumer = require('source-map').SourceMapConsumer
var WeakMap = require('core-js/es6/weak-map')
var _ = require('lodash')

var log = require('./logger').create('reporter')
Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -358,8 +358,6 @@
"devDependencies": {
"LiveScript": "^1.3.0",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.23.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.2.2",
Expand Down
12 changes: 7 additions & 5 deletions test/unit/cli.spec.js
@@ -1,8 +1,10 @@
import cli from '../../lib/cli'
import optimist from 'optimist'
import path from 'path'
import constant from '../../lib/constants'
import mocks from 'mocks'
var optimist = require('optimist')
var path = require('path')
var mocks = require('mocks')

var cli = require('../../lib/cli')
var constant = require('../../lib/constants')

var loadFile = mocks.loadFile

describe('cli', () => {
Expand Down
6 changes: 4 additions & 2 deletions test/unit/config.spec.js
@@ -1,4 +1,4 @@
import path from 'path'
var path = require('path')
var loadFile = require('mocks').loadFile
var helper = require('../../lib/helper')
var logger = require('../../lib/logger.js')
Expand Down Expand Up @@ -421,7 +421,9 @@ describe('config', () => {
describe('custom', () => {
var di = require('di')

var forwardArgsFactory = (args) => args
var forwardArgsFactory = function (args) {
return args
}

var baseModule = {
'preprocessor:base': ['type', forwardArgsFactory],
Expand Down
5 changes: 3 additions & 2 deletions test/unit/emitter_wrapper.spec.js
@@ -1,5 +1,6 @@
import EmitterWrapper from '../../lib/emitter_wrapper'
import {EventEmitter} from 'events'
var EventEmitter = require('events').EventEmitter

var EmitterWrapper = require('../../lib/emitter_wrapper')

describe('emitter_wrapper', () => {
var emitter
Expand Down
97 changes: 56 additions & 41 deletions test/unit/file-list.spec.js
@@ -1,23 +1,24 @@
import Promise from 'bluebird'
import {EventEmitter} from 'events'
import mocks from 'mocks'
import proxyquire from 'proxyquire'
import pathLib from 'path'
import _ from 'lodash'
import from from 'core-js/library/fn/array/from'
var Promise = require('bluebird')
var EventEmitter = require('events').EventEmitter
var mocks = require('mocks')
var proxyquire = require('proxyquire')
var pathLib = require('path')
var _ = require('lodash')

import helper from '../../lib/helper'
import config from '../../lib/config'
var helper = require('../../lib/helper')
var config = require('../../lib/config')

// create an array of pattern objects from given strings
var patterns = (...strings) => strings.map((str) => new config.Pattern(str))
var patterns = function () {
return Array.from(arguments).map((str) => new config.Pattern(str))
}

function pathsFrom (files) {
return _.map(from(files), 'path')
return _.map(Array.from(files), 'path')
}

function findFile (path, files) {
return from(files).find((file) => file.path === path)
return Array.from(files).find((file) => file.path === path)
}

var PATTERN_LIST = {
Expand Down Expand Up @@ -71,10 +72,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

List = proxyquire('../../lib/file-list', {
Expand Down Expand Up @@ -201,10 +204,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

List = proxyquire('../../lib/file-list', {
Expand Down Expand Up @@ -238,10 +243,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

List = proxyquire('../../lib/file-list', {
Expand Down Expand Up @@ -430,10 +437,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

clock = sinon.useFakeTimers()
Expand Down Expand Up @@ -557,10 +566,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

clock = sinon.useFakeTimers()
Expand Down Expand Up @@ -664,10 +675,12 @@ describe('FileList', () => {
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

clock = sinon.useFakeTimers()
Expand Down Expand Up @@ -739,16 +752,18 @@ describe('FileList', () => {
beforeEach(() => {
patternList = PATTERN_LIST
mg = MG
Promise.setScheduler((fn) => fn())
Promise.setScheduler(function (fn) { fn() })

preprocess = sinon.spy((file, done) => process.nextTick(done))
emitter = new EventEmitter()

glob = {
Glob: (pattern, opts) => ({
found: patternList[pattern],
statCache: mg.statCache
})
Glob: function (pattern, opts) {
return {
found: patternList[pattern],
statCache: mg.statCache
}
}
}

modified = sinon.stub()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/helper.spec.js
@@ -1,4 +1,4 @@
import path from 'path'
var path = require('path')

describe('helper', () => {
var helper = require('../../lib/helper')
Expand Down
3 changes: 2 additions & 1 deletion test/unit/init.spec.js
@@ -1,4 +1,5 @@
import path from 'path'
var path = require('path')

describe('init', () => {
var loadFile = require('mocks').loadFile
var m = null
Expand Down
6 changes: 4 additions & 2 deletions test/unit/init/formatters.spec.js
@@ -1,4 +1,5 @@
import formatters from '../../../lib/init/formatters'
var formatters = require('../../../lib/init/formatters')

describe('init/formatters', () => {
var formatter

Expand All @@ -8,7 +9,8 @@ describe('init/formatters', () => {
})

describe('formatAnswers', () => {
var createAnswers = function (ans = {}) {
var createAnswers = function (ans) {
ans = ans || {}
ans.frameworks = ans.frameworks || []
ans.files = ans.files || []
ans.onlyServedFiles = ans.onlyServedFiles || []
Expand Down
2 changes: 1 addition & 1 deletion test/unit/init/state_machine.spec.js
@@ -1,4 +1,4 @@
import StateMachine from '../../../lib/init/state_machine'
var StateMachine = require('../../../lib/init/state_machine')

describe('init/StateMachine', () => {
var done
Expand Down

0 comments on commit 60dfc5c

Please sign in to comment.