For bug reports:
Cannot read property '1' of null after successful bundling.What did you expect should have happened?
It correctly deploys.
What was the config you used?
Quite huge and generated from pipeline env vars, but it shouldn't matter. Because it is the module identifier changed.
The regular expression below does not match the actual module identifier string 'external commonjs "aws-sdk"',
https://github.com/serverless-heaven/serverless-webpack/blob/fa2370d8902f4d5e2ad50ab0c06490b6eb9acf0c/lib/compile.js#L31
It seems like webpack added the keyword "commonjs" in the middle.
What stacktrace or error message from your provider did you see?
TypeError: Cannot read property '1' of null
at getExternalModuleName (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:32:61)
at isExternalModule (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:45:77)
at getExternalModules (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:76:9)
at /Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:103:24
at arrayMap (/Users/vicary/Documents/[REDACTED]/node_modules/lodash/lodash.js:653:23)
at Function.map (/Users/vicary/Documents/[REDACTED]/node_modules/lodash/lodash.js:9622:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:101:14
at tryCatcher (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:673:18)
at /Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/nodeback.js:42:21
at finalCallback (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:425:32)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:489:17
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/HookWebpackError.js:68:3
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at Cache.storeBuildDependencies (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Cache.js:122:37)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:485:19
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:482:23
at Compiler.emitRecords (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:874:39)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:474:11
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:856:14
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:853:27
at /Users/vicary/Documents/[REDACTED]/node_modules/neo-async/async.js:2818:7
at done (/Users/vicary/Documents/[REDACTED]/node_modules/neo-async/async.js:3522:9)
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:707:33
at /Users/vicary/Documents/[REDACTED]/node_modules/graceful-fs/graceful-fs.js:143:16
at /Users/vicary/Documents/[REDACTED]/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:188:23)
From further sampling, it sometimes contains "node-commonjs" in the middle.
/^external .*"(.*?)"$/ should fit both cases.
I just hit this as well after upgrading some dependencies. I was able to resolve it by downgrading webpack from 5.52.0 to 5.51.2 (which is very strange to me).
This may also have something to do with NPM bugs. I've noticed an issue with the acorn peer dependency from webpack + eslint + jest: if you're using node 14 + npm 6, npm will fail to find the correct acorn peer dependency for one of webpack's transitive dependencies. The resolution is to uninstall webpack, jest, and eslint, then install webpack, then install jest and eslint. (Doing all 3 in a single command generates a failure.) Webpack maintainers have identified this as a "bug in npm" (without any further information): https://github.com/webpack/webpack/issues/13935
I just hit this as well after upgrading some dependencies. I was able to resolve it by downgrading webpack from 5.52.0 to 5.51.2 (which is very strange to me).
This may also have something to do with NPM bugs. I've noticed an issue with the acorn peer dependency from webpack + eslint + jest: if you're using node 14 + npm 6, npm will fail to find the correct acorn peer dependency for one of webpack's transitive dependencies. The resolution is to uninstall webpack, jest, and eslint, then install webpack, then install jest and eslint. (Doing all 3 in a single command generates a failure.) Webpack maintainers have identified this as a "bug in npm" (without any further information): webpack/webpack#13935
this was also my experience, I removed the node_modules path, installed webpack 5.51.2 and then installed the remaining assets with a npm i -- it works now
I am not sure about the story behind webpack's change on module identifiers.
@j0k3r care to make a comment? I can start a PR if you think the regex fix is good enough.
Looks like it appears here https://github.com/webpack/webpack/pull/14118 (here) with no more information on what is fixed and nothing show up in the changelog.
Anyway please start a PR about it and it you can add a real test to cover that change from webpack, it might be awesome, thanks @vicary !
I finally provided a fix https://github.com/serverless-heaven/serverless-webpack/pull/953
@j0k3r Wow that was quick, thanks a lot!
Most helpful comment
I just hit this as well after upgrading some dependencies. I was able to resolve it by downgrading webpack from 5.52.0 to 5.51.2 (which is very strange to me).
This may also have something to do with NPM bugs. I've noticed an issue with the acorn peer dependency from webpack + eslint + jest: if you're using node 14 + npm 6, npm will fail to find the correct acorn peer dependency for one of webpack's transitive dependencies. The resolution is to uninstall webpack, jest, and eslint, then install webpack, then install jest and eslint. (Doing all 3 in a single command generates a failure.) Webpack maintainers have identified this as a "bug in npm" (without any further information): https://github.com/webpack/webpack/issues/13935