oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.21k stars 2.77k forks source link

Support index.html as an entrypoint #4688

Open Klohto opened 1 year ago

Klohto commented 1 year ago

What is the problem this feature would solve?

Congrats on the 1.0.0 release!

I was testing a migration of a simple app, that has entrypoint defined in index.html and links to index.ts. Bun build by defaults targets web, but isn't able to handle this use-case. Contrary to eq. Vite, which even expects index.html.

Bun will treat html as an asset (as expected according to the docs) and generates index.js referencing it. But it won't do anything else further with the html itself.

Are there any plans in the future to act as a drop-in replacement in the bundler segment or is that a stretch and not on the roadmap?

What is the feature you are proposing to solve the problem?

Support index.html as an entrypoint and not just .ts or .js

What alternatives have you considered?

No response

fchamieh commented 1 year ago

I absolutely agree, html entry files are very common, and many bundlers support them as entry points.

tlrobinson commented 1 year ago

This is one of my favorite features of Parcel, along with hot module replacement.

It would also be really neat to integrate a Parcel-like dev server into Bun.serve() so you could just start your backend and frontend dev server together.

BjornTheProgrammer commented 1 year ago

In the meantime, I created an extension of the Bun bundler which is able to accept HTML files as entry points. Additionally, it can compile typescript files that are added in, to javascript automatically.

There still might be a few bugs here and there, but here is the GitHub link for bun-plugin-html. Feel free to leave bugs/enhancements in the issues tab.

fchamieh commented 1 year ago

In the meantime, I created an extension of the Bun bundler which is able to accept HTML files as entry points. Additionally, it can compile typescript files that are added in, to javascript automatically.

There still might be a few bugs here and there, but here is the GitHub link for bun-plugin-html. Feel free to leave bugs/enhancements in the issues tab.

Fantastic, great job!

humphd commented 1 year ago

I filed #1365, which is somewhat related to this. It's weird how bun index.html returns error: file not found "index.html".

It would be great if bun could do something more similar to Parcel here.

Mouradif commented 11 months ago

I though this was supported since Parcel is mentioned in the benchmarks,

150x faster than Parcel

I just got rid of my .parcelrc file and discovered it wasn't 😆

Yeah I just wanted to join the cause and add my little "+1" although I would be completely unable to help in such a PR

gevera commented 5 days ago

That's a bummer, I would like to compile a single bun binary that will contain my vite static spa which is index.html and bun runtime

Jarred-Sumner commented 5 days ago

@snoglobe will start working on this soon