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

Babel MVP #143

Merged
merged 4 commits into from
Dec 7, 2017
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
41 changes: 41 additions & 0 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"rollup": "^0.50.0",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-node-resolve": "^3.0.0",
"standard": "^10.0.3"
"rollup-plugin-uglify": "^2.0.1",
"standard": "^10.0.3",
"uglify-es": "^3.2.0",
"uglify-js": "^3.2.0"
},
"standard": {
"parser": "babel-eslint",
Expand Down
5 changes: 4 additions & 1 deletion examples/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import node from 'rollup-plugin-node-resolve'
import flow from 'rollup-plugin-flow'
import uglify from 'rollup-plugin-uglify'
import { minify } from 'uglify-es'

export default {
plugins: [
flow(),
node()
node(),
uglify({}, minify)
],
output: {
format: 'iife',
Expand Down
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
"author": "brian@hovercraftstudios.com",
"license": "MIT",
"devDependencies": {
"lerna": "^2.5.1"
"@briancavalier/assert": "^3.2.0",
"babel-core": "^6.26.0",
"babel-plugin-annotate-pure-calls": "^0.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"cpy-cli": "^1.0.1",
"cross-env": "^5.0.5",
"flow-bin": "^0.57.3",
"lerna": "^2.5.1",
"mocha": "^3.4.2",
"nyc": "^11.0.2",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"sinon": "^1.17.7",
"snazzy": "^7.0.0",
"standard": "^10.0.3",
"uglify-js": "^2.7.5"
}
}
5 changes: 5 additions & 0 deletions packages/core/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in babel7 (soon-ish) it will be possible to use .babelrc.js directly and therefore omit those .babelrc entirely

"presets": [
"./.babelrc.js"
]
}
14 changes: 14 additions & 0 deletions packages/core/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false

module.exports = {
presets: [
['env', {
modules,
loose: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forceAllTransforms: true

Copy link
Contributor Author

@Andarist Andarist Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was thinking about it, but aint sure if there is any benefit in that if we do not provide non-default targets, thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's same target like uplify before. At least if defaults will be changed then nothing will be broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's same target like uplify before.

Just a confirmation - that's exactly what it is

At least if defaults will be changed then nothing will be broken.

Good point, gonna add this later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant semantically the same too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I understanding forceAllTransforms correctly in that it essentially causes babel-preset-env to behave like babel-preset-es2015?

Copy link
Contributor Author

@Andarist Andarist Oct 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda, its job is to output pure es5 which can be ofc understood by subsequent tools (like uglifyjs)

Preset2015 has only es2015 plugins in it, but preset-env has also plugins from other yearly presets and also it has (or soon it will, aint sure) shipped proposals plugins (like when browsers implement language features from stage 3 or something).

forceAllTransforms: true
}]
],
plugins: [
'annotate-pure-calls'
]
}
11 changes: 8 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"test": "npm run test:lint && npm run test:unit && npm run test:flow",
"test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot --recursive 'test/**/*-test.js'",
"test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot --recursive 'test/**/*-test.js'",
"test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy",
"test:flow": "flow check",
"build": "npm run build:dist && npm run build:flow",
Expand Down Expand Up @@ -39,13 +39,18 @@
"license": "MIT",
"devDependencies": {
"@briancavalier/assert": "^3.2.0",
"buba": "^4.0.2",
"babel-core": "^6.26.0",
"babel-plugin-annotate-pure-calls": "^0.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"cpy-cli": "^1.0.1",
"cross-env": "^5.0.5",
"flow-bin": "^0.57.3",
"mocha": "^3.4.2",
"nyc": "^11.0.2",
"rollup": "^0.50.0",
"rollup-plugin-buble": "^0.16.0",
"rollup-plugin-babel": "^3.0.2",
"sinon": "^1.17.7",
"snazzy": "^7.0.0",
"standard": "^10.0.3"
Expand Down
7 changes: 5 additions & 2 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import buble from 'rollup-plugin-buble'
import babel from 'rollup-plugin-babel'
import pkg from './package.json'

export default {
input: 'src/index.js',
plugins: [
buble()
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
})
],
external: [
'@most/scheduler',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/chain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {chain, fromArray} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/concatMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, concatMap} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/filter-map-reduce.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {map, filter, fromArray} = require('../../src/index');
const {reduce} = require('../../test/helper/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/merge-nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, merge: _merge} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/merge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, mergeArray} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
},
"dependencies": {
"@reactivex/rxjs": "^5.0.1",
"babel-register": "^6.26.0",
"baconjs": "^0.7.89",
"benchmark": "github:bestiejs/benchmark.js#master",
"buba": "^4.0.1",
"highland": "^2.10.1",
"kefir": "^3.6.1",
"rx": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/scan.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, scan} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/skipRepeats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, skipRepeats} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/slice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, skip, take} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/switch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, map, switchLatest} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/perf/zip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('buba/register')
require('babel-register')
const Benchmark = require('benchmark');
const {fromArray, zip} = require('.././index');
const {reduce} = require('.././combinator/reduce')
Expand Down
5 changes: 5 additions & 0 deletions packages/disposable/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"./.babelrc.js"
]
}
14 changes: 14 additions & 0 deletions packages/disposable/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false

