From a05226544f1bdfebe292a870f55ce5f7e1a8c9d9 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 24 May 2022 14:09:48 +0000 Subject: [PATCH] Adding final files from js to ts. --- jest.config.js | 4 ++-- package.json | 2 +- service-worker.js => service-worker.ts | 4 ++++ setupTest.js => setupTest.ts | 0 src/__mocks__/{fileMock.js => fileMock.ts} | 0 webpack.config.ts | 4 ++-- 6 files changed, 9 insertions(+), 5 deletions(-) rename service-worker.js => service-worker.ts (95%) rename setupTest.js => setupTest.ts (100%) rename src/__mocks__/{fileMock.js => fileMock.ts} (100%) diff --git a/jest.config.js b/jest.config.js index cdd6de8..551d50c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,8 @@ module.exports = { - setupFilesAfterEnv: ['/setupTest.js'], + setupFilesAfterEnv: ['/setupTest.ts'], "testEnvironment": "jsdom", moduleNameMapper: { - "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/__mocks__/fileMock.js", + "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/__mocks__/fileMock.ts", "\\.(css|sass|less)$": "identity-obj-proxy" }, }; \ No newline at end of file diff --git a/package.json b/package.json index d63499e..c6eabc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aleleba/create-react-ssr", - "version": "2.0.6", + "version": "2.0.7", "description": "Starter Kit of server side render of react", "bin": "./bin/cli.js", "main": "src/server/index", diff --git a/service-worker.js b/service-worker.ts similarity index 95% rename from service-worker.js rename to service-worker.ts index af16b1d..c91ff17 100644 --- a/service-worker.js +++ b/service-worker.ts @@ -14,12 +14,14 @@ import { StaleWhileRevalidate, NetworkFirst } from 'workbox-strategies'; clientsClaim(); // This allows the web app to trigger skipWaiting via +// @ts-ignore:next-line self.skipWaiting(); // Precache all of the assets generated by your build process. // Their URLs are injected into the manifest variable below. // This variable must be present somewhere in your service worker file, // even if you decide not to use precaching. See https://cra.link/PWA +// @ts-ignore:next-line precacheAndRoute(self.__WB_MANIFEST); // An example runtime caching route for requests that aren't handled by the @@ -45,8 +47,10 @@ registerRoute(/^https?.*/, new NetworkFirst(), 'GET'); //Wait for Notification. self.addEventListener('push', function (e) { + // @ts-ignore:next-line const data = e.data.json(); + // @ts-ignore:next-line registration.showNotification(data.title, { body: data.message, icon: 'favicon.ico' diff --git a/setupTest.js b/setupTest.ts similarity index 100% rename from setupTest.js rename to setupTest.ts diff --git a/src/__mocks__/fileMock.js b/src/__mocks__/fileMock.ts similarity index 100% rename from src/__mocks__/fileMock.js rename to src/__mocks__/fileMock.ts diff --git a/webpack.config.ts b/webpack.config.ts index e98f546..4a1e6ff 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -109,7 +109,7 @@ const frontendConfig = { ] }), new InjectManifest({ - swSrc: './service-worker.js', + swSrc: './service-worker.ts', swDest: 'service-worker.js', }), ], @@ -210,7 +210,7 @@ const serverConfig = { 'process.env.PUBLIC_URL': JSON.stringify(PUBLIC_URL), }), new InjectManifest({ - swSrc: './service-worker.js', + swSrc: './service-worker.ts', swDest: 'service-worker.js', }), ],