expo / expo-cli

Tools for creating, running, and deploying universal Expo and React Native apps
https://docs.expo.io/workflow/expo-cli/
2.62k stars 477 forks source link

"globPatterns" is not a supported parameter - using example from docs #3508

Closed ezekiel747 closed 3 years ago

ezekiel747 commented 3 years ago

Hi, i'm encountering an error when trying to use next-offline with expo:

npx next build Browserslist: caniuse-lite is outdated. Please run: npx browserslist@latest --update-db info - Using external babel configuration from /Users/dnicoara/extra/c-songs/babel.config.js info - Creating an optimized production build
Failed to compile.

Please check your GenerateSW plugin configuration: "globPatterns" is not a supported parameter.. "globDirectory" is not a supported parameter.

This is the next.config.js content:

const { withExpo } = require('@expo/next-adapter');
const withOffline = require('next-offline');
const withFonts = require('next-fonts');
const withImages = require('next-images');

module.exports = withOffline({
  workboxOpts: {
    swDest: 'workbox-service-worker.js',

    /* changing any value means you'll have to copy over all the defaults  */
    /* next-offline */
    globPatterns: ['static/**/*'],
    globDirectory: '.',
    runtimeCaching: [
      {
        urlPattern: /^https?.*/,
        handler: 'NetworkFirst',
        options: {
          cacheName: 'offlineCache',
          expiration: {
            maxEntries: 200,
          },
        },
      },
    ],
  },
  ...withExpo(withImages(withFonts({
    projectRoot: __dirname,
  }))),
});

Could you please help? Thanks.

byCedric commented 3 years ago

Hi @ezekiel747! This looks like an issue with next-offline, and specifically this issue. You can try running your project without next-offline, if that works fine (even though offline is disabled) it's that library.

ezekiel747 commented 3 years ago

Thank you for responding. I've discovered that due to a change in a more recent version of workbox-webpack-plugin (not sure which one), the these are indeed no longer valid options:

we may use instead the "include" option, which require another format instead (regex).

ezekiel747 commented 3 years ago

The instructions in Expo docs should be checked and corrected / updated to actually work with the current version of next-offline and / or its workbox-related dependencies. I would rather let someone more experienced with nextjs & workbox than doing a PR myself. Thanks!

kchangch commented 2 years ago

is there anywhere where I can find what to use instead of globPatterns, globDirectory, and globIgnores?

ezekiel747 commented 1 year ago

sorry for the late response - check out these links for the available options: https://developer.chrome.com/docs/workbox/modules/workbox-webpack-plugin/ https://developer.chrome.com/docs/workbox/reference/workbox-build/#type-WebpackGenerateSWOptions