serwist

A Swiss Army knife for service workers.

MIT License

Downloads
1.7M
Stars
667
Committers
81

Bot releases are visible (Hide)

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 6c3e789 Thanks @DuCanhGH! - feat(precaching.PrecacheFallbackPlugin): renamed fallbackURL, added support for a matcher

    • fallbackURL has been renamed to fallbackUrls, which should now be an array of strings or PrecacheFallbackEntry's.

      • PrecacheFallbackEntry is an interface that requires a fallback URL and a matcher, which is used to check whether the current fallback entry can be used for a request.

      • To migrate:

        • Old:
        new PrecacheFallbackPlugin({
          fallbackURL: "/~offline",
        });
        
        • New:
        new PrecacheFallbackPlugin({
          fallbackUrls: ["/~offline"],
        });
        // Or
        new PrecacheFallbackPlugin({
          fallbackUrls: [
            {
              url: "/~offline",
              matcher({ request }) {
                return request.destination === "document";
              },
            },
          ],
        });
        
    • With this change, serwist.Serwist.fallbacks now also uses PrecacheFallbackPlugin. This means that FallbackEntry.cacheMatchOptions has been removed, for PrecacheController.matchPrecache doesn't support a custom matchOptions. This option is most likely not needed anyway.

      • To migrate:

        • Old:
        fallbacks({
          entries: [
            {
              url: "/~offline",
              revision,
              matcher({ request }) {
                return request.destination === "document";
              },
              cacheMatchOptions: { ignoreSearch: true },
            },
          ],
          runtimeCaching,
        });
        
        • New:
        new Serwist({
          fallbacks: {
            entries: [
              {
                url: "/~offline",
                revision,
                matcher({ request }) {
                  return request.destination === "document";
                },
              },
            ],
          }
          runtimeCaching,
        });
        
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

  • #123 cbf3e46 Thanks @DuCanhGH! - feat(precaching): support concurrent precaching

    • Serwist now accepts a new option, precacheOptions.concurrency, which should be the number of precache requests that should be made concurrently.
    • By default, we precache things 10 assets each, but this can be changed by setting this option.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 4a5d51a Thanks @DuCanhGH! - chore(peerDeps): bump minimum supported TypeScript and Node.js version

    • From now, we only support TypeScript versions later than 5.0.0 and Node.js ones later than 18.0.0.
    • To migrate, simply update these tools.
    # Change to your preferred way of updating Node.js
    nvm use 18
    # Change to your package manager
    npm i -D typescript@5
    
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

  • #123 e4c00af Thanks @DuCanhGH! - refactor(core): replaced installSerwist, PrecacheController, and Router with Serwist

    • `installSerwist, PrecacheController, and Router have been moved to serwist/legacy. Their functionalities have been merged into the Serwist class.

    • The new Serwist class does NOT have a singleton instance. As such, serwist.initializeGoogleAnalytics() and @serwist/recipes's functions now require you to pass in your own Serwist instance.

    • This was done because separating Serwist's functionalities into three separate classes, namely PrecacheController, Router, and Serwist, was not only unnecessary, but it also required the code to be rather... boilerplatey. In the past, to set up, you needed to install all the necessary packages (workbox-routing, workbox-precaching, workbox-strategies), import all the necessary classes (PrecacheController, Router,...), and know all the APIs needed (PrecacheController.precache, Router.registerRoute, new PrecacheRoute(), runtime caching strategies,...) to get yourself started. To simplify that whole process, the Workbox team provided GenerateSW, which allowed you to create a service worker without having to write one. However, this design was not my cup of tea, one of the reasons of which was that you needed to migrate from GenerateSW to InjectManifest if you needed to do anything remotely complex, so I replaced it with installSerwist. Still, I was not satisfied by the result. I wanted an API where things are simple enough that you don't need to have multiple ways of doing one same thing, some more straightforward than others. This change where we merge the three classes is an effort to simplify and unify the API.

    • To migrate, either:

      • Use the new Serwist class:
      import { Serwist } from "serwist";
      
      const serwist = new Serwist({
        // Initial list of precache entries.
        precacheEntries: [],
        // Initial list of runtime caching strategies.
        runtimeCaching: [],
      });
      
      // Additionally append another list of precache entries.
      // Make sure there are no duplicates in the initial list.
      serwist.addToPrecacheList([]);
      
      // Register another runtime caching strategy.
      serwist.registerRoute(
        new Route(/\/api\/.*\/*.json/, new NetworkOnly(), "POST"),
      );
      
      // This should be called before `Serwist.addEventListeners`.
      self.addEventListener("message", (event) => {
        if (event.data && event.data.type === "YOUR_MESSAGE_TYPE") {
          // Do something
        }
      });
      
      // Finally, add Serwist's listeners.
      serwist.addEventListeners();
      
      • Or import PrecacheController and Router from serwist/legacy:
      import { PrecacheController, Router } from "serwist/legacy";
      

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

  • #123 c47a8b2 Thanks @DuCanhGH! - feat(expiration.ExpirationPlugin): added maxAgeFrom

    • This allows you to decide whether maxAgeSeconds should be calculated from when an entry was last fetched or when it was last used.
    • For more information, see the original Workbox issue.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 4a5d51a Thanks @DuCanhGH! - chore(peerDeps): bump minimum supported TypeScript and Node.js version

    • From now, we only support TypeScript versions later than 5.0.0 and Node.js ones later than 18.0.0.
    • To migrate, simply update these tools.
    # Change to your preferred way of updating Node.js
    nvm use 18
    # Change to your package manager
    npm i -D typescript@5
    
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 4a5d51a Thanks @DuCanhGH! - chore(peerDeps): bump minimum supported TypeScript and Node.js version

    • From now, we only support TypeScript versions later than 5.0.0 and Node.js ones later than 18.0.0.
    • To migrate, simply update these tools.
    # Change to your preferred way of updating Node.js
    nvm use 18
    # Change to your package manager
    npm i -D typescript@5
    
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

  • #123 ea0944c Thanks @DuCanhGH! - feat(cacheable-response): use Headers instead of a headers object

    • Since Headers.prototype.get() is case-insensitive, it would be nice to have our headers be the same. The easiest way to do that would be to also use Headers.
    • Now, you can use a HeadersInit for headers rather than be limited to a map from string to string like before.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • #123 b1df273 Thanks @DuCanhGH! - chore(core): allow non-Promise return types for SerwistPlugin callbacks

    • Usually you don't need to do anything to migrate, but we still mark it as a breaking change because changing a function's signature is considered a breaking one in this project.
  • #123 7b55ac5 Thanks @DuCanhGH! - refactor(js): dropped the CommonJS build

    • Serwist is now an ESM-only project.

    • This was done because our tooling around supporting CJS had always been crappy: it was slow, had no way of supporting emitting .d.cts (we used to copy .d.ts to .d.cts), and was too error-prone (there were various issues of our builds crashing due to an ESM-only package slipping in).

    • If you already use ESM, there's nothing to be done. Great! Otherwise, to migrate:

      • Migrate to ESM if possible.

      • Otherwise, use dynamic imports. For example, to migrate to the new @serwist/next:

        • Old:
        // @ts-check
        const withSerwist = require("@serwist/next").default({
          cacheOnNavigation: true,
          swSrc: "app/sw.ts",
          swDest: "public/sw.js",
        });
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = withSerwist(nextConfig);
        
        • New:
        // @ts-check
        /** @type {import("next").NextConfig} */
        const nextConfig = {
          reactStrictMode: true,
        };
        
        module.exports = async () => {
          const withSerwist = (await import("@serwist/next")).default({
            cacheOnNavigation: true,
            swSrc: "app/sw.ts",
            swDest: "public/sw.js",
          });
          return withSerwist(nextConfig);
        };
        
      • If all else fails, use require(esm). This may or may not be supported on your current Node.js version.

Minor Changes

  • #123 c65578b Thanks @DuCanhGH! - refactor: merge service worker modules into serwist

    • These service worker modules have been merged into serwist:

      • Modules now located at serwist:

        • @serwist/navigation-preload:

          • @serwist/navigation-preload.disable -> serwist.disableNavigationPreload.
          • @serwist/navigation-preload.enable -> serwist.enableNavigationPreload.
          • @serwist/navigation-preload.isSupported -> serwist.isNavigationPreloadSupported.
        • @serwist/background-sync

          • @serwist/background-sync.QueueEntry -> serwist.BackgroundSyncQueueEntry
          • @serwist/background-sync.QueueOptions -> serwist.BackgroundSyncQueueOptions
          • @serwist/background-sync.Queue -> serwist.BackgroundSyncQueue
          • @serwist/background-sync.QueueStore -> serwist.BackgroundSyncQueueStore
        • @serwist/broadcast-update

        • @serwist/cacheable-response

        • @serwist/expiration

        • @serwist/google-analytics

          • @serwist/google-analytics.initialize -> serwist.initializeGoogleAnalytics
        • @serwist/range-requests

        • @serwist/precaching

        • @serwist/routing

        • @serwist/strategies

    • They remain operable for compatibility, but they will be marked as deprecated on npm.

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

serwist - [email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • 3a16582 Thanks @DuCanhGH! - chore: second stability test before stable release
serwist - @serwist/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

Package Rankings
Top 23.13% on Npmjs.org