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
2
votes
1 answer

How create bundle with esbuild with import modules

i have this module import * as cborg from 'cborg' import { CID } from 'multiformats/cid' function cidEncoder (obj) { } .... when i build module with this command line "bundle": "./node_modules/.bin/esbuild ./dist/index.mjs --bundle …
Sergey
  • 418
  • 1
  • 7
  • 21
2
votes
1 answer

How to load custom JS in Rails 7 ESBuild project?

I have Rails 7.0.4. I generated the project using this command. rails new myproject --database=postgresql -j esbuild --css bootstrap Thus, I don't have a file named config/importmap.rb. How do I load a single file with custom JS? I tried creating a…
PrimeTimeTran
  • 1,807
  • 2
  • 17
  • 29
2
votes
0 answers

Module not found Error: Can't resolve '@swc/core' and 'esbuild'

Error Log ERROR in Error: Child compilation failed: Module not found: Error: Can't resolve '@swc/core' in '/Users/monish/code/my-app/node_modules/terser-webpack-plugin/dist' ModuleNotFoundError: Module not found: Error: Can't resolve…
narwanimonish
  • 1,552
  • 17
  • 13
2
votes
0 answers

Use esbuild-loader for webpack and typescript while also using type declaration files in project?

I'm looking to switch from ts-loader to esbuild-loader in webpack to improve build times / watch compile times. In our project, we use various type delceration files .d.ts to load types/interfaces etc. However running the esbuild-loader get a bunch…
Carson Wood
  • 1,174
  • 3
  • 14
  • 23
2
votes
0 answers

Cannot import custom components with mdx-bundler and nextjs

I remotely get the content from Strapi API: import CookieSettings from './components/shared/buttons/cookieSettings' Some content... then I prepare mdx during entities adaptation, this function is in a separate folder and it's…
Atomike-Toxic
  • 212
  • 1
  • 4
  • 12
2
votes
1 answer

typescript - Esbuild - Unexpected token '<'

Compiling TypeScript files for a React app with esbuild. It is successfully compiling, but in the browser an error is shown in the console: Uncaught SyntaxError: Unexpected token '<' after the return //…
2
votes
1 answer

esbuild failed: word unexpected (expecting ")")

I was preparing a Docker image for my umbrella elixir application. I am using esbuild for assets compilation. esbuild is installed using as npm package. Dockerfile: # copy umbrella app COPY ./apps/gpanel ./apps/gpanel ... # compile assets RUN mix…
2
votes
0 answers

how to set up a react on rails 7 app with esbuild for production

I have a rails 7 app with react as the front-end. I have esbuild as the bundler for the app. Everything works fine in development, but when I push the app to heroku, the css/scss and imported react images don't work. This is my setup: rails new…
Lyte
  • 59
  • 5
2
votes
0 answers

Action Text [Rails 7 Error] vanishing field

Trying to isolate an error I'm getting with the basic setup of a new blog site using the below just so I can test Action_Text for the create blog section. Every-time i create the below- it works great until i change the <%= form.text_area :content…
Karl
  • 21
  • 3
2
votes
1 answer

Is there a way to easily remove devDependencies from the final bundle with esbuild

I'm using esbuild to package my lambdas functions. However, when generating the build of them to perform the deployment, I get an alert that the package is too big, as in the image below. File to big I found in the documentation a way to remove…
2
votes
1 answer

How to include css into bundled js instead of seperate file with esbuild?

It always generates two files - main.js and main.css, how can I force it to include css into main.js? I looked through documentation but there seem to be no mentions on how to do it. Here is my config: import process from 'process'; import esbuild…
Borouch
  • 103
  • 4
2
votes
0 answers

esbuild: How to prevent transpiled js from using eval?

I am trying to make a chrome extension with esbuild and ts react with a build file that looks something like this. require('esbuild') .build({ entryPoints: [ 'src/contentScript.ts', 'src/index.html', ], …
sdfsdf
  • 5,052
  • 9
  • 42
  • 75
2
votes
1 answer

How automatically load all js controller files in Rails 7 with esbuild as JavaScript bundler

I'm trying to configure Rails 7 app to load all js Stimulus controllers automatically. I use esbuild as JavaScript bundler. If we're using Stimulus for Rails together with an import map, the integration will automatically load all controller files…
Yurii Stefaniuk
  • 1,594
  • 2
  • 11
  • 16
2
votes
3 answers

Bundling versus debugging in a Visual Studio Code extension

I have written an extension for VS Code and now am creating a package for it. It is recommended then to bundle the files, which I do with esbuild. Packaging works, but it leaves me with a dilemma. In package.json, I can either write "main":…
m-q
  • 29
  • 7
2
votes
1 answer

remix Cannot find module '@emotion/server/types/create-instance'

I would like to use @mui/material with remix run. I follow this example https://github.com/mui/material-ui/blob/master/examples/remix-with-typescript/app/entry.server.tsx Also I follow blues stack https://github.com/remix-run/blues-stack After npm…
Serfi
  • 71
  • 7