netlify / netlify-lambda

Helps building and serving lambda functions locally and in CI environments
MIT License
594 stars 117 forks source link

IgnorePluginOptions error while building functions: vertx #562

Closed DavidSabine closed 1 year ago

DavidSabine commented 2 years ago

While building functions for use with a Gatsby site, I've been hitting this error for months.

CLI Output

netlify-lambda: Building functions
ValidationError: Invalid options object. Ignore Plugin has been initialized using an options object that does not match the API schema.
 - options should be one of these:
   object { resourceRegExp, contextRegExp? } | object { checkResource }
   Details:
    * options misses the property 'resourceRegExp'. Should be:
      RegExp
      -> A RegExp to test the request against.
    * options misses the property 'checkResource'. Should be:
      function
      -> A filter function for resource and context.
    at validate (C:\Users\me\Documents\GitHub\my-site\node_modules\schema-utils\dist\validate.js:105:11)
    at C:\Users\me\Documents\GitHub\my-site\node_modules\webpack\lib\util\create-schema-validation.js:16:17
    at new IgnorePlugin (C:\Users\me\Documents\GitHub\my-site\node_modules\webpack\lib\IgnorePlugin.js:28:3)
    at webpackConfig (C:\Users\me\Documents\GitHub\my-site\node_modules\netlify-lambda\lib\build.js:161:7)
    at async Object.exports.run (C:\Users\me\Documents\GitHub\my-site\node_modules\netlify-lambda\lib\build.js:208:18) {
  errors: [
    {
      keyword: 'anyOf',
      dataPath: '',
      schemaPath: '#/anyOf',
      params: {},
      message: 'should match some schema in anyOf',
      schema: [Array],
      parentSchema: [Object],
      data: /vertx/,
      children: [Array]
    }
  ],
  schema: { title: 'IgnorePluginOptions', anyOf: [ [Object], [Object] ] },
  headerName: 'Ignore Plugin',
  baseDataPath: 'options',
  postFormatter: null
}

To Reproduce

I don't know how to reproduce the error. I don't use "vertx" in the project and have no idea what it is.

To Avoid the error

  1. I navigate to my node_modules/netlify-lambda/lib/build.js > webpackConfig > webpackConfig > plugins
  2. And delete this line:
new webpack.IgnorePlugin(/vertx/),

Then all is well!

Configuration

netlify.toml

[build]
    functions = './site/__functions__'

[dev]
    autoLaunch = false
    command = 'yarn workspace site develop'
    framework = '#custom'
    port = 8888
    publish = './site/public'
    targetPort = 8000

[[plugins]]
    package = 'netlify-plugin-gatsby-cache'

npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

  System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 19.26 GB / 31.96 GB
  Binaries:
    Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.1.1 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD
erezrokah commented 2 years ago

Hi @DavidSabine, going to move this to https://github.com/netlify/netlify-lambda, as I think it fits better in that repository.

If you could provide a public repository that we can use to reproduce the error that would be great, as it might be specific to the way netlify-lambda is configured with your project.

frankcalise commented 2 years ago

I'm also seeing this error with Gatsby 3.14.6 and netlify-lambda 2.0.15, I believe it is due to Webpack 5 maybe and the IgnorePlugin signature change?