Questions tagged [esbuild]

esbuild is a fast bundler for JavaScript and its related languages (e.g. TypeScript, JSX, JSON, and CSS) with support for both the browser and node. This tag is specific for the esbuild bundler and is not used for general questions about bundling ES modules.

esbuild is a fast bundler for JavaScript and its related languages (e.g. TypeScript, JSX, JSON, and CSS, as well as some content formats, like Text and Binary, are all supported by default without needing to install plugins).

esbuild's primary goal is performance (claiming to be 104 times faster than webpack 5 in certain benchmarks), with ease-of-use and support for modern syntax listed as important secondary goals ("create an easy-to-use modern bundler along the way").

esbuild supports transforming modern JavaScript syntax into older equivalents based on specified target environments. Supported targets include:

  • All major browsers (e.g. chrome, edge, firefox, ie, safari, and others)
  • JavaScript language versions (e.g. "es2022")
  • node (e.g. "node12.19.0").

Note that support for very old targets (like ES5) is currently limited and may produce errors.

Useful Links

317 questions
7
votes
2 answers

Does esbuild provide a feature like the resolve.alias option in webpack?

Does esbuild provide a feature like the resolve.alias option in webpack? const path = require('path'); module.exports = { //... resolve: { alias: { Utilities: path.resolve(__dirname, 'src/utilities/'), Templates:…
doberkofler
  • 9,511
  • 18
  • 74
  • 126
7
votes
4 answers

EsBuild StartService replacement

I am new to esBuild and ReactJS and following a guid I decided to building a custom CLI Transpiling application. I got to the point that I am entering a text in textarea but on the console in the client the following error message came out Host…
DraksBG
  • 137
  • 1
  • 9
7
votes
1 answer

How to expose a class to the global scope with esbuild?

Update user @TKoL suggested defining a property in the window object. This produces the result I wanted to achieve, although I do not know if it is the correct way to proceed. I will be using this method for the time being. Thanks! I am using…
Khryus
  • 347
  • 3
  • 12
6
votes
3 answers

esbuild throwing `[ERROR] Could not resolve [import statement]` while setting up Ruby on Rails 7/React application

I am trying to set up my first Ruby on Rails 7 with a React app. I installed Ruby on Rails with the esbuild flag: rails new project_name -d postgresql -j esbuild I Yarn added react, react-dom and react-router-dom. I also created a React…
baconsocrispy
  • 81
  • 2
  • 8
6
votes
0 answers

How to configure esbuild to use css-modules and sass/scss for when bundling?

Background: I am attempting to extend esbuild's CSS support to include CSS Modules and Sass/Scss. I have therefore been making use of custom made plugins--utilising the esbuild plugin API. First, I tried: esbuild-sass-plugin: As the name suggests,…
slackermorris
  • 368
  • 3
  • 11
6
votes
5 answers

AWS SAM - Esbuild Failed: cannot find esbuild

I'm trying out AWS SAM with nodeJS and Typescript using 'sam init', but when I want to build the example hello-world-typescript application using 'sam build', I get the following message: Building codeuri: C:\RF\GitHub\rf-09-06\hello-world runtime:…
Toba
  • 61
  • 1
  • 3
6
votes
0 answers

ESBuild in NextJS: "You may need an appropriate loader to handle this file type" - /node_modules/esbuild/lib/main.d.ts

I am using mdx-bundler (which uses esbuild + node-gyp) in next.js. I have been working on this project for some time and everything is working. Now my partner just cloned the repo and tried to get it working but she…
antonwilhelm
  • 5,768
  • 4
  • 19
  • 45
6
votes
1 answer

How to set up Vue.js with Rails 7 and esbuild

I set up a new Rails 7 project with esbuild: rails new my_project -j esbuild I then added Vue.js with yarn add vue. I can see that Vue was added successfully to my package.json file: { "name": "app", "private": "true", "dependencies": { …
DaniG2k
  • 4,772
  • 36
  • 77
6
votes
1 answer

Load bootstrap JS with esbuild

I'm trying to import the bootstrap JS in my esbuild build: // index.js import 'jquery-import' import 'bootstrap' // jquery-import.js import jquery from 'jquery' window.jQuery = window.$ = jquery; The build target is esm. The problem is that the…
sudoremo
  • 2,274
  • 2
  • 22
  • 39
6
votes
1 answer

Testing React app with Jest, using Vite as a module Bundler; import.meta error

i am testing a React-Typescript application with Jest; my application uses Vite as a module bundler. The issue is, everytime i run tests and jest encounters an import.meta.ENV_VAR_NAME statement i get the following error: "SyntaxError: Cannot use…
RettoScorretto
  • 125
  • 1
  • 7
5
votes
3 answers

Can't access exported functions in bundled .js file using esbuild

I want to create a library using TypeScript. It should be available for Node and Browser environments. I started with the package.json file and installed esbuild as a dependency and typescript as a dev dependency. The result is { "name":…
user17298649
4
votes
0 answers

build sharp for specific platform with esbuild and deploy it with NodejsFunction lambda

I'm trying to deploy a Lambda function which uses sharp for image processing. I do not want to use docker builds -- I have to use esbuild. Here is my lambda definition in cdk: const processUploadedImageLambdaFunction = new NodejsFunction( …
4
votes
1 answer

Invalid option in build() call: "watch"

I am following the example as it is described here: https://bilalbudhani.com/chokidar-esbuild/ When I do: node esbuild.config.js --watch I get the message: [ERROR] Invalid option in build() call: "watch" I have no idea why this is happening. Is…
Nick_K
  • 541
  • 6
  • 22
4
votes
1 answer

How to include static files into the lambda package with AWS SAM esbuild?

I have a NodeJS AWS Lambda function which generates an e-mail based on a html template file (emailTemplate.html). I started building my lambdas with esbuild via SAM. Now I wonder how I can configure SAM/esbuild to include this file into my lambda…
Tim Van Laer
  • 2,434
  • 26
  • 30
4
votes
0 answers

React 17 ESbuild - Problem with @emotion/react, export 'useInsertionEffect' (imported as 'React') was not found in 'react'

how are you? I have a project with React 17 and babel-loader and i'm trying to change it to esbuild-loader. For this i installed "esbuild-loader": "2.19.0" and changed my webpack loader config to this: { test: /\.js$/, loader: 'esbuild-loader', …
Rohr Facu
  • 607
  • 1
  • 12
  • 29
1
2
3
21 22