chihab / dotenv-run

Seamlessly load environment variables. Supports cli, esbuild, rollup, vite, webpack, angular. ESM and Monorepos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESBuild Support?

AmGarera opened this issue · comments

Hi,

Like the Angular team has started to do in v14 and v15 by adding ESBuild as a preview is there any chance the same support could be added here?
The build times are drastically faster as seen in the picture below.
source: https://blog.angular.io/angular-v15-is-now-available-df7be7f2f4c8
image

The @angular-devkit/build-angular:browser-esbuild builder is missing the ability to transform the ESBuild configuration as it's done in @angular-devkit/build-angular:browser
More details in this issue: angular/angular-cli#24163

Note: ESBuild supports a similar transformation https://esbuild.github.io/api/#define, waiting for the final builder interface to support it.

Awesome thanks for the response! After reading through that issue it makes a ton of sense.

It looks that it is now possible to override ESBuild configuration angular/angular-cli#24163

I'll work on that asap in preparation of v17.

Any help would be appreciated.

It looks that it is now possible to override ESBuild configuration angular/angular-cli#24163

I'll work on that asap in preparation of v17.

Any help would be appreciated.

@chihab I created a fork to implement the necessary changes for angular 17. I was able to use angular's new builder ("@angular-devkit/build-angular:application") and its exposed functionality to add environment variables. However, the process of replacing variables in the index.html (e.g. %NG_APP_ENV%) is causing me problems, because unlike webpack it seems that in esbuild there is no direct way to manipulate the index. Angular itself manipulates the index after running esbuild... Do you have any suggestions for overcoming this problem?

@luca-peruzzo not really.

I'm still struggling to get the esbuild plugin to work as expected. See angular/angular-cli#26326

I'd be interested to know how you got it to work.

If you have something ready, you can send a PR even if index.html is not supported we can indicate it as a limitation...

@luca-peruzzo not really.

I'm still struggling to get the esbuild plugin to work as expected. See angular/angular-cli#26326

I'd be interested to know how you got it to work.

If you have something ready, you can send a PR even if index.html is not supported we can indicate it as a limitation...

@chihab I found a way to modify index.html, I will update the pull request

Many thanks to @luca-peruzzo for his work on the esbuild support.

A new version has been published in alpha, please give it a try.

npx ng add @ngx-env/builder