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

chore(build): Reworks babel build #163

Merged
merged 3 commits into from
Aug 7, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
coverage
dist
lib
13 changes: 0 additions & 13 deletions .npmignore

This file was deleted.

19 changes: 16 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ os:
- osx
node_js:
- node
- "6"
- "5"
- "4"

script: npm test
env:
- export WEBPACK_VERSION="2.1.0-beta"
- export WEBPACK_VERSION="1.13.0"
matrix:
fast_finish: true
before_install:
- nvm --version
- node --version
- npm --version
before_script:
- 'if [ "$WEBPACK_VERSION" ]; then npm install webpack@^$WEBPACK_VERSION; fi'
script:
- npm run build
- npm test
after_success:
- bash <(curl -s https://codecov.io/bash)
69 changes: 69 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict' // eslint-disable-line strict

const gulp = require('gulp')
const del = require('del')
const util = require('gulp-util')
const eslint = require('gulp-eslint')
const babel = require('gulp-babel')

gulp.task('clean', function(done) {
del([
'lib/**/*',
])
done()
})

/**
* Lints all the JavaScript in the project.
* Ignores transpiled code & node_modules.
*/
gulp.task('lint', function(done) {
gulp.src(['**/*.js', '!node_modules/**', '!lib/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
done()
})

/**
* Transpiles with Babel based on defined presets.
*/
gulp.task('build', function(done) {
gulp.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'))
done()
})

/**
* Watches for changes in the src directory.
* "on change" transpiles incrementally.
* "on unlink" removes the transpiled version of the deleted file.
*/
gulp.task('watch', function() {
gulp.watch('src/**/*.js')
.on('change', function(path) {
gulp.src(path)
.pipe(babel())
.pipe(gulp.dest('lib'))
util.log(`File "${path}" rebuilt`)
})
.on('unlink', function(path) {
util.log(`File "${path}" removed`)
let filePathFromSrc = path.relative(path.resolve('src'))
let destFilePath = path.resolve('build', filePathFromSrc)

del.sync(destFilePath)
})
})

/**
* Entrypoint for running watch.
*/
gulp.task('build.watch', gulp.series('build', 'watch', function(done) {
done()
}))

gulp.task('default', gulp.series('clean', 'lint', 'build', function(done) {
done()
}))
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = require('./lib/karma-webpack')
26 changes: 18 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@
"description": "Use webpack with karma",
"license": "MIT",
"homepage": "http://github.com/webpack/karma-webpack",
"main": "dist/karma-webpack.js",
"scripts": {
"lint": "eslint test src",
"gulp": "gulp",
"lint": "gulp lint",
"clean": "gulp clean",
"pretest": "npm run lint",
"test": "npm run test.unit",
"test.unit": "mocha --compilers js:babel-register --full-trace --check-leaks test/unit",
"test.integration": "npm run build && karma start --single-run",
"travis": "npm run test.unit && npm run test.integration",
"generate.changelog": "node scripts/release/generate-changelog.js",
"publish.version": "npm run build:dist && sh scripts/release/npm-publish.sh",
"build:dev": "webpack",
"build:dist": "cross-env NODE_ENV=production webpack"
"publish.version": "npm run build && sh scripts/release/npm-publish.sh",
"build:watch": "gulp build.watch",
"build": "gulp build"
},
"files": [
"lib",
"index.js"
],
"repository": {
"type": "git",
"url": "https://github.com/webpack/karma-webpack.git"
},
"peerDependencies": {
"webpack": "^1.4.0 || ^2 || ^2.1.0-beta"
"webpack": "^1.1.0 || ^2 || ^2.1.0-beta"
},
"dependencies": {
"async": "~0.9.0",
Expand All @@ -47,16 +52,21 @@
"conventional-changelog": "^1.1.0",
"cross-env": "^2.0.0",
"cz-conventional-changelog": "^1.1.6",
"del": "^2.2.1",
"eslint": "^3.1.1",
"eslint-plugin-babel": "^3.3.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-babel": "^6.1.2",
"gulp-eslint": "^3.0.1",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.9",
"istanbul": "^0.4.4",
"json-loader": "^0.5.4",
"karma": "^1.x",
"karma-chrome-launcher": "~1.0.1",
"karma-mocha": "~1.1.1",
"karma-spec-reporter": "~0.0.22",
"mocha": "^2.5.3",
"webpack": "^2.1.0-beta.20"
"mocha": "^2.5.3"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

*The NPM Portion*
* `npm login` to the user with rights to publish to NPM
* `npm run publish.version` which executes a `dist` build and publishes using the tag created above.
* `npm run publish.version` which executes the build and publishes using the tag created above.
47 changes: 0 additions & 47 deletions webpack.config.babel.js

This file was deleted.