Description
Hi,
I've recently added a new lambda function with mainly serverless-http, apollo-server-express, graphql-modules and got this error when starting, preventing to run the server:
➜ yarn lambda-serve
yarn run v1.15.2
$ NODE_ENV=development netlify-lambda -c ./netlify.webpack.functions.js serve lambda-src
netlify-lambda: Starting server
Hash: e5ff9126f80c7609c6e2
Version: webpack 4.29.6
Time: 7100ms
Built at: 04/18/2019 6:49:38 AM
Asset Size Chunks Chunk Names
0.js 8.29 MiB 0 [emitted]
1.js 19.5 KiB 1 [emitted]
2.js 673 bytes 2 [emitted]
graphql.js 9.84 MiB graphql [emitted] graphql
Entrypoint graphql = graphql.js
[...]
path.js:39
throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at Object.join (path.js:1157:7)
at Object.clearCache (/workspace/cfa/pronostics-lyonnais/node_modules/netlify-lambda/lib/serve.js:183:25)
I use netlify-lambda v1.4.5 but I've met this issue in the previous version too.
The error is thrown by clearCache, because 3 chunks have an undefined name, and come from this piece of code:
stats.compilation.chunks.forEach(function(chunk) {
server.clearCache(chunk.name);
});
Those chunks are created in the lambda function with the id instead (0.js, 1.js, ...) and seem to be related to typescript (but I don't use typescript at all in my source code), and graphql-related libraries like graphql-import.
Also, just in case, here is my webpack custom config:
module.exports = {
mode: 'development',
plugins: [new webpack.DefinePlugin({ 'global.GENTLY': false })],
resolve: {
alias: {
lib: path.resolve(__dirname, 'lambda-src/lib/'),
'@client': path.resolve(__dirname, 'src/'),
},
// modules: ['node_modules', path.resolve(__dirname, 'lambda-src')],
},
module: {
rules: [
{
test: /\.mjs$/,
type: 'javascript/auto',
include: /node_modules/,
use: [],
},
],
},
};
From my understanding we should fallback to chunk.id if chunk.name is undefined, when clearing the cache.