localstack / localstack/serverless-localstack

Issue with working serverless-webpack

オープン
#266 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

serverless-webpack status: backlog status: response required
主要言語
JavaScript
スター
542
フォーク
92
PR マージ指標
30日以内にマージされた PR はありません

説明

As the documentation says, I added this configuration inside my `custom` property in the serverless.yaml

```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:

```yaml
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
excludeFiles: tests/**/*.{js,ts}
keepOutputDirectory: true
```

This is the webpack configuration:

```js
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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず serverless.yaml のハンドラー設定と webpack.config.js を確認し、次に生成された .webpack パスとエラーに表示される _HANDLER の値を比較します。plugin と serverless-webpack がパッケージ化されたハンドラーのパスをどのように導出しているかを確認します。デプロイされたハンドラーのパスが生成された .webpack/a-dir/a-handler.handle の場所と一致し、LocalStack の呼び出しが正常に開始されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, webpack
領域
cloud
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。