serverless-bundle
serverless-bundle copied to clipboard
serverless-bundle v5: TypeError: Cannot read property '1' of null
I just tried upgrading to v5 I am getting Webpack build failure.
My project does not have a webpack config file. When I remove the plugin from the package it eventually builds. Also when I downgrade to 4.4.0, it works as expected.
Not sure where to raise this issue.
I am using sls webpack command for building locally and on CI/CD server.
Serverless: Bundling with Webpack...
Type Error ----------------------------------------------
TypeError: Cannot read property '1' of null
at getExternalModuleName (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:31:61)
at isExternalModule (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:44:77)
at getExternalModules (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:75:9)
at __PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:102:24
at arrayMap (__PROJECT_PATH__/node_modules/lodash/lodash.js:653:23)
at Function.map (__PROJECT_PATH__/node_modules/lodash/lodash.js:9622:14)
at __PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:100:14
at finalCallback (__PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:425:32)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:489:17
at __PROJECT_PATH__/node_modules/webpack/lib/HookWebpackError.js:68:3
at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at Cache.storeBuildDependencies (__PROJECT_PATH__/node_modules/webpack/lib/Cache.js:122:37)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:485:19
at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:482:23
at Compiler.emitRecords (__PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:874:39)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:474:11
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:856:14
at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:853:27
at __PROJECT_PATH__/node_modules/neo-async/async.js:2818:7
at done (__PROJECT_PATH__/node_modules/neo-async/async.js:3522:9)
at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:707:33
at __PROJECT_PATH__/node_modules/graceful-fs/graceful-fs.js:143:16
at __PROJECT_PATH__/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (fs.js:180:23)
From previous event:
at webpackCompile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:89:64)
at BbPromise.map.concurrency.concurrency (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:108:43)
From previous event:
at webpackConcurrentCompile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:108:20)
at ServerlessPlugin.compile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:125:12)
From previous event:
at Object.webpack:compile:compile [as hook] (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:164:61)
at PluginManager.invoke (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:579:20)
at PluginManager.spawn (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:601:16)
at ServerlessPlugin.<anonymous> (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:156:53)
at processImmediate (internal/timers.js:464:21)
From previous event:
at Object.webpack:webpack [as hook] (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:156:12)
at PluginManager.invoke (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:579:20)
at PluginManager.run (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:639:18)
at async Serverless.run (__PROJECT_PATH__/node_modules/serverless/lib/Serverless.js:452:5)
at async __PROJECT_PATH__/node_modules/serverless/scripts/serverless.js:795:9
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.17.3
Framework Version: 2.57.0 (local)
Plugin Version: 5.4.4
SDK Version: 4.3.0
Components Version: 3.17.0
Hi,
This is a serverless-webpack issue with webpack >= 5.52.0.
Quick fix would be to lock webpack version to 5.51.2.
Quick fix would be to lock webpack version to 5.51.2.
@hrougier I assume you mean for the serverless-bundle to downgrade webpack version since my project does not have webpack as explicit dependency.
If you can confirm that this fixes the issue, please submit a PR and I'll cut a release with it.
Hi! Any updates? I am having this exact issue.
For me it worked with webpack version 5.51.2
complete package.json
"dependencies": {
"aws-sdk": "^2.978.0",
"serverless-webpack": "",
"webpack-node-externals": "",
"webpack": "5.51.2",
"babel-loader": "",
"@babel/core": "",
"babel-plugin-source-map-support": "",
"@babel/preset-env": ""
}
}
Thanks! Anybody want to submit a PR with this change?
i start learning sls+ts+lambda and i have the exact same issue, the fix work
For me it worked with
webpackversion5.51.2complete package.json
"dependencies": { "aws-sdk": "^2.978.0", "serverless-webpack": "", "webpack-node-externals": "", "webpack": "5.51.2", "babel-loader": "", "@babel/core": "", "babel-plugin-source-map-support": "", "@babel/preset-env": "" } }
i start learning sls+ts+lambda and i have the exact same issue, the fix work
[email protected] has been released a couple hours ago, it should fix this issue with webpack >= 5.52.0
Edit: one would need to submit a PR to bump [email protected] in serverless-bundle, sorry I only use serverless-webpack not serverless-bundle but glad to help!
Same issue here. As others have mentioned, it seems that [email protected] corrects the issue with webpack 5.52.0.
Published: https://github.com/AnomalyInnovations/serverless-bundle/releases/tag/v5.0.1
@panchosoft
Same issue here. As others have mentioned, it seems that [email protected] corrects the issue with webpack 5.52.0.
Indeed. By forcing serverless-webpack in package.json to 5.5.4 and runnining yarn I could finally run sls deploy without errors.