diff --git a/README.md b/README.md index 33122af6e..9e3c53b5a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ Your `package.json` should have the following entries. ```json -"main": "lib/index.js", -"jsnext:main": "src/index.js", +"main": "src/index.js", "scripts": { "lint": "aegir-lint", "release": "aegir-release", @@ -35,13 +34,10 @@ Your `package.json` should have the following entries. } ``` -You should also add `babel-runtime` to your `dependencies` as it is required by the babelified version in `lib`. - ## Stack Requirements To bring you its many benefits, `aegir` requires -- [ES6 / Babel](https://github.com/babel/babel) transpilation - JS written in [Standard](https://github.com/feross/standard) style - Tests written in [Mocha](https://github.com/mochajs/mocha) - [Karma](https://github.com/karma-runner/karma) for browser tests @@ -111,8 +107,6 @@ https://unpkg.com//dist/index.js https://unpkg.com//dist/index.min.js ``` -There is also an ES5 build that will be placed in `lib` that will be required by default from consumers using `require`. - You can run it using ```bash diff --git a/config/babel.js b/config/babel.js deleted file mode 100644 index 10bb88b29..000000000 --- a/config/babel.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict' - -module.exports = { - presets: [require.resolve('babel-preset-es2015')] -} diff --git a/config/karma.conf.js b/config/karma.conf.js index 467cbceb9..f5566d516 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -1,21 +1,76 @@ 'use strict' -const path = require('path') const webpackConfig = require('./webpack') const timeout = require('./custom').timeout -const browsers = [] +let concurrency = 1 +let reporters = ['mocha-own'] + +const launchers = { + sl_chrome: { + base: 'SauceLabs', + browserName: 'Chrome', + platform: 'Windows 10', + version: '53' + }, + sl_firefox: { + base: 'SauceLabs', + browserName: 'Firefox', + platform: 'Windows 10', + version: '48' + }, + sl_safari: { + base: 'SauceLabs', + browserName: 'Safari', + platform: 'OS X 10.11', + version: 'latest' + }, + sl_ie_11: { + base: 'SauceLabs', + browserName: 'Internet Explorer', + platform: 'Windows 10', + version: '11' + }, + sl_edge: { + base: 'SauceLabs', + browserName: 'MicrosoftEdge', + platform: 'Windows 10', + version: '14.14393' + }, + sl_android: { + base: 'SauceLabs', + browserName: 'Browser', + deviceName: 'Android Emulator', + platformName: 'Android', + appiumVersion: '1.5.3', + platformVersion: '5.1', + deviceOrientation: 'portrait' + }, + sl_iphone: { + base: 'SauceLabs', + browserName: 'Safari', + deviceName: 'iPhone Simulator', + platformName: 'iOS', + platformVersion: '9.3', + appiumVersion: '1.5.3', + deviceOrientation: 'portrait' + } +} + +let browsers = [] if (process.env.TRAVIS) { - browsers.push('Firefox') + if (process.env.SAUCE_USERNAME) { + browsers = Object.keys(launchers) + concurrency = 3 + reporters = ['progress', 'saucelabs'] + } else { + browsers.push('Firefox') + } } else { browsers.push('Chrome') } -if (!process.env.DEBUG && process.env.PHANTOM !== 'off') { - browsers.push('PhantomJS') -} - module.exports = function (config) { config.set({ basePath: process.cwd(), @@ -26,7 +81,6 @@ module.exports = function (config) { } }, files: [ - path.join(require.resolve('babel-polyfill'), '/../../dist/polyfill.js'), 'test/browser.js', 'test/**/*.spec.js' ], @@ -38,7 +92,7 @@ module.exports = function (config) { webpackMiddleware: { noInfo: true }, - reporters: ['mocha-own'], + reporters: reporters, mochaOwnReporter: { reporter: 'spec' }, @@ -47,8 +101,9 @@ module.exports = function (config) { logLevel: process.env.DEBUG ? config.LOG_DEBUG : config.LOG_INFO, autoWatch: false, browsers: browsers, + customLaunchers: launchers, singleRun: false, - concurrency: 1, + concurrency: concurrency, browserNoActivityTimeout: timeout, failOnEmptyTestSuite: false }) diff --git a/config/webpack.js b/config/webpack.js index eab87579e..1032e0591 100644 --- a/config/webpack.js +++ b/config/webpack.js @@ -1,10 +1,10 @@ 'use strict' -const webpack = require('webpack') const path = require('path') const upperFirst = require('lodash.upperfirst') const camelCase = require('lodash.camelcase') const merge = require('webpack-merge') +const webpack = require('webpack') const pkg = require(path.resolve('package.json')) let customConfig = {} @@ -12,7 +12,6 @@ try { customConfig = require(path.resolve('.aegir.js')) } catch (err) { } -const babel = require('./babel') // e.g. peer-id -> PeerId const libraryName = upperFirst(camelCase(pkg.name)) @@ -32,7 +31,6 @@ const specific = merge(custom1, custom2) const shared = { entry: [ - require.resolve('babel-polyfill'), path.resolve('src/index.js') ], output: { @@ -44,11 +42,7 @@ const shared = { modules: [ 'node_modules', path.resolve(__dirname, '../node_modules') - ], - alias: { - http: require.resolve('stream-http'), - https: require.resolve('https-browserify') - } + ] }, resolveLoader: { modules: [ @@ -58,68 +52,15 @@ const shared = { }, module: { loaders: [{ - test: /\.js$/, - exclude: /node_modules|vendor/, - loader: 'babel', - query: babel - }, { - test: /\.js$/, - include: /node_modules\/(hoek|qs|wreck|boom|ipfs|promisify-es|whatwg-fetch|node-fetch|isomorphic-fetch|db\.js)/, - loader: 'babel', - query: babel - }, { - test: /\.js$/, - include: /node_modules\/cbor/, - loader: 'babel', - query: { - plugins: [ - // All things supported by node >= 4.0 - 'babel-plugin-transform-es2015-template-literals', - 'babel-plugin-transform-es2015-literals', - 'babel-plugin-transform-es2015-function-name', - 'babel-plugin-transform-es2015-arrow-functions', - 'babel-plugin-transform-es2015-block-scoped-functions', - 'babel-plugin-transform-es2015-classes', - 'babel-plugin-transform-es2015-object-super', - 'babel-plugin-transform-es2015-shorthand-properties', - 'babel-plugin-transform-es2015-duplicate-keys', - 'babel-plugin-transform-es2015-computed-properties', - 'babel-plugin-transform-es2015-for-of', - // 'babel-plugin-transform-es2015-sticky-regex', - // 'babel-plugin-transform-es2015-unicode-regex', - 'babel-plugin-check-es2015-constants', - // 'babel-plugin-transform-es2015-spread', - // 'babel-plugin-transform-es2015-parameters', - // 'babel-plugin-transform-es2015-destructuring', - 'babel-plugin-transform-es2015-block-scoping', - 'babel-plugin-transform-es2015-typeof-symbol', - // 'babel-plugin-transform-es2015-modules-commonjs', - 'babel-plugin-transform-regenerator' - ].map((p) => require.resolve(p)) - } - }, { test: /\.json$/, loader: 'json' - }, { - test: /\.js$/, - loader: 'transform?brfs', - enforce: 'pre' }] }, - externals: { - net: '{}', - fs: '{}', - tls: '{}', - console: '{}', - 'require-dir': '{}', - ursa: '{}' - }, node: { Buffer: true }, - plugins: [ - new webpack.DefinePlugin({'fs.writeSync': false}) - ] + plugins: [], + target: 'web' } const dev = merge(shared, { diff --git a/package.json b/package.json index 9c3b55f35..03185e6c7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ }, "keywords": [ "webpack", - "babel", "standard", "lint", "build" @@ -25,25 +24,19 @@ "license": "MIT", "dependencies": { "args-parser": "^1.0.2", - "babel-core": "^6.14.0", - "babel-loader": "^6.2.5", - "babel-polyfill": "^6.13.0", - "babel-preset-es2015": "^6.14.0", - "brfs": "^1.4.3", "chalk": "^1.1.3", "conventional-github-releaser": "^1.1.3", "coveralls": "^2.11.14", - "eslint": "^3.6.0", - "eslint-config-standard": "^6.1.0", - "eslint-plugin-promise": "^3.0.0", - "eslint-plugin-standard": "^2.0.0", + "eslint": "^3.8.1", + "eslint-config-standard": "^6.2.1", + "eslint-plugin-promise": "^3.3.0", + "eslint-plugin-standard": "^2.0.1", "gulp": "^3.9.1", - "gulp-babel": "^6.1.2", "gulp-bump": "^2.4.0", "gulp-conventional-changelog": "^1.1.0", "gulp-eslint": "^3.0.1", "gulp-filter": "^4.0.0", - "gulp-git": "^1.11.3", + "gulp-git": "^1.12.0", "gulp-mocha": "^3.0.1", "gulp-rename": "^1.2.2", "gulp-size": "^2.1.0", @@ -57,32 +50,33 @@ "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-firefox-launcher": "^1.0.0", - "karma-mocha": "^1.1.1", + "karma-mocha": "^1.2.0", "karma-mocha-own-reporter": "^1.1.2", - "karma-phantomjs-launcher": "^1.0.2", + "karma-sauce-launcher": "^1.1.0", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^1.8.0", "lodash.camelcase": "^4.3.0", "lodash.includes": "^4.3.0", "lodash.upperfirst": "^4.3.1", - "mocha": "^3.0.2", - "phantomjs-prebuilt": "^2.1.12", + "mocha": "^3.1.2", "pretty-hrtime": "^1.0.2", + "pump": "^1.0.1", "rimraf": "^2.5.4", "run-sequence": "^1.2.2", "semver": "^5.3.0", "signal-exit": "^3.0.1", "stream-http": "^2.4.0", "transform-loader": "^0.2.3", + "uglify-js": "github:mishoo/UglifyJS2#harmony", "webpack": "^2.1.0-beta.25", - "webpack-merge": "^0.14.1" + "webpack-merge": "^0.15.0" }, "repository": { "type": "git", "url": "https://github.com/dignifiedquire/aegir" }, "engines": { - "node": ">=4.2.2" + "node": ">=4.0.0" }, "contributors": [ "David Dias ", @@ -92,4 +86,4 @@ "Stephen Whitmore ", "npmcdn-to-unpkg-bot " ] -} \ No newline at end of file +} diff --git a/tasks/build.js b/tasks/build.js index 17b540b59..6c8230963 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -5,5 +5,5 @@ module.exports = (gulp) => { require('./build/browser')(gulp) require('./clean')(gulp) - gulp.task('build', ['build:browser', 'build:node']) + gulp.task('build', ['build:browser']) } diff --git a/tasks/build/browser.js b/tasks/build/browser.js index f0839317d..830985f11 100644 --- a/tasks/build/browser.js +++ b/tasks/build/browser.js @@ -3,10 +3,12 @@ module.exports = (gulp) => { gulp.task('build:browser', ['clean:browser'], (done) => { const webpack = require('webpack') - const uglify = require('gulp-uglify') + const minifier = require('gulp-uglify/minifier') const util = require('gulp-util') const size = require('gulp-size') const rename = require('gulp-rename') + const uglify = require('uglify-js') + const pump = require('pump') const config = require('../../config/webpack') @@ -18,16 +20,17 @@ module.exports = (gulp) => { ) webpack(c, webpackDone(() => { - gulp.src('dist/index.js') - .pipe(uglify({ + pump([ + gulp.src('dist/index.js'), + minifier({ mangle: false - })) - .pipe(rename({ + }, uglify), + rename({ suffix: '.min' - })) - .pipe(size()) - .pipe(gulp.dest('dist')) - .once('end', done) + }), + size(), + gulp.dest('dist') + ], done) })) function webpackDone (done) { diff --git a/tasks/build/node.js b/tasks/build/node.js index 95cc28e21..46b85809f 100644 --- a/tasks/build/node.js +++ b/tasks/build/node.js @@ -1,31 +1,7 @@ 'use strict' -const size = require('gulp-size') - module.exports = (gulp) => { - gulp.task('copy::node', () => { - return gulp.src('src/**/*') - .pipe(size()) - .pipe(gulp.dest('lib')) - }) - - gulp.task('build::node', () => { - const babel = require('gulp-babel') - const config = require('../../config/babel') - - return gulp.src('lib/**/*.js') - .pipe(babel(config)) - .pipe(size()) - .pipe(gulp.dest('lib')) - }) - - gulp.task('build:node', ['clean:node'], (done) => { - const runSequence = require('run-sequence') - - runSequence.use(gulp)( - 'copy::node', - 'build::node', - done - ) + gulp.task('build:node', () => { + throw new Error('node builds are not supported anymore') }) } diff --git a/tasks/clean.js b/tasks/clean.js index 804ae70ec..024d96229 100644 --- a/tasks/clean.js +++ b/tasks/clean.js @@ -1,6 +1,5 @@ 'use strict' module.exports = (gulp) => { - require('./clean/node')(gulp) require('./clean/browser')(gulp) } diff --git a/tasks/clean/node.js b/tasks/clean/node.js deleted file mode 100644 index 0fb283d5c..000000000 --- a/tasks/clean/node.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict' - -const rimraf = require('rimraf') - -module.exports = (gulp) => { - gulp.task('clean:node', (done) => { - rimraf('./lib', done) - }) -} diff --git a/tasks/release/node.js b/tasks/release/node.js index cb0e8797c..57be8d53e 100644 --- a/tasks/release/node.js +++ b/tasks/release/node.js @@ -14,7 +14,6 @@ module.exports = (gulp) => { gulp.task('release:node', (done) => { runSequence.use(gulp)( 'release:pre-build:node', - 'build:node', 'release:post-build', done ) diff --git a/tasks/test/browser.js b/tasks/test/browser.js index b1700fd17..11dc4f92c 100644 --- a/tasks/test/browser.js +++ b/tasks/test/browser.js @@ -8,10 +8,16 @@ const utils = require('../../src/utils') module.exports = (gulp) => { gulp.task('karma', (done) => { const debug = process.env.DEBUG + const sauce = process.env.SAUCE_USERNAME && process.env.TRAVIS + new Server({ - configFile: path.join(__dirname, '/../../config/karma.conf.js'), + configFile: path.join(__dirname, '../../config/karma.conf.js'), singleRun: !debug }, (code) => { + if (sauce) { + // don't fail on saucelabs tests + return done() + } done(code > 0 ? 'Some tests are failing' : undefined) }).start() })