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
4
votes
0 answers

How to use a dependency that uses "require" when building an app with Vite?

I have an app (Vite + React) that depends on a library that makes use of dynamic imports in the form of: const { T } = useLocale(({ locale }) => require(`./i18n/${locale}.json`)); Unfortunately, I can't seem to be able to build my app due to this…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
4
votes
1 answer

How to import JS files with esbuild & jsbundling-rails

I'm moving a Rails 6 app from webpack & webpacker to esbuild & jsbundling-rails I can't find any documentation on the correct way to import custom js files in application.js, if not using stimulus. Thanks.
Pseudo-Hippy
  • 177
  • 11
4
votes
4 answers

Application.js not compiling after upgrading to Rails 7 on heroku with esbuild

I updated my app on Heroku from Rails 6 with Webpacker to Rails 7 with esbuild. The error I receive on production is as follows: The asset "application.js" is not present in the asset pipeline I went into my Heroku server and saw that the…
Fudge
  • 121
  • 1
  • 8
4
votes
1 answer

Reduce Javascript size in Rails app and improve performance score. Maybe issue with ESBuild?

Not specifically a Rails question, but a question within a Rails app. In my app I am using the jsbundling-rails gem configured with esbuild. This gem adds a build line to my package.json file. It works and compiles all my JS and runs fine. …
rctneil
  • 7,016
  • 10
  • 40
  • 83
4
votes
1 answer

SyntaxError: Unexpected token 'export' when using fast-components in a remix app

I'm trying to use FAST web-components in a remix application, but so far no luck. My guess at this point is that the problem comes from the build done in remix. I understand that the build is done by esbuild and that it doesn't fully work with the…
Ben
  • 674
  • 9
  • 21
4
votes
0 answers

Is anyone working on getting the styled components CSS prop working with esbuild "natively"?

I was tempted to try building a few of our applications with esbuild and it is SO MUCH FASTER ...like 300ms instead of 30 seconds or more for production. Everything worked ...except where we'd used the css prop API for styled components. I guess…
Brendan
  • 740
  • 4
  • 12
3
votes
1 answer

angular browser-esbuild error: Could not resolve absolute path [plugin angular-css-resource]

During migrating from angular v15 to v16 in a nx environment, my build process encounters with lots of errors regarding to my form of addressing assets in scss files. For example: ✘ [ERROR] Could not resolve…
Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
3
votes
2 answers

Deno bundle replacement

Could you please help me with replacing deprecetad deno bundle command? I wanted to change it for esbuild, but running a command: ./node_modules/.bin/esbuild --bundle lib/commands/abc/main.ts --outfile=mod.abc.ts give me an error: [ERROR] Top-level…
Kim Yu
  • 205
  • 2
  • 9
3
votes
0 answers

npm install for vite package gives syntax error in esbuild install.js

I am trying to install packages on VScode (npm install) with the goal of using vite and svelte and get the error messages: >esbuild@0.17.12 postinstall C:\Users\smurf\Data Visualisation\javascript\datavis-main\node_modules\esbuild > node…
3
votes
1 answer

ESBuild post-install failed when installing Vite

I am using Vite as a bundler for a Nodejs project. When first installing Vite, everything is fine. But when I tried to install other packages again, I ran into the following error: node_modules/esbuild postinstall$ node install.js │…
Sam Zhang
  • 320
  • 4
  • 17
3
votes
1 answer

Rails 7 + esbuild + React flicker when changing pages

I have a new Rails project using esbuild with React. The setup is pretty standard:
And then a: import { Controller } from "@hotwired/stimulus" import React from "react"; import…
MB.
  • 4,167
  • 8
  • 52
  • 79
3
votes
1 answer

TypeScript serverless-esbuild exclude "*" (full node_modules) doesn't seem to work

I use serverless-layers plugin in Serverless Framework so I'd like to exclude node_modules directory from esbuild. According to the official document, I can set "*" to the exclude option of serverless-esbuild to exclude the full node_modules…
Akumachan
  • 81
  • 2
  • 9
3
votes
0 answers

How to include type definitions in js library bundled with esbuild

I am working on a JS library to be published in npm with TypeScript and esbuild. My esbuild command successfully minifies all of my .ts files into a single .js file. The problem is there are no type definitions, so if I publish just the .js file,…
abc
  • 1,141
  • 12
  • 29
3
votes
2 answers

esbuild build does not bundle the public directory

I decided to use esbuild to bundle my express API. So far all is good, except that the public directory which holds the swagger UI is not being bundled with the rest of the application. I have an endpoint defined as a static route which serves that…
Terchila Marian
  • 2,225
  • 3
  • 25
  • 48
3
votes
1 answer

Rails 7, React & Esbuild - Static assets not served in production

I have created a simple new Rails 7 project from scratch with Esbuild and React to get to know these, and they indeed feel like a step up from Webpack, except I can't manage to have my static files (ie image) served in production. I have an Esbuild…
Alexfo
  • 31
  • 3
1 2
3
21 22