Skip to content
Open
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
8 changes: 6 additions & 2 deletions packages/bun-types/bun.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3054,9 +3054,13 @@ declare module "bun" {
/**
* Enable REPL mode transforms:
* - Wraps top-level inputs that appear to be object literals (inputs starting with '{' without trailing ';') in parentheses
* - Hoists all declarations as var for REPL persistence across vm.runInContext calls
* - Hoists the declarations the input wrote as var for REPL persistence across vm.runInContext calls.
* A helper import or a temporary that the transpiler adds stays inside the IIFE
* - Wraps last expression in { __proto__: null, value: expr } for result capture
* - Wraps code in sync/async IIFE to avoid parentheses around object literals
* - Wraps code in sync/async IIFE to avoid parentheses around object literals.
* The IIFE is async, and the result is a Promise, if the input has a top-level await or an import,
* or if the transpiler imports helpers for it (decorators, `accessor`, a lowered `using`, JSX with `autoImportJSX`).
* An import becomes an `import()` call: with `vm.runInContext`, pass `importModuleDynamically`
*
* @default false
*/
Expand Down
6 changes: 5 additions & 1 deletion src/js_parser/parse/parse_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,11 @@ impl<'a> Parser<'a> {
// because we only do tree-shaking on top-level statements and lowering
// a top-level "using" declaration moves all top-level statements into a
// nested scope.
if !p.options.tree_shaking || p.will_wrap_module_in_try_catch_for_using {
if !p.options.tree_shaking
|| p.will_wrap_module_in_try_catch_for_using
// The REPL transform moves all top-level statements into a function.
|| p.options.repl_mode
{
// When tree shaking is disabled, everything comes in a single part
p.append_part(&mut parts, stmts)?;
} else {
Expand Down
Loading
Loading