Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack errors on serve and build. #74

Closed
brianmcallister opened this issue Nov 1, 2018 · 3 comments
Closed

Webpack errors on serve and build. #74

brianmcallister opened this issue Nov 1, 2018 · 3 comments
Labels

Comments

@brianmcallister
Copy link

I'm seeing some errors that appear to be related to webpack when I run serve and build. Here's a sample repository (this link is to a tag I created, in case I make any changes between now and when somebody gets a chance to take a look): https://github.com/brianmcallister/functions-test/releases/tag/test-build

Here's what I'm seeing:

When I run npx netlify-lambda serve ., I see the following message:

netlify-lambda: Starting server
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
    * configuration.entry should not be empty.
      -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
Lambda server is listening on 9000

...and when I GET localhost:9000/test, the server is responding correctly.

However, when I run npx netlify-lambda build ., I see the following:

netlify-lambda: Building functions
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
    * configuration.entry should not be empty.
      -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
    at webpack (/Users/brianmcallister/projects/functions-test/node_modules/webpack/lib/webpack.js:31:9)
    at /Users/brianmcallister/projects/functions-test/node_modules/netlify-lambda/lib/build.js:93:5
    at new Promise (<anonymous>)
    at Object.exports.run (/Users/brianmcallister/projects/functions-test/node_modules/netlify-lambda/lib/build.js:92:10)
    at Command.<anonymous> (/Users/brianmcallister/projects/functions-test/node_modules/netlify-lambda/bin/cmd.js:51:8)
    at Command.listener (/Users/brianmcallister/projects/functions-test/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:180:13)
    at Command.parseArgs (/Users/brianmcallister/projects/functions-test/node_modules/commander/index.js:654:12)
    at Command.parse (/Users/brianmcallister/projects/functions-test/node_modules/commander/index.js:474:21)
    at Object.<anonymous> (/Users/brianmcallister/projects/functions-test/node_modules/netlify-lambda/bin/cmd.js:61:9)

According to the documentation, it doesn't appear as though I need to provide any custom webpack config at all, but let me know if I'm misunderstanding something.

@8eecf0d2
Copy link
Contributor

8eecf0d2 commented Nov 2, 2018

Appears you've got the source and build directories mixed up.

Change your netlify.toml to:

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

And try running:

npx netlify-lambda build ./src/functions

@swyxio swyxio added the triage label Nov 6, 2018
@stefan--
Copy link
Contributor

stefan-- commented Dec 3, 2018

@brianmcallister I have been experiencing the same and solved it by specifying entry points with
entry: glob.sync('./*.(ts|js)', { cwd: process.cwd() + <path_to_functions> }).reduce((o, key) => ({ ...o, [key.replace(/\.(m?js|ts)$/, '')]: key }), {}).

@swyxio
Copy link
Contributor

swyxio commented Dec 3, 2018

@brianmcallister its been a while - gonna close for now - feel free to reopen if any issues

fwiw everyone here i ran into this issue myself today and figured out it was because i was accidentally nesting my functions inside folders - so i proposed this console message to make the error a bit friendlier: #84

@swyxio swyxio closed this as completed Dec 3, 2018
gburgett added a commit to gburgett/dallas-albania-connection that referenced this issue Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants