Skip to content

Commit

Permalink
Migrate to ES modules
Browse files Browse the repository at this point in the history
- Replaced browserify with rollup
- Replaced AMD modules with ES modules
- Updated Karma config to use rollup
  • Loading branch information
chrisn committed Jun 24, 2021
1 parent e6a10f3 commit 5143a52
Show file tree
Hide file tree
Showing 56 changed files with 13,909 additions and 13,078 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module.exports = {
'root': true,
'env': {
'browser': true,
'amd': true
'browser': true
},
'parserOptions': {
'ecmaVersion': 2015,
'sourceType': 'module'
},
'extends': 'eslint:recommended',
'rules': {
Expand Down
4 changes: 4 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env"],
"plugins": []
}
50 changes: 32 additions & 18 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';
/* eslint-env node */

var istanbul = require('browserify-istanbul');
var commonjs = require('rollup-plugin-commonjs');
var resolve = require('rollup-plugin-node-resolve');
var babel = require('@rollup/plugin-babel');
var json = require('@rollup/plugin-json');
var istanbul = require('rollup-plugin-istanbul');

function filterBrowsers(browsers, re) {
return Object.keys(browsers).filter(function(key) {
Expand All @@ -11,15 +15,14 @@ function filterBrowsers(browsers, re) {

module.exports = function(config) {
var isCI = Boolean(process.env.CI) && Boolean(process.env.BROWSER_STACK_ACCESS_KEY);
var glob = config.glob || '**/*.js';

// Karma configuration
config.set({
// The root path location that will be used to resolve all relative paths
// defined in 'files' and 'exclude'.
basePath: '',

frameworks: ['browserify', 'mocha', 'chai-sinon'],
frameworks: ['mocha', 'chai-sinon'],

client: {
chai: {
Expand All @@ -30,31 +33,42 @@ module.exports = function(config) {
}
},

browserify: {
debug: true,
transform: [
istanbul({
ignore: [
'test/unit/*.js'
]
}),
'deamdify'
]
},

// list of files / patterns to load in the browser
files: [
{ pattern: 'test/test_img/*', included: false },
{ pattern: 'test_data/*', included: false },
{ pattern: 'test/unit/' + glob, included: true }
{ pattern: 'test/unit/tests.js', type: 'module', included: true }
],

mime: {
'application/octet-stream': ['dat']
},

preprocessors: {
'test/unit/*.js': ['browserify']
'test/unit/tests.js': ['rollup']
},

rollupPreprocessor: {
plugins: [
commonjs(),
json(),
resolve({ browser: true }),
babel.babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**'
}),
istanbul({
exclude: [
'test/unit/*.js',
'test_data/**',
'node_modules/**/*.js'
]
})
],
output: {
format: 'iife',
name: 'peaks',
sourcemap: 'inline'
}
},

// test results reporter to use
Expand Down
Loading

0 comments on commit 5143a52

Please sign in to comment.