Skip to content

Commit dbc4e92

Browse files
authored
add support for Serverless projects with esbuild source config (#195)
1 parent 362bc6f commit dbc4e92

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/node_modules
44
example/service/.serverless
55
example/service/.serverless_plugins
6+
.idea

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ localstack start --docker -d \
8787
-v /path/to/project-b:/path/to/project-b
8888
```
8989

90-
If you use either `serverless-webpack` or `serverless-plugin-typescript`, `serverless-localstack`
90+
If you use either `serverless-webpack`, `serverless-plugin-typescript`, or `serverless-esbuild`, `serverless-localstack`
9191
will detect it and modify the mount paths to point to your output directory. You will need to invoke
9292
the build command in order for the mounted code to be updated. (eg: `serverless webpack`). There is no
9393
`--watch` support for this out of the box, but could be accomplished using nodemon:
@@ -96,7 +96,7 @@ the build command in order for the mounted code to be updated. (eg: `serverless
9696
npm i --save-dev nodemon
9797
```
9898

99-
`package.json`:
99+
Webpack example's `package.json`:
100100

101101
```json
102102
"scripts": {

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const TYPESCRIPT_PLUGIN_BUILD_DIR_TSC = '.build'; //TODO detect from tsconfig.js
1515
// Plugin naming and build directory of serverless-webpack plugin
1616
const TS_PLUGIN_WEBPACK = 'ServerlessWebpack'
1717
const TYPESCRIPT_PLUGIN_BUILD_DIR_WEBPACK = '.webpack/service'; //TODO detect from webpack.config.js
18+
// Plugin naming and build directory of serverless-webpack plugin
19+
const TS_PLUGIN_ESBUILD = 'EsbuildServerlessPlugin'
20+
const TYPESCRIPT_PLUGIN_BUILD_DIR_ESBUILD = '.esbuild/.build'; //TODO detect from esbuild.config.js
1821

1922
// Default edge port to use with host
2023
const DEFAULT_EDGE_PORT = '4566';
@@ -248,6 +251,7 @@ class LocalstackPlugin {
248251
detectTypescriptPluginType() {
249252
if (this.findPlugin(TS_PLUGIN_TSC)) return TS_PLUGIN_TSC
250253
if (this.findPlugin(TS_PLUGIN_WEBPACK)) return TS_PLUGIN_WEBPACK
254+
if (this.findPlugin(TS_PLUGIN_ESBUILD)) return TS_PLUGIN_ESBUILD
251255
return undefined
252256
}
253257

@@ -256,6 +260,7 @@ class LocalstackPlugin {
256260
const TS_PLUGIN = this.detectTypescriptPluginType()
257261
if (TS_PLUGIN === TS_PLUGIN_TSC) return TYPESCRIPT_PLUGIN_BUILD_DIR_TSC
258262
if (TS_PLUGIN === TS_PLUGIN_WEBPACK) return TYPESCRIPT_PLUGIN_BUILD_DIR_WEBPACK
263+
if (TS_PLUGIN === TS_PLUGIN_ESBUILD) return TYPESCRIPT_PLUGIN_BUILD_DIR_ESBUILD
259264
return undefined
260265
}
261266

0 commit comments

Comments
 (0)