module.exports = {
presets: [
['env', {
modules,
loose: true,
forceAllTransforms: true
}]
],
plugins: [
'annotate-pure-calls'
]
}
11 changes: 8 additions & 3 deletions packages/disposable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"test": "npm run test:lint && npm run test:unit && npm run test:flow",
"test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot --recursive 'test/**/*-test.js'",
"test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot --recursive 'test/**/*-test.js'",
"test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy",
"test:flow": "flow check",
"build": "npm run build:dist && npm run build:flow",
Expand Down Expand Up @@ -39,13 +39,18 @@
"license": "MIT",
"devDependencies": {
"@briancavalier/assert": "^3.2.0",
"buba": "^4.0.2",
"babel-core": "^6.26.0",
"babel-plugin-annotate-pure-calls": "^0.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"cpy-cli": "^1.0.1",
"cross-env": "^5.0.5",
"flow-bin": "^0.57.3",
"mocha": "^3.4.2",
"nyc": "^11.0.2",
"rollup": "^0.50.0",
"rollup-plugin-buble": "^0.16.0",
"rollup-plugin-babel": "^3.0.2",
"sinon": "^1.17.7",
"snazzy": "^7.0.0",
"standard": "^10.0.3"
Expand Down
7 changes: 5 additions & 2 deletions packages/disposable/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import buble from 'rollup-plugin-buble'
import babel from 'rollup-plugin-babel'
import pkg from './package.json'

export default {
input: 'src/index.js',
plugins: [
buble()
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
})
],
external: [
'@most/prelude'
Expand Down
19 changes: 9 additions & 10 deletions packages/disposable/src/disposeAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,24 @@ const throwIfErrors = errors => {
}
}

// Aggregate Error type for DisposeAll
export class DisposeAllError extends Error {
constructor (message, errors) {
super(message)
export const DisposeAllError = (Error => {
function DisposeAllError (message, errors) {
Error.call(this, message)
this.message = message
this.name = this.constructor.name
this.name = DisposeAllError.name
this.errors = errors

if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
Error.captureStackTrace(this, DisposeAllError)
}

this.stack = `${this.stack}${formatErrorStacks(this.errors)}`
}

toString () {
return this.stack
}
}
DisposeAllError.prototype = Object.create(Error.prototype)

return DisposeAllError
})(Error)

const formatErrorStacks = errors =>
reduce(formatErrorStack, '', errors)
Expand Down
5 changes: 5 additions & 0 deletions packages/prelude/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"./.babelrc.js"
]
}
14 changes: 14 additions & 0 deletions packages/prelude/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false

module.exports = {
presets: [
['env', {
modules,
loose: true,
forceAllTransforms: true
}]
],
plugins: [
'annotate-pure-calls'
]
}