From 59816d8c49856477678cf42186083a63c092b0f8 Mon Sep 17 00:00:00 2001 From: cgerrard-pass <187540148+cgerrard-pass@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:29:24 +0100 Subject: [PATCH] (PC-33007) chore(web): remove service worker --- .../dev_on_dispatch_service_worker_test.yml | 130 ----------- doc/development/general-info-web.md | 2 - package.json | 15 +- public/index.html | 1 - scripts/service-worker-test.mjs | 127 ----------- src/App.web.tsx | 83 ++++--- src/service-worker.ts | 83 ------- src/web/serviceWorkerRegistration.ts | 165 -------------- src/web/useServiceWorker.tsx | 214 ------------------ yarn.lock | 105 --------- 10 files changed, 41 insertions(+), 884 deletions(-) delete mode 100644 .github/workflows/dev_on_dispatch_service_worker_test.yml delete mode 100644 scripts/service-worker-test.mjs delete mode 100644 src/service-worker.ts delete mode 100644 src/web/serviceWorkerRegistration.ts delete mode 100644 src/web/useServiceWorker.tsx diff --git a/.github/workflows/dev_on_dispatch_service_worker_test.yml b/.github/workflows/dev_on_dispatch_service_worker_test.yml deleted file mode 100644 index fdc531bc550..00000000000 --- a/.github/workflows/dev_on_dispatch_service_worker_test.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: '1 [on_dispatch] Service Worker Test' - -on: - workflow_dispatch: - inputs: - versionFrom: - description: "Nom de l'ancienne release (ex: 1.199.0)" - required: true - type: string - versionTo: - description: 'Nom de la nouvelle release (ex: 1.200.0)' - required: true - type: string - repository_dispatch: - types: service-worker-test - -jobs: - testServiceWorker: - name: Test service worker - runs-on: ubuntu-22.04 - env: - PORT: 5000 - container: - image: ghcr.io/pass-culture/puppeteer:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.github_token }} - options: --user root - steps: - # Docker entrypoint is otherwise ignored in GitHub Action - - name: Docker entrypoint - shell: bash - run: /entrypoint.sh - - # Useful to get the latest service worker test script - - name: Checkout registry - uses: actions/checkout@v4 - - # To initialize the latest node version - - name: Setup Node.JS - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - # Necessary for the latest service worker test script - - name: Install dependencies - shell: bash - run: | - yarn install --immutable - yarn add puppeteer - - # Clone the version from in its own directory - - name: Checkout ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} - path: versionFrom - - # Build version from in versionFrom/build - - name: Building Webapp ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} - shell: bash - run: | - yarn install --cwd versionFrom --immutable - NODE_OPTIONS='--openssl-legacy-provider --max-old-space-size=4096' yarn --cwd versionFrom build:testing - - # Clone the version to in its own directory - - name: Checkout ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} - path: versionTo - - # Build version to in versionTo/build - ## Important: This build will be used during the last step by the JS script - ## There is an alternative way to improve this, described here: https://github.com/pass-culture/pass-culture-app-native/pull/3452 - - name: Building Webapp ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} - shell: bash - run: | - yarn install --cwd versionTo --immutable - NODE_OPTIONS='--openssl-legacy-provider --max-old-space-size=4096' yarn --cwd versionTo build:testing - - # Create build directory for serve - - name: Create a build directory to be served - run: mkdir build - - # Run HTTP server - - name: Serve Files - uses: Eun/http-server-action@v1 - with: - directory: build - port: ${{ env.PORT }} - no-cache: false - content-types: | - { - "appcache": "text/cache-manifest", - "css": "text/css", - "gif": "image/gif", - "html": "text/html", - "ico": "image/x-icon", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "js": "text/javascript", - "json": "application/json", - "png": "image/png", - "txt": "text/plain", - "xml": "text/xml" - } - - # Copy versionFrom to build directory - - name: Copy versionFrom to server directory - run: yes | cp -rf versionFrom/build/* build/ - - # Run puppeteer - - run: yarn test:sw ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} - - # Send failure otherwise success message to slack - - name: Send failure message to slack - shell: bash - if: failure() - env: - SLACK_WEBHOOK_SERVICE_WORKER_TEST: ${{ secrets.SLACK_WEBHOOK_SERVICE_WORKER_TEST }} - run: | - curl -X POST -H 'Content-type: application/json' --data '{"text":"[App Web] Test service-worker failed to upgrade from ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} to ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} :collision:"}' "$SLACK_WEBHOOK_SERVICE_WORKER_TEST" - - name: Send success message to slack - shell: bash - if: success() - env: - SLACK_WEBHOOK_SERVICE_WORKER_TEST: ${{ secrets.SLACK_WEBHOOK_SERVICE_WORKER_TEST }} - run: | - curl -X POST -H 'Content-type: application/json' --data '{"text":"[App Web] Test service-worker succeeded to upgrade from ${{ github.event.inputs.versionFrom }}${{ github.event.client_payload.versionFrom }} to ${{ github.event.inputs.versionTo }}${{ github.event.client_payload.versionTo }} :rocket:️️"}' "$SLACK_WEBHOOK_SERVICE_WORKER_TEST" diff --git a/doc/development/general-info-web.md b/doc/development/general-info-web.md index ec9f93ac464..48e6411a702 100644 --- a/doc/development/general-info-web.md +++ b/doc/development/general-info-web.md @@ -127,7 +127,6 @@ There are certain number of optimizations/improvements and things that were done MUST HAVE: -- Remove service workers (caused cache update issues) and manifest if we decide to not use PWA (because it requires maintenance). - Test older browsers - If needed, increase compatibility with `@vitejs/plugin-legacy` (you will need to install `terser` for the plugin to work) @@ -142,7 +141,6 @@ COULD HAVE: - Using vite's chunking technology (or any other chunking technology) to reduce the initial loading time of the web app - Chunk protection (check there isn't any bundle issues and protect against future issues) - Depending on the compatibility with older browsers, update `src/web/SupportedBrowsersGate.web.test.tsx` and `package.json.browserList` -- PWA (it seems that vite generates a manifest but we should make sure the service worker is functioning) COULD BE NICE TO HAVE: diff --git a/package.json b/package.json index c8180a79f80..fd9ef3fdc65 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,6 @@ "test:lint": "eslint . --ext .js,.ts,.tsx,.mjs --cache", "test:perf": "NODE_ENV=performance NODE_OPTIONS='--no-experimental-fetch' TEST_RUNNER_ARGS='--runInBand --testMatch \"/**/*.perf.test.tsx\"' yarn reassure", "test:perf:update": "yarn test:perf --baseline", - "test:sw": "node scripts/service-worker-test.mjs", "test:storybook:accessibility": "TZ=UTC axe-storybook --storybook-address http://localhost:6006", "test:types": "tsc", "test:types:noUncheckedIndexedAccess": "grep --recursive --line-number ./src --regexp '// @ts-expect-error: because of noUncheckedIndexedAccess' | awk -F: '{print $1\":\"$2}' | sort", @@ -349,19 +348,7 @@ "typescript": "5.0.4", "url-loader": "^4.1.1", "vite": "^5.3.1", - "vite-plugin-html": "^3.2.2", - "workbox-background-sync": "^6.1.5", - "workbox-broadcast-update": "^6.1.5", - "workbox-cacheable-response": "^6.1.5", - "workbox-core": "^6.1.5", - "workbox-expiration": "^6.1.5", - "workbox-google-analytics": "^6.1.5", - "workbox-navigation-preload": "^7.1.0", - "workbox-precaching": "^6.1.5", - "workbox-range-requests": "^6.1.5", - "workbox-routing": "^6.1.5", - "workbox-strategies": "^6.1.5", - "workbox-streams": "^6.1.5" + "vite-plugin-html": "^3.2.2" }, "resolutions": { "@sentry/cli": "^2.33.1", diff --git a/public/index.html b/public/index.html index 9e48d0c4212..33454b481bc 100644 --- a/public/index.html +++ b/public/index.html @@ -111,7 +111,6 @@ media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" /> -