From 0a8dfcca37b18c08dadca805dbe7814b6281b735 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Sun, 21 Jan 2018 17:53:43 +0000 Subject: [PATCH] fix babelification problems --- .gitignore | 1 - Makefile | 9 +++------ karma.conf.js | 13 ++++++------- src/client.js | 2 -- src/lib/compile-route.js | 1 - test/sw.js | 24 ------------------------ 6 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 test/sw.js diff --git a/.gitignore b/.gitignore index b63d930d..c1fc6850 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/test/fixtures/built-sw.js /es5/ package-lock.json /node_modules/ diff --git a/Makefile b/Makefile index c583548e..2cf519d0 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,12 @@ .PHONY: test -build-sw: - ./node_modules/.bin/webpack --entry ./test/fixtures/sw.js --output-filename ./test/fixtures/built-sw.js - -test-dev: build-sw +test-dev: ./node_modules/karma/bin/karma start --browsers=Chrome -test-chrome: build-sw +test-chrome: ./node_modules/karma/bin/karma start --single-run --browsers=Chrome -test-firefox: build-sw +test-firefox: ./node_modules/karma/bin/karma start --single-run --browsers=Firefox test-unit: diff --git a/karma.conf.js b/karma.conf.js index 244f6c58..b61c518e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -7,32 +7,31 @@ module.exports = function(karma) { frameworks: [ 'mocha', 'chai'], files: [ 'test/client.js', - 'test/sw.js', - {pattern: 'test/fixtures/built-sw.js', served: true, included: false}, + {pattern: 'test/fixtures/sw.js', served: true, included: false}, ], proxies: { - '/__sw.js': '/base/test/fixtures/built-sw.js' + '/__sw.js': '/base/test/fixtures/sw.js' }, preprocessors: { 'test/**/*.js': ['webpack'] }, webpack: { - devtool: 'source-map', + // devtool: 'source-map', module: { rules: [ - //babel { test: /\.js$/, loader: 'babel-loader', + exclude: /node_modules/, query: { babelrc: false, // ignore any .babelrc in project & dependencies cacheDirectory: true, plugins: [ // ensures a module reqired multiple times is only transpiled once and // is shared by all that use it rather than transpiling it each time - [require.resolve('babel-plugin-transform-runtime'),{ + [require.resolve('babel-plugin-transform-runtime'), { helpers: true, - polyfill: false, + polyfill: true, }], ], presets: [require.resolve('babel-preset-env')] diff --git a/src/client.js b/src/client.js index 9d6790ce..a0703333 100644 --- a/src/client.js +++ b/src/client.js @@ -1,5 +1,3 @@ -'use strict'; - const FetchMock = require('./lib/index'); const statusTextMap = require('./lib/status-text'); const theGlobal = typeof window !== 'undefined' ? window : self; diff --git a/src/lib/compile-route.js b/src/lib/compile-route.js index cb0dbcaa..8580ce56 100644 --- a/src/lib/compile-route.js +++ b/src/lib/compile-route.js @@ -1,4 +1,3 @@ -'use strict'; const glob = require('glob-to-regexp') const express = require('path-to-regexp'); const URL = require('url'); diff --git a/test/sw.js b/test/sw.js deleted file mode 100644 index b3afa0dc..00000000 --- a/test/sw.js +++ /dev/null @@ -1,24 +0,0 @@ -const expect = require('chai').expect; -describe('service worker', () => { - it('should work within a service worker', () => { - return navigator.serviceWorker && navigator.serviceWorker.register('__sw.js') - .then(registration => { - return new Promise((resolve, reject) => { - if (registration.installing) { - registration.installing.onstatechange = function () { - if (this.state === 'activated') { - resolve(); - } - } - } else { - reject('No idea what happened'); - } - }) - .then(() => { - expect(true).to.be.true; - return navigator.serviceWorker.getRegistration() - .then(registration => registration ? registration.unregister() : false); - }) - }) - }) -})