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

fix excessive gleam.mjs generation #3238

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
anonymous function passed as an argument.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where the compiler would unnecessarily generate `gleam.mjs`,
confusing build tools like Vite
([Ofek Doitch](https://github.com/ofekd))

## v1.2.1 - 2024-05-30

### Bug Fixes
Expand Down
8 changes: 7 additions & 1 deletion compiler-core/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ impl<'a> JavaScript<'a> {
}
self.js_module(writer, module, &js_name)?
}
self.write_prelude(writer)?;

// This check skips unnecessary `gleam.mjs` writes which confuse
// watchers and HMR build tools
if !modules.is_empty() {
self.write_prelude(writer)?;
}
ofekd marked this conversation as resolved.
Show resolved Hide resolved

Ok(())
}

Expand Down
Loading