diff --git a/.eslintrc b/.eslintrc
index bf88a35..b50e89e 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -2,7 +2,7 @@
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
- "node": true,
+ "browser": true,
"mocha": true
}
-}
\ No newline at end of file
+}
diff --git a/.travis.yml b/.travis.yml
index d96bef9..986b314 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,3 +2,9 @@ language: node_js
node_js:
- "4.0"
- "5.0"
+cache:
+ directories:
+ - node_modules
+env:
+ global:
+ - NPM_CONFIG_PROGRESS="false"
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..ebbbe84
--- /dev/null
+++ b/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+ Sample project for packages built with rollup
+
+
+
+
+
+
+
diff --git a/karma.conf.js b/karma.conf.js
new file mode 100644
index 0000000..9739444
--- /dev/null
+++ b/karma.conf.js
@@ -0,0 +1,98 @@
+// Karma configuration
+// Generated on Sun Feb 05 2017 11:15:12 GMT+1100 (AEDT)
+var babel = require('rollup-plugin-babel');
+var babelrc = require('babelrc-rollup').default;
+var globals = require('rollup-plugin-node-globals');
+var builtins = require('rollup-plugin-node-builtins');
+var resolve = require('rollup-plugin-node-resolve');
+var istanbul = require('rollup-plugin-istanbul');
+
+var pkg = require('./package.json');
+var external = Object.keys(pkg.dependencies);
+var testFiles = [
+ 'test/**/*_test.js'
+];
+
+module.exports = function(config) {
+ config.set({
+
+ // base path that will be used to resolve all patterns (eg. files, exclude)
+ basePath: '',
+
+
+ // frameworks to use
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: ['mocha'],
+
+ client: { mocha: { reporter: './istanbul.reporter.js' } },
+
+ // list of files / patterns to load in the browser
+ files: testFiles,
+
+
+ // list of files to exclude
+ exclude: [
+ ],
+
+
+ // preprocess matching files before serving them to the browser
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: {
+ 'test/**/*_test.js': ['rollup']
+ },
+
+ rollupPreprocessor: {
+ plugins: [
+ babel(babelrc()),
+ globals(),
+ builtins(),
+ resolve({
+ jsnext: true
+ }),
+ istanbul({
+ exclude: testFiles.concat([ 'node_modules/**/*' ])
+ })
+ ],
+ external: external,
+ format: 'iife',
+ sourceMap: 'inline'
+ },
+
+
+ // test results reporter to use
+ // possible values: 'dots', 'progress'
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['progress', 'coverage'],
+
+
+ // web server port
+ port: 9876,
+
+
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+
+
+ // level of logging
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+
+
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: false,
+
+
+ // start these browsers
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: ['PhantomJS'],
+
+
+ // Continuous Integration mode
+ // if true, Karma captures browsers, runs the tests and exits
+ singleRun: true,
+
+ // Concurrency level
+ // how many browser should be started simultaneous
+ concurrency: Infinity
+ })
+}
diff --git a/lib/index.js b/lib/index.js
index bd702c4..dd820bf 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -37,3 +37,5 @@ export function multiply(n, m, negative=false) {
}
return negative ? -result : result;
}
+
+document.write(multiply(11, 9));
diff --git a/package.json b/package.json
index 2adcb40..cc749a3 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,12 @@
"build": "rollup -c",
"watch": "rollup -c -w",
"pretest": "npm run build",
- "test": "mocha",
- "prepublish": "npm test"
+ "test": "karma start",
+ "preuglify": "npm test",
+ "uglify": "cd dist && uglifyjs rollup-starter-project.js --output rollup-starter-project.min.js --source-map rollup-starter-project.min.js.map --in-source-map rollup-starter-project.js.map --compress --mangle",
+ "prepublish": "npm run uglify",
+ "prestart": "npm install",
+ "start": "ws"
},
"repository": "rollup/rollup-starter-project",
"keywords": [
@@ -39,11 +43,20 @@
"babel-register": "^6.18.0",
"babelrc-rollup": "^3.0.0",
"eslint": "^3.12.2",
- "istanbul": "^0.4.5",
+ "karma": "^1.4.1",
+ "karma-coverage": "^1.1.1",
+ "karma-mocha": "^1.3.0",
+ "karma-phantomjs-launcher": "^1.0.2",
+ "karma-rollup-plugin": "^0.2.4",
+ "local-web-server": "^1.2.6",
"mocha": "^3.2.0",
"rollup": "^0.37.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-istanbul": "^1.1.0",
- "rollup-watch": "^2.5.0"
+ "rollup-plugin-node-builtins": "^2.0.0",
+ "rollup-plugin-node-globals": "^1.1.0",
+ "rollup-plugin-node-resolve": "^2.0.0",
+ "rollup-watch": "^2.5.0",
+ "uglify-js": "^2.7.5"
}
}
diff --git a/rollup.config.js b/rollup.config.js
index 056d1a8..e5357b8 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,6 +1,5 @@
import babel from 'rollup-plugin-babel';
import babelrc from 'babelrc-rollup';
-import istanbul from 'rollup-plugin-istanbul';
let pkg = require('./package.json');
let external = Object.keys(pkg.dependencies);
@@ -8,10 +7,7 @@ let external = Object.keys(pkg.dependencies);
export default {
entry: 'lib/index.js',
plugins: [
- babel(babelrc()),
- istanbul({
- exclude: ['test/**/*', 'node_modules/**/*']
- })
+ babel(babelrc())
],
external: external,
targets: [
diff --git a/test/index_test.js b/test/index_test.js
index 13cc432..e041bfc 100644
--- a/test/index_test.js
+++ b/test/index_test.js
@@ -1,4 +1,4 @@
-import { multiply } from '../';
+import { multiply } from '../lib/index.js';
import { strictEqual } from 'assert';
describe('multiply', () => {
diff --git a/test/istanbul.reporter.js b/test/istanbul.reporter.js
deleted file mode 100644
index 5022b61..0000000
--- a/test/istanbul.reporter.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const instanbul = require('istanbul');
-const MochaSpecReporter = require('mocha/lib/reporters/spec');
-
-module.exports = function (runner) {
- const collector = new instanbul.Collector();
- const reporter = new instanbul.Reporter();
- reporter.addAll(['lcov', 'json']);
- new MochaSpecReporter(runner);
-
- runner.on('end', function () {
- collector.add(global.__coverage__);
-
- reporter.write(collector, true, function () {
- process.stdout.write('report generated');
- });
- });
-};
diff --git a/test/mocha.opts b/test/mocha.opts
deleted file mode 100644
index d17f083..0000000
--- a/test/mocha.opts
+++ /dev/null
@@ -1 +0,0 @@
---reporter test/istanbul.reporter.js --recursive --compilers js:babel-register