localstack / localstack/serverless-localstack
Issue with working serverless-webpack
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 542
- 分支
- 92
- PR 合併指標
- 30 天內沒有已合併 PR
描述
As the documentation says, I added this configuration inside my custom property in the serverless.yaml
localstack:
stages:
# list of stages for which the plugin should be enabled
- local
- development
host: http://localhost # optional - LocalStack host to connect to
edgePort: 4566 # optional - LocalStack edge port to connect to
autostart: true # optional - Start LocalStack in Docker on Serverless deploy
networks: #optional - attaches the list of networks to the localstack docker container after startup
- host
- overlay
lambda:
# Enable this flag to improve performance
mountCode: true # specify either "true", or a relative path to the root Lambda mount path
The webpack config is this for the serverless:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
excludeFiles: tests/**/*.{js,ts}
keepOutputDirectory: true
This is the webpack configuration:
const path = require('path');
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: slsw.lib.entries,
target: 'node',
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
minimize: false,
},
plugins: [],
performance: {
// Turn off size warnings for entry points
hints: false,
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader?configFile=tsconfig.build.json',
exclude: [/node_modules/, /tests/],
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
libraryTarget: 'commonjs2',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
cache: {
type: 'filesystem',
},
};
And I'm getting this error:
Execution environment startup failed: {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'a-handler'\nRequire stack:\n- /var/runtime/index.mjs","trace":["Runtime.ImportModuleError: Error: Cannot find module 'a-handler'","Require stack:","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:1087:17)"," at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]}
And it looks like is because the handler path is incorrect, it says this
'_HANDLER': '.webpack/service/src/a-dir/a-handler.handle'
But when webpack package the code is located in .webpack/a-dir/a-handler.handle, what would be the solution for that, I'm kind of lost, should I update the output path?
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先從 serverless.yaml 中的 handler 設定和 webpack.config.js 開始,然後將產生的 .webpack 路徑與錯誤中顯示的 _HANDLER 值進行比較。檢查 plugin 和 serverless-webpack 如何推導封裝後 handler 的路徑。當已部署的 handler 路徑與產生的 .webpack/a-dir/a-handler.handle 位置一致,且 LocalStack 呼叫成功啟動時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, webpack
- 領域
- cloud
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100