Open timoangerer opened 5 years ago
A workaround for the error is to add the following to your webpack.config.js
optimization: {
minimize: false
}
This will prevent Terser from trying to minify your code
I'm getting a similar issue when deploying with serverless in our bitbucket pipeline using docker image node:10.15.3. I also have mongoose installed. Although it previously had not been an issue, and we have not changed any package versions.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/swamp-conn-str/test~true' could not be found.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/swamp-conn-str/staging~true' could not be found.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/subj-area-conn-str/test~true' could not be found.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/subj-area-conn-str/staging~true' could not be found.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/quarantined-conn-str/test~true' could not be found.
Serverless Warning --------------------------------------
A valid SSM parameter to satisfy the declaration 'ssm:/swamp-filter/quarantined-conn-str/staging~true' could not be found.
Serverless: Bundling with Webpack...
Time: 17563ms
Built at: 08/09/2019 8:54:11 PM
Asset Size Chunks Chunk Names
src/function-handlers/queue/handler.js 3.9 MiB 0 src/function-handlers/queue/handler
src/function-handlers/queue/handler.js.map 4.79 MiB 0 src/function-handlers/queue/handler
Entrypoint src/function-handlers/queue/handler = src/function-handlers/queue/handler.js src/function-handlers/queue/handler.js.map
[50] external "fs" 42 bytes {0} [built]
[59] external "path" 42 bytes {0} [built]
[79] ./config/config.ts 6.32 KiB {0} [built]
[80] ./node_modules/mongoose/index.js 87 bytes {0} [built]
[161] external "module" 42 bytes {0} [built]
[249] multi ./source-map-install.js ./src/function-handlers/queue/handler.ts 40 bytes {0} [built]
[250] ./source-map-install.js 41 bytes {0} [built]
[251] ./node_modules/source-map-support/source-map-support.js 17.7 KiB {0} [built]
[252] ./node_modules/source-map/source-map.js 405 bytes {0} [built]
[259] ./node_modules/buffer-from/index.js 1.56 KiB {0} [built]
[260] ./src/function-handlers/queue/handler.ts 1.01 KiB {0} [built]
[261] ./src/runner.ts 3.64 KiB {0} [built]
[436] ./src/swamp/extract.ts 1.5 KiB {0} [built]
[465] ./src/quarantine/populate.ts 1.66 KiB {0} [built]
[466] ./src/subject-areas/retrieve.ts 630 bytes {0} [built]
+ 453 hidden modules
WARNING in ./node_modules/mongoose/lib/index.js 8:26-62
Critical dependency: the request of a dependency is an expression
@ ./node_modules/mongoose/index.js
@ ./config/config.ts
@ ./src/runner.ts
@ ./src/function-handlers/queue/handler.ts
@ multi ./source-map-install.js ./src/function-handlers/queue/handler.ts
WARNING in ./node_modules/require_optional/index.js 82:18-42
Critical dependency: the request of a dependency is an expression
@ ./node_modules/mongodb-core/index.js
@ ./node_modules/mongodb/index.js
@ ./src/util/db.ts
@ ./src/swamp/extract.ts
@ ./src/runner.ts
@ ./src/function-handlers/queue/handler.ts
@ multi ./source-map-install.js ./src/function-handlers/queue/handler.ts
WARNING in ./node_modules/require_optional/index.js 90:20-44
Critical dependency: the request of a dependency is an expression
@ ./node_modules/mongodb-core/index.js
@ ./node_modules/mongodb/index.js
@ ./src/util/db.ts
@ ./src/swamp/extract.ts
@ ./src/runner.ts
@ ./src/function-handlers/queue/handler.ts
@ multi ./source-map-install.js ./src/function-handlers/queue/handler.ts
WARNING in ./node_modules/require_optional/index.js 97:35-67
Critical dependency: the request of a dependency is an expression
@ ./node_modules/mongodb-core/index.js
@ ./node_modules/mongodb/index.js
@ ./src/util/db.ts
@ ./src/swamp/extract.ts
@ ./src/runner.ts
@ ./src/function-handlers/queue/handler.ts
@ multi ./source-map-install.js ./src/function-handlers/queue/handler.ts
ERROR in src/function-handlers/queue/handler.js from Terser
undefined
Unhandled rejection Error: Webpack compilation error, see above
at _.forEach.compileStats (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/lib/compile.js:38:19)
at arrayEach (/opt/atlassian/pipelines/agent/build/node_modules/lodash/lodash.js:516:11)
at Function.forEach (/opt/atlassian/pipelines/agent/build/node_modules/lodash/lodash.js:9342:14)
at BbPromise.fromCallback.then.stats (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/lib/compile.js:31:11)
at tryCatcher (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/promise.js:574:18)
at Promise._settlePromise0 (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/promise.js:619:10)
at Promise._settlePromises (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/promise.js:699:18)
at Promise._fulfill (/opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/promise.js:643:18)
at /opt/atlassian/pipelines/agent/build/node_modules/serverless-webpack/node_modules/bluebird/js/release/nodeback.js:42:21
at finalCallback (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js:257:39)
at hooks.done.callAsync.err (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js:273:13)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js:271:21)
at hooks.afterCompile.callAsync.err (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js:671:15)
at _err0 (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at /opt/atlassian/pipelines/agent/build/node_modules/ts-loader/dist/after-compile.js:27:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/Hook.js:154:20)
at compilation.seal.err (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js:668:31)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeAssets.callAsync.err (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compilation.js:1385:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (/opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compilation.js:1376:32)
at _err0 (eval at create (/opt/atlassian/pipelines/agent/build/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at taskRunner.run (/opt/atlassian/pipelines/agent/build/node_modules/terser-webpack-plugin/dist/index.js:321:9)
at step (/opt/atlassian/pipelines/agent/build/node_modules/terser-webpack-plugin/dist/TaskRunner.js:87:9)
at done (/opt/atlassian/pipelines/agent/build/node_modules/terser-webpack-plugin/dist/TaskRunner.js:98:30)
at boundWorkers (/opt/atlassian/pipelines/agent/build/node_modules/terser-webpack-plugin/dist/TaskRunner.js:103:13)
at /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:199:19
at process._tickCallback (internal/process/next_tick.js:61:11)
serverless version: 1.49.1 serverless-webpack version: ^5.1.1 webpack version: ^4.5.1
I can also confirm that the workaround proposed by timoangerer works for us as well.
Strangely enough, I cannot reproduce the problem locally on my mac. I've made sure to use the same version of node as well as all npm packages, and nothing. Maybe there is an ubuntu component to the issue as well?
I already created an issue and the author of Terser is working very hard to fix it: https://github.com/terser-js/terser/issues/432.
As a temporary workaround, use this config to still have minification enabled:
new TerserPlugin({
//... your other options if you have any
terserOptions: {
//... your other options if you have any
compress: {
reduce_vars: false, //when the bug is fixed this could be changed to true
},
},
}),
This is a (Bug Report / Feature Proposal)
Bug Report
Description
Steps to reproduce:
serverless create --template aws-nodejs-typescript && npm install
For bug reports:
mongoose
is most probably the problem, as soon as I import it, an error happens during bundling. The error isundefined
, so not very helpful for debugging.For feature proposals:
Similar or dependent issue(s):
12345
Additional Data