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

Use `compilerOptions.baseUrl` with Vite.js project?

I'm trying to migrate from Create React App to Vite.js, but I'm having issues with the import aliases. In Create React App I have a jsconfig.json file with compilerOptions.baseUrl set to src, so that if I import Comp from 'components/MyComponent it…
Fez Vrasta
  • 14,110
  • 21
  • 98
  • 160
3
votes
1 answer

How to get esbuild to include internal dependencies when using typescript

I am working on a vscode extension and am using esbuild to do the bundling/minification. I want to use the jsonc-parser NPM module. When I do this, esbuild runs OK but the extension won't load, giving an error "Activating extension failed: Cannot…
Peter Hull
  • 6,683
  • 4
  • 39
  • 48
3
votes
1 answer

Minify & Purge HTML/CSS/JSS

I use GitHub for source control my HTML, CSS and JS. I use Netlify / Cloudflare Pages to host my website (which is trigger off of a GitHub commit). I work with static files (.html, .js and .css) and do not use programming frameworks like Ruby on…
Mike P.
  • 47
  • 2
3
votes
3 answers

configuring esbuild with react (replacing create-react-app)

I have a bunch of files with the extension js instead of jsx. (This is a react project). I setup my package.json for build with such script: "build": "esbuild src/App.js --bundle --minify --sourcemap --outfile=public/bundle.js", Upon running it, I…
Robolisk
  • 1,682
  • 5
  • 22
  • 49
3
votes
1 answer

AWS CDK bundling lambda docker used instead of esbuild / debian WSL2

I have issues with cdk while trying to bundle lambdas with esbuild while working in my WSL2 debian esbuild is installed as a global npm package and also in devDependencies of my cdk project node --version v14.16.0 cdk --version 1.95.1 esbuild…
3
votes
1 answer

Bundling expressjs with esbuild gives missing view.js warning

I'm trying to bundle an "express.js" script with esbuild using esbuild index.js --bundle --platform=node --outfile=server.js to run as a netlify/aws lambda function and seem always to get this warning: > node_modules/express/lib/view.js: warning:…
JacobP
  • 561
  • 3
  • 21
2
votes
0 answers

How to generate a single file "ESM" bundle using ESBuild for Node.js?

In order to deploy my Node.js server to the serverless platform, I need to bundle the codebase into a single file. I have following constraints: The produced output should be single file. The produced output should run on Node.js runtime. The…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
2
votes
1 answer

esbuild hybrid plugin to bundle multiple files iife and single esm bundle

There is a project SlickGrid that have multiple files that are all written as iife (it was originally built with jQuery namespace as iife). Most files are optional and the user can choose which feature they are interested (ie slick.contextmenu.js,…
ghiscoding
  • 12,308
  • 6
  • 69
  • 112
2
votes
1 answer

esbuild import css as a string

I am using vite to build a component library. I use css?inline like this import otherStyles from './bar.css?inline' // will be available as a string And use the string to construct stylesheets in the component. see here Now I made a build script…
MrKlein
  • 95
  • 1
  • 4
2
votes
0 answers

js.erb files with esbuild in Rails 7

I would like to package a js.erb file with esbuild. In my app, a user clicks on a 'Buy' button, which is connected to a Stimulus controller. The Stimulus action redirects to Stripe, but needs a public key. I want to read that key from the Rails…
BEEK
  • 151
  • 2
  • 5
2
votes
0 answers

Is it possible to require raw files with angular browser-esbuild like in webpack?

In Webpack we can use a raw-loader to load a file like that: require('!!rawloader!./yourfile.html').default I'd like to do the same in Angular with the experimental browser-esbuild builder. With normal esbuild I could write a plugin or use it but…
Christian
  • 22,585
  • 9
  • 80
  • 106
2
votes
1 answer

Google Apps Script local Addon development with live reload

I am developing a Google Apps Script editor add-on with the following setup: src |__ client |__ gas esbuild.config.js tsconfig.json package.json src/client is a Svelte app for the add-on UI. src/gas is Google Apps Script code…
2
votes
1 answer

bin/dev: 8: exec: foreman: not found

Hello I am currently following a tutorial in order to connect react to my rails app that uses https://github.com/rails/jsbundling-rails and went with esbuild, however when I run bin/dev in my terminal I get the above error any help is appreciated as…
CoolGuy
  • 99
  • 7
2
votes
1 answer

How to Polyfill node core modules using vite

It seems that vite does not do automatic polyfills anymore - vite 4.0.0 How do you guys go about this? I have tried multiple variations of what I could find over the internet and none of them seems to be solid. ✘ [ERROR] The injected path…
Terchila Marian
  • 2,225
  • 3
  • 25
  • 48
2
votes
3 answers

Cypress - can't run tests after upgrading cucumber preprocessor

in package.json I used these versions of cucumber and esbuild with cypress: "cypress-cucumber-preprocessor": { "stepDefinitions": "cypress/support/step_definitions/**/*.{js,ts}" }, "devDependencies": { …
Darksymphony
  • 2,155
  • 30
  • 54