Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for built-in Esbuild in Serverless Framework v4 #267

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading