Skip to content

Commit

Permalink
feat: add support for built-in esbuild in Serverless Framework v4 (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
czubocha authored Oct 31, 2024
1 parent 5901186 commit 62b9d5e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const TYPESCRIPT_PLUGIN_BUILD_DIR_WEBPACK = '.webpack/service'; //TODO detect fr
// Plugin naming and build directory of serverless-webpack plugin
const TS_PLUGIN_ESBUILD = 'EsbuildServerlessPlugin';
const TYPESCRIPT_PLUGIN_BUILD_DIR_ESBUILD = '.esbuild/.build'; //TODO detect from esbuild.config.js
// Plugin naming and build directory of esbuild built-in with Serverless Framework
const TS_PLUGIN_BUILTIN_ESBUILD = 'Esbuild';
const TYPESCRIPT_PLUGIN_BUILD_DIR_BUILTIN_ESBUILD = '.serverless/build'; //TODO detect from esbuild.config.js

// Default AWS endpoint URL
const DEFAULT_AWS_ENDPOINT_URL = 'http://localhost:4566';
Expand Down Expand Up @@ -292,6 +295,13 @@ class LocalstackPlugin {
if (this.findPlugin(TS_PLUGIN_TSC)) return TS_PLUGIN_TSC;
if (this.findPlugin(TS_PLUGIN_WEBPACK)) return TS_PLUGIN_WEBPACK;
if (this.findPlugin(TS_PLUGIN_ESBUILD)) return TS_PLUGIN_ESBUILD;
const builtinEsbuildPlugin = this.findPlugin(TS_PLUGIN_BUILTIN_ESBUILD);
if (builtinEsbuildPlugin &&
builtinEsbuildPlugin.constructor &&
typeof builtinEsbuildPlugin.constructor.WillEsBuildRun === 'function' &&
builtinEsbuildPlugin.constructor.WillEsBuildRun(this.serverless.configurationInput, this.serverless.serviceDir)) {
return TS_PLUGIN_BUILTIN_ESBUILD;
}
return undefined;
}

Expand All @@ -303,6 +313,9 @@ class LocalstackPlugin {
return TYPESCRIPT_PLUGIN_BUILD_DIR_WEBPACK;
if (TS_PLUGIN === TS_PLUGIN_ESBUILD)
return TYPESCRIPT_PLUGIN_BUILD_DIR_ESBUILD;
if (TS_PLUGIN === TS_PLUGIN_BUILTIN_ESBUILD) {
return TYPESCRIPT_PLUGIN_BUILD_DIR_BUILTIN_ESBUILD;
}
return undefined;
}

Expand Down

0 comments on commit 62b9d5e

Please sign in to comment.