Socket
Socket
Sign inDemoInstall

arc-plugin-esbuild

Package Overview
Dependencies
72
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arc-plugin-esbuild

Use Typescript and esbuild with arc.codes!


Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

arc-plugin-esbuild

Bundles arc functions with esbuild, includes dependencies and tree shakes!

Arc serverless framework plugin for compiling your functions with ESBuild Bundler

Install

npm i --save-dev arc-plugin-esbuild

Usage

After installing add @plugins and @esbuild pragmas to your app.arc file:

app.arc

@app
myapp

@esbuild

@http
get /

@plugins
arc-plugin-esbuild

File listing;

myapp/app.arc
myapp/package.json
myapp/tsconfig.json
myapp/src/http/get-index/index.ts

It's also worth ignoring the build artifacts.

#.gitignore

src/**/*.js
!src/macros/*.js  # these are not transpiled
!src/plugins/*.js # these are not transpiled
.esbuild

Options

This plugin supports the following options under the @esbuild pragma:

OptionDescriptionExample
buildDirectoryThe directory to write the bundled files to. This directory will be used at deploy-time before bundling your functions for deployment. Defaults to .esbuild.buildDirectory .esbuild
entryFilePatternA glob representing the file that should be used as entry point into your bundle. At arc deploy time, this pattern will be scoped to each Lambda function's directory before bundling each Lambda separately. At arc sandbox time, this pattern will be appended to src/**/ when setting up the watcher process. If not specified the default will be index.{ts,tsx}.entryFilePattern index.{ts,tsx}
externalesbuild package externals defaults to aws-sdkexternal prisma aws-sdk

Sandbox

Running arc sandbox kicks up the local development server Architect provides. This plugin hooks into sandbox execution to watch and compile any typescript files located under your project's src/ directory (using the glob ./src/**/<entry option || index.ts>). It will create index.js files in each of your arc project's Lambda function folders on sandbox startup, and will remove those when sandbox shuts down.

It's recommended to gitignore the output js files.

Deploy

Running arc deploy will bundle all functions using esbuild into your buildDirectory-specified folder instead of ./src, and use the bundled code when deploying your functions to AWS.

Sample Application

There is a sample application located under sample-app/. cd into that directory, npm install and you can run locally via arc sandbox or deploy to the internet via arc deploy.

⚠️ Known Issues

Order of Arc Plugins Matter

You probably want to list this plugin last under the @plugins section of your app.arc because plugins are executed in the order that they appear in your application manifest. If you run this plugin before another plugin that creates Lambdas, then the Lambda function code from the plugin will not be bundled.

Mixing and Matching JS and TS

Mixing and matching JS and TS index files will work!. The entryFilePattern will need to be adjusted to match js files eg index.{ts,tsx,js,jsx}

Keywords

FAQs

Last updated on 14 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc