Skip to content

Commit

Permalink
Infrastructure update. (#235)
Browse files Browse the repository at this point in the history
* Infrastructure update.
Use latest ESLint, Babel, Rollup.
Rename distr. bundle files to avoid common confusions.

* Dropping support of node 0.12

* Fix package.json pointer to the UMD build.

* Enable back an ESList rule ++
  • Loading branch information
koresar authored and FredyC committed Sep 22, 2016
1 parent 265c529 commit d4c35aa
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 76 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
@@ -1,12 +1,13 @@
// Add our overrides as necessary
{
"extends": "airbnb/base",
"extends": "airbnb-base",
"rules": {
"object-curly-spacing": [2, "never"],
"no-param-reassign": 0,
"comma-dangle": 0,
"no-confusing-arrow": 0,
"prefer-rest-params": 0,
"no-use-before-define": 1
"no-use-before-define": 1,
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }]
}
}
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "0.12"
- "4"
- "5"
- "6"
Expand Down
55 changes: 30 additions & 25 deletions build/index.js
Expand Up @@ -19,52 +19,53 @@ const moduleName = 'stampit';

function execute() {
return Promise.all([
makeBundle(
{
format: 'es6',
ext: '.mjs',
dest: 'dist',
moduleName: 'stampit'
}
),

// The main stampit distributable bundle. Meaning no other files needed
makeBundle(
{
format: 'cjs',
ext: '.js',
ext: '.full.js',
babelPlugins: es2015Plugins,
dest: 'dist',
moduleName: 'stampit'
}
),

// The UMD build for browsers
makeBundle(
{
format: 'cjs',
ext: '.es5.js',
format: 'umd',
ext: '.umd.js',
babelPlugins: es2015Plugins,
dest: 'dist',
moduleName: 'stampit'
}
),

// The minified UMD build for browsers
makeBundle(
{
format: 'umd',
ext: '.full.js',
ext: '.umd.min.js',
minify: true,
babelPlugins: es2015Plugins,
dest: 'dist',
moduleName: 'stampit'
}
),

// The experimental ES6 bundle
makeBundle(
{
format: 'umd',
ext: '.full.min.js',
minify: true,
babelPlugins: es2015Plugins,
format: 'es',
ext: '.mjs',
dest: 'dist',
moduleName: 'stampit'
}
),


// The "stampit/compose" file for direct importing
makeBundle(
{
format: 'cjs',
Expand All @@ -74,6 +75,7 @@ function execute() {
moduleName: 'compose'
}
),
// The "stampit/isStamp" file for direct importing
makeBundle(
{
format: 'cjs',
Expand All @@ -83,6 +85,7 @@ function execute() {
moduleName: 'isStamp'
}
),
// The "stampit/isComposable" file for direct importing
makeBundle(
{
format: 'cjs',
Expand Down Expand Up @@ -116,6 +119,14 @@ function defaultExport(opts = {}) {
}

function makeBundle(config) {
const outputConfig = {
dest: `${config.dest}/${config.moduleName}${config.ext}`,
format: config.format,
sourceMap: !config.minify,
moduleName: config.moduleName,
exports: 'named'
};

const isUMD = config.format === 'umd';
const isCJS = config.format === 'cjs';

Expand All @@ -138,7 +149,9 @@ function makeBundle(config) {

if (config.minify) {
inputConfig.plugins.push(uglify());
inputConfig.plugins.push(filesize());
inputConfig.plugins.push(filesize({
render: (opt, size, gzip) => `Estimating ${outputConfig.dest}: ${size}, GZIP : ${gzip}`
}));
}

if (isCJS) {
Expand All @@ -147,14 +160,6 @@ function makeBundle(config) {
}));
}

const outputConfig = {
dest: `${config.dest}/${config.moduleName}${config.ext}`,
format: config.format,
sourceMap: !config.minify,
moduleName: config.moduleName,
exports: 'named'
};

return rollup(inputConfig)
.then(bundle => bundle.write(outputConfig))
.then(() => console.log('created', outputConfig.dest));
Expand Down
26 changes: 13 additions & 13 deletions package.json
Expand Up @@ -6,9 +6,9 @@
"name": "Eric Elliott",
"url": "https://ericelliottjs.com"
},
"main": "dist/stampit.js",
"main": "dist/stampit.full.js",
"jsnext:main": "dist/stampit.mjs",
"browser": "dist/stampit.es5.js",
"browser": "dist/stampit.umd.js",
"keywords": [
"object",
"prototype",
Expand All @@ -32,8 +32,8 @@
"babel-plugin-check-es2015-constants": "^6.8.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.8.0",
"babel-plugin-transform-es2015-block-scoping": "^6.10.1",
"babel-plugin-transform-es2015-classes": "^6.9.0",
"babel-plugin-transform-es2015-block-scoping": "^6.15.0",
"babel-plugin-transform-es2015-classes": "^6.14.0",
"babel-plugin-transform-es2015-computed-properties": "^6.8.0",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-duplicate-keys": "^6.8.0",
Expand All @@ -48,27 +48,27 @@
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-es2015-typeof-symbol": "^6.8.0",
"babel-plugin-transform-es2015-unicode-regex": "^6.8.0",
"babel-plugin-transform-regenerator": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-plugin-transform-regenerator": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-runtime": "^6.9.2",
"check-compose": "^3.2.0",
"dependency-check": "^2.5.0",
"eslint": "^2.12.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.1",
"eslint": "^3.5.0",
"eslint-config-airbnb-base": "^7.1.0",
"eslint-plugin-import": "^1.15.0",
"isparta": "^4.0.0",
"lodash": "^4.11.1",
"lodash": "^4.16.1",
"magic-string": "^0.16.0",
"nsp": "^2.1.0",
"require-all": "^2.0.0",
"rimraf": "^2.3.4",
"rollup": "^0.31.2",
"rollup": "^0.36.0",
"rollup-plugin-babel": "^2.4.0",
"rollup-plugin-filesize": "^0.4.4",
"rollup-plugin-filesize": "^0.5.5",
"rollup-plugin-uglify": "^1.0.0",
"tap-dot": "^1.0.5",
"tape": "^4.2.2",
"watch": "^0.18.0"
"watch": "^0.19.2"
},
"scripts": {
"cov": "npm run cov:clean && npm run cov:generate",
Expand Down
1 change: 1 addition & 0 deletions src/compose.js
Expand Up @@ -2,6 +2,7 @@ import isFunction from './isFunction';
import isObject from './isObject';
import isComposable from './isComposable';
import merge from './merge';

const assign = Object.assign;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/stampit.js
@@ -1,14 +1,14 @@
import standardiseDescriptor from './standardise-descriptor';
import extractFunctions from './extract-functions';
import merge from './merge';
import compose from './compose';
import isComposable from './isComposable';
import isStamp from './isStamp';

export {compose};
export {isComposable};
export {isStamp};

import standardiseDescriptor from './standardise-descriptor';
import extractFunctions from './extract-functions';
import merge from './merge';

const assign = Object.assign;

/* Composition functions */
Expand Down
5 changes: 4 additions & 1 deletion test/.eslintrc
Expand Up @@ -4,6 +4,9 @@
"object-shorthand": 0,
"arrow-body-style": 0,
"func-names": 0,
"newline-per-chained-call": 0
"newline-per-chained-call": 0,
"no-prototype-builtins": 0,
"import/no-named-as-default-member": 0,
"import/no-extraneous-dependencies": 0
}
}
2 changes: 1 addition & 1 deletion test/basics-init.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics Enclose

Expand Down
2 changes: 1 addition & 1 deletion test/basics-methods.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics Methods

Expand Down
2 changes: 1 addition & 1 deletion test/basics-props.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics Props

Expand Down
2 changes: 1 addition & 1 deletion test/basics-refs.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics refs

Expand Down
2 changes: 1 addition & 1 deletion test/basics-static.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics statics

Expand Down
2 changes: 1 addition & 1 deletion test/basics.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Basics

Expand Down
6 changes: 3 additions & 3 deletions test/compose.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Compose

Expand All @@ -13,7 +13,7 @@ test('stampit().compose()', (t) => {
},
refs: {ref: false},
init() {
closuresCalled++;
closuresCalled += 1;
},
props: {prop: false}
});
Expand All @@ -25,7 +25,7 @@ test('stampit().compose()', (t) => {
},
refs: {ref: true},
init() {
closuresCalled++;
closuresCalled += 1;
},
props: {prop: true}
});
Expand Down
2 changes: 1 addition & 1 deletion test/convert-constructor.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Oldskool

Expand Down
2 changes: 1 addition & 1 deletion test/deep-props-safety.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Props safety

Expand Down
2 changes: 1 addition & 1 deletion test/immutability.js
@@ -1,5 +1,5 @@
import stampit from '../src/stampit';
import test from 'tape';
import stampit from '../src/stampit';

// Immutability

Expand Down
4 changes: 2 additions & 2 deletions test/import.js
@@ -1,10 +1,10 @@
/* eslint-disable */
import test from 'tape';

import stampit1 from '../dist/stampit';
import stampit1 from '../';

test('import is the same as require', (t) => {
const stampit2 = require('../dist/stampit');
const stampit2 = require('../');

t.equal(stampit1, stampit2,
'Should export same object for both ES6 and CommonJS');
Expand Down
6 changes: 3 additions & 3 deletions test/infected-statics.js
@@ -1,6 +1,6 @@
import stampit from '../src/stampit';
import test from 'tape';
import _ from 'lodash';
import stampit from '../src/stampit';

// stampit().methods, stampit.refs, stampit.init, stampit.props, etc

Expand Down Expand Up @@ -74,10 +74,10 @@ test('stampit().staticPropertyDescriptors static method', (t) => {
t.end();
});

test('stampit() can be infected', t => {
test('stampit() can be infected', (t) => {
let counter = 0;
const infectedStampit = function (...args) {
counter++;
counter += 1;
args.push({
staticProperties: {
compose: infectedStampit
Expand Down

0 comments on commit d4c35aa

Please sign in to comment.