From 31b5ff93124bcb735a1c043b6d77d16392c7f41c Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Thu, 18 Jan 2018 17:13:54 -0700 Subject: [PATCH] Disable service worker by default (#3817) * WIP disable service worker by default (#2554) * Updated service worker registration * Readd default export in registerServiceWorker.js * Updated comments about using Service Worker * Call it serviceWorker * Nits --- packages/react-scripts/template/src/index.js | 8 ++++++-- .../src/{registerServiceWorker.js => serviceWorker.js} | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) rename packages/react-scripts/template/src/{registerServiceWorker.js => serviceWorker.js} (99%) diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index fae3e3500cf..59410291118 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -2,7 +2,11 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; -import registerServiceWorker from './registerServiceWorker'; +import * as serviceWorker from './serviceWorker'; ReactDOM.render(, document.getElementById('root')); -registerServiceWorker(); + +// If you want your app to work offline and load faster, you can change +// unregister() to register() below. Note this comes with some pitfalls. +// Learn more about service workers: http://bit.ly/2vJdu84 +serviceWorker.unregister(); diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/serviceWorker.js similarity index 99% rename from packages/react-scripts/template/src/registerServiceWorker.js rename to packages/react-scripts/template/src/serviceWorker.js index a3e6c0cfc10..2edbdd420ea 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/serviceWorker.js @@ -18,7 +18,7 @@ const isLocalhost = Boolean( ) ); -export default function register() { +export function register() { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL(process.env.PUBLIC_URL, window.location);