From bc38707e7865c3496247928d7b5dcd7d2dcb453f Mon Sep 17 00:00:00 2001 From: DuCanhGH <75556609+DuCanhGH@users.noreply.github.com> Date: Wed, 30 Nov 2022 22:37:54 +0700 Subject: [PATCH] fix: added webpack to peerDeps, fast-glob to deps --- .github/workflows/build-examples.yml | 34 +++++++++++++------ .github/workflows/npm-publish.yml | 2 +- README.md | 8 +++-- .../cache-on-front-end-nav/next.config.js | 2 +- examples/cache-on-front-end-nav/package.json | 12 +++---- examples/cookie/next.config.js | 2 +- examples/cookie/package.json | 12 +++---- examples/custom-ts-worker/README.md | 4 +-- examples/custom-ts-worker/next.config.js | 2 +- examples/custom-ts-worker/package.json | 12 +++---- examples/custom-worker/README.md | 2 +- examples/custom-worker/next.config.js | 2 +- examples/custom-worker/package.json | 12 +++---- examples/lifecycle/next.config.js | 2 +- examples/lifecycle/package.json | 12 +++---- examples/minimal/next.config.js | 2 +- examples/minimal/package.json | 12 +++---- examples/next-9/next.config.js | 2 +- examples/next-9/package.json | 12 +++---- examples/next-i18next/next.config.js | 2 +- examples/next-i18next/package.json | 12 +++---- examples/next-image/next.config.js | 2 +- examples/next-image/package.json | 12 +++---- examples/offline-fallback-v2/next.config.js | 2 +- examples/offline-fallback-v2/package.json | 12 +++---- examples/offline-fallback/next.config.js | 2 +- examples/offline-fallback/package.json | 12 +++---- examples/web-push/next.config.js | 2 +- examples/web-push/package.json | 12 +++---- package.json | 5 +-- 30 files changed, 120 insertions(+), 103 deletions(-) diff --git a/.github/workflows/build-examples.yml b/.github/workflows/build-examples.yml index 63e26255..dffebcab 100644 --- a/.github/workflows/build-examples.yml +++ b/.github/workflows/build-examples.yml @@ -1,4 +1,4 @@ -name: Build Examples +name: Build examples on: push: @@ -10,6 +10,9 @@ jobs: build: strategy: matrix: + node-version: ["16.x"] + pnpm-version: ["7.x"] + os: [ubuntu-latest] example: [ minimal, @@ -24,17 +27,26 @@ jobs: offline-fallback-v2, web-push, ] - runs-on: ubuntu-latest + if: ${{ github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, '[skip ci]') }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout repo + uses: actions/checkout@v3 + - name: Use pnpm + uses: pnpm/action-setup@v2 with: - node-version: 16 - - run: npm ci - - run: npm link - - run: npm install - working-directory: examples/${{ matrix.example }} - - run: npm link next-pwa + version: ${{ matrix.pnpm-version }} + - name: Use Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + - name: Install dependencies in root + run: pnpm install + - name: Link package + run: pnpm link + - name: Install dependencies for app + run: pnpm install --frozen-lockfile=false working-directory: examples/${{ matrix.example }} - - run: npm run build + - name: Build app + run: pnpm build working-directory: examples/${{ matrix.example }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 87ad7791..54b0ec0c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,4 +1,4 @@ -name: Release package +name: Publish package to npm on: [push] jobs: build: diff --git a/README.md b/README.md index c5726fd0..d07f7ed0 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,11 @@ This plugin is powered by [Workbox](https://developer.chrome.com/docs/workbox/) > If you are new to `Next.js` or `React.js`, you may want to checkout [learn Next.js](https://nextjs.org/learn/basics/create-nextjs-app) or [Next.js documentation](https://nextjs.org/docs/getting-started) first. Then start from [a simple example](https://github.com/DuCanhGH/next-pwa/tree/master/examples/next-9) or [progressive-web-app example in Next.js's repository](https://github.com/vercel/next.js/tree/canary/examples/progressive-web-app). ```bash -yarn add next-pwa +npm i @ducanh2912/next-pwa +# or +# yarn add @ducanh2912/next-pwa +# or +# pnpm add @ducanh2912/next-pwa ``` ## Basic Usage @@ -269,7 +273,7 @@ You can also setup `precacheFallback.fallbackURL` in your [runtimeCaching config There are options you can use to customize the behavior of this plugin: ```javascript -const withPWA = require("next-pwa").default({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", // disable: process.env.NODE_ENV === 'development', // register: true, diff --git a/examples/cache-on-front-end-nav/next.config.js b/examples/cache-on-front-end-nav/next.config.js index 38937372..271c1df6 100644 --- a/examples/cache-on-front-end-nav/next.config.js +++ b/examples/cache-on-front-end-nav/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/cache-on-front-end-nav/package.json b/examples/cache-on-front-end-nav/package.json index 9a87802b..a492bcc4 100644 --- a/examples/cache-on-front-end-nav/package.json +++ b/examples/cache-on-front-end-nav/package.json @@ -10,13 +10,13 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "@ducanh2912/next-pwa": "latest", + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/cookie/next.config.js b/examples/cookie/next.config.js index b905da6d..b780033b 100644 --- a/examples/cookie/next.config.js +++ b/examples/cookie/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", dynamicStartUrl: true, // this is same as default value dynamicStartUrlRedirect: "/login", // recommend to config this for best user experience if your start-url redirects on first load diff --git a/examples/cookie/package.json b/examples/cookie/package.json index 54a98475..fadef567 100644 --- a/examples/cookie/package.json +++ b/examples/cookie/package.json @@ -10,15 +10,15 @@ "start": "next start" }, "dependencies": { + "@ducanh2912/next-pwa": "latest", "js-cookie": "^3.0.1", - "next": "^12.2.5", + "next": "13.0.5", "next-cookies": "^2.0.3", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/custom-ts-worker/README.md b/examples/custom-ts-worker/README.md index b41758e8..3c37e92a 100644 --- a/examples/custom-ts-worker/README.md +++ b/examples/custom-ts-worker/README.md @@ -17,7 +17,7 @@ In this way, you get benefit of code splitting and size minimization automatical You can customize the directory of your custom worker file by setting the `customWorkerDir` relative to the `basedir` in the `pwa` section of your `next.config.js`: ```javascript -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ customWorkerDir: "serviceworker", // ... }); @@ -34,7 +34,7 @@ In this example, `next-pwa` would look for `serviceworker/index.ts`. Basically you need to create a file such as `worker.js` in `public` folder, then add an option `importScripts` to `pwa` object in `next.config.js`: ```javascript -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", importScripts: ["/worker.js"], }); diff --git a/examples/custom-ts-worker/next.config.js b/examples/custom-ts-worker/next.config.js index 38937372..271c1df6 100644 --- a/examples/custom-ts-worker/next.config.js +++ b/examples/custom-ts-worker/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/custom-ts-worker/package.json b/examples/custom-ts-worker/package.json index 772ab16c..f7034449 100644 --- a/examples/custom-ts-worker/package.json +++ b/examples/custom-ts-worker/package.json @@ -10,16 +10,16 @@ "start": "next start" }, "dependencies": { + "@ducanh2912/next-pwa": "latest", "babel-loader": "^8.2.5", - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { "@types/react": "^18.0.17", - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5", + "eslint": "8.28.0", + "eslint-config-next": "13.0.5", "typescript": "^4.7.4" } } diff --git a/examples/custom-worker/README.md b/examples/custom-worker/README.md index f2aa0104..4984bf34 100644 --- a/examples/custom-worker/README.md +++ b/examples/custom-worker/README.md @@ -36,7 +36,7 @@ In this example, `next-pwa` would look for `serviceworker/index.js`. Basically you need to create a file such as `worker.js` in `public` folder, then add an option `importScripts` to `pwa` object in `next.config.js`: ```javascript -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", importScripts: ["/worker.js"], }); diff --git a/examples/custom-worker/next.config.js b/examples/custom-worker/next.config.js index 38937372..271c1df6 100644 --- a/examples/custom-worker/next.config.js +++ b/examples/custom-worker/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/custom-worker/package.json b/examples/custom-worker/package.json index bc9d6d14..19c2ac86 100644 --- a/examples/custom-worker/package.json +++ b/examples/custom-worker/package.json @@ -10,14 +10,14 @@ "start": "next start" }, "dependencies": { + "@ducanh2912/next-pwa": "latest", "babel-loader": "^8.2.5", - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/lifecycle/next.config.js b/examples/lifecycle/next.config.js index 8de16c97..007df1d3 100644 --- a/examples/lifecycle/next.config.js +++ b/examples/lifecycle/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", register: false, skipWaiting: false, diff --git a/examples/lifecycle/package.json b/examples/lifecycle/package.json index 9a87802b..a492bcc4 100644 --- a/examples/lifecycle/package.json +++ b/examples/lifecycle/package.json @@ -10,13 +10,13 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "@ducanh2912/next-pwa": "latest", + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/minimal/next.config.js b/examples/minimal/next.config.js index 97dea39b..02edd0cc 100644 --- a/examples/minimal/next.config.js +++ b/examples/minimal/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ // pwa output folder // dest: '.next/pwa' // diff --git a/examples/minimal/package.json b/examples/minimal/package.json index cdc2abee..64fcc066 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -10,16 +10,16 @@ "start": "cross-env NODE_ENV=production node ./index.js" }, "dependencies": { + "@ducanh2912/next-pwa": "latest", "cross-env": "^7.0.3", "fastify": "^4.5.2", "fastify-compress": "^4.1.0", - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/next-9/next.config.js b/examples/next-9/next.config.js index 38937372..271c1df6 100644 --- a/examples/next-9/next.config.js +++ b/examples/next-9/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/next-9/package.json b/examples/next-9/package.json index 9a87802b..a492bcc4 100644 --- a/examples/next-9/package.json +++ b/examples/next-9/package.json @@ -10,13 +10,13 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "@ducanh2912/next-pwa": "latest", + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/next-i18next/next.config.js b/examples/next-i18next/next.config.js index f16f546b..34973a02 100644 --- a/examples/next-i18next/next.config.js +++ b/examples/next-i18next/next.config.js @@ -1,3 +1,3 @@ -const withPWA = require("next-pwa")(); +const withPWA = require("@ducanh2912/next-pwa").default(); module.exports = withPWA(); diff --git a/examples/next-i18next/package.json b/examples/next-i18next/package.json index 194cfac2..4e50f344 100644 --- a/examples/next-i18next/package.json +++ b/examples/next-i18next/package.json @@ -10,17 +10,17 @@ "start": "cross-env NODE_ENV=production node ./index.js" }, "dependencies": { + "@ducanh2912/next-pwa": "latest", "cross-env": "^7.0.3", "express": "^4.18.1", "fastify-compress": "^4.1.0", - "next": "^12.2.5", + "next": "13.0.5", "next-i18next": "^12.0.0", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/next-image/next.config.js b/examples/next-image/next.config.js index 38937372..271c1df6 100644 --- a/examples/next-image/next.config.js +++ b/examples/next-image/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/next-image/package.json b/examples/next-image/package.json index 9a87802b..a492bcc4 100644 --- a/examples/next-image/package.json +++ b/examples/next-image/package.json @@ -10,13 +10,13 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0" + "@ducanh2912/next-pwa": "latest", + "next": "13.0.5", + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/offline-fallback-v2/next.config.js b/examples/offline-fallback-v2/next.config.js index cf5f2cdc..e0f80add 100644 --- a/examples/offline-fallback-v2/next.config.js +++ b/examples/offline-fallback-v2/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", fallbacks: { image: "/static/images/fallback.png", diff --git a/examples/offline-fallback-v2/package.json b/examples/offline-fallback-v2/package.json index 85cbce96..a39a1703 100644 --- a/examples/offline-fallback-v2/package.json +++ b/examples/offline-fallback-v2/package.json @@ -10,14 +10,14 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "next": "13.0.5", + "@ducanh2912/next-pwa": "latest", + "react": "18.2.0", + "react-dom": "18.2.0", "sharp": "^0.30.7" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/offline-fallback/next.config.js b/examples/offline-fallback/next.config.js index 8adf1b68..aadc9a42 100644 --- a/examples/offline-fallback/next.config.js +++ b/examples/offline-fallback/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", swSrc: "service-worker.js", }); diff --git a/examples/offline-fallback/package.json b/examples/offline-fallback/package.json index 85cbce96..a39a1703 100644 --- a/examples/offline-fallback/package.json +++ b/examples/offline-fallback/package.json @@ -10,14 +10,14 @@ "start": "next start" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "next": "13.0.5", + "@ducanh2912/next-pwa": "latest", + "react": "18.2.0", + "react-dom": "18.2.0", "sharp": "^0.30.7" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/examples/web-push/next.config.js b/examples/web-push/next.config.js index 38937372..271c1df6 100644 --- a/examples/web-push/next.config.js +++ b/examples/web-push/next.config.js @@ -1,4 +1,4 @@ -const withPWA = require("next-pwa")({ +const withPWA = require("@ducanh2912/next-pwa").default({ dest: "public", }); diff --git a/examples/web-push/package.json b/examples/web-push/package.json index b98469ba..ebebebb9 100644 --- a/examples/web-push/package.json +++ b/examples/web-push/package.json @@ -11,14 +11,14 @@ "vapid": "web-push generate-vapid-keys" }, "dependencies": { - "next": "^12.2.5", - "next-pwa": "latest", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "next": "13.0.5", + "@ducanh2912/next-pwa": "latest", + "react": "18.2.0", + "react-dom": "18.2.0", "web-push": "^3.5.0" }, "devDependencies": { - "eslint": "^8.22.0", - "eslint-config-next": "12.2.5" + "eslint": "8.28.0", + "eslint-config-next": "13.0.5" } } diff --git a/package.json b/package.json index d0ec9c91..adce2be2 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "dependencies": { "babel-loader": "9.1.0", "clean-webpack-plugin": "4.0.0", + "fast-glob": "3.2.12", "terser-webpack-plugin": "5.3.6", "workbox-build": "6.5.4", "workbox-webpack-plugin": "6.5.4", @@ -64,7 +65,6 @@ "eslint-config-prettier": "8.5.0", "eslint-plugin-prettier": "4.2.1", "eslint-plugin-simple-import-sort": "8.0.0", - "fast-glob": "3.2.12", "husky": "8.0.2", "next": "13.0.5", "prettier": "2.8.0", @@ -79,6 +79,7 @@ "webpack": "5.75.0" }, "peerDependencies": { - "next": ">=9.0.0" + "next": ">=9", + "webpack": ">=5" } }