Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun build removes script html element if entrypoint html file doesn't have header element #16973

Open
darekzak opened this issue Feb 1, 2025 · 0 comments
Labels
bug Something isn't working bun:serve Bun.serve and HTTP server bundler Something to do with the bundler

Comments

@darekzak
Copy link

darekzak commented Feb 1, 2025

What version of Bun is running?

1.2.2-canary.3+26d3688e5

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

Run $ Bun build ./index.html --outdir=dist

<!doctype html>
<html>
  <body>
    test
    <script src="./app.ts" type="module"></script>
  </body>
</html>

If there is no <head></head> element inside ./index.html then in dist/index.html there is no

<script src="./app.ts" type="module"></script>

Additionally if there is head element inside ./index.html and script element is in body, then after running $ Bun build ./index.html --outdir=dist script element is being moved to head element.

What is the expected behavior?

After running $ Bun build ./index.html --outdir=dist html script element in dist/index.html should be in the same place where it was in ./index.html. So if it was in header, it should be in header. If it was inside body, it should stay there.

<script src="./app.ts" type="module"></script>

What do you see instead?

dist/index.html

<!doctype html>
<html>
  <body>
    test
    
  </body>
</html>

Additional information

No response

@darekzak darekzak added bug Something isn't working needs triage labels Feb 1, 2025
@RiskyMH RiskyMH added bundler Something to do with the bundler bun:serve Bun.serve and HTTP server and removed needs triage labels Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:serve Bun.serve and HTTP server bundler Something to do with the bundler
Projects
None yet
Development

No branches or pull requests

2 participants