diff options
author | 2021-12-16 17:57:13 -0800 | |
---|---|---|
committer | 2021-12-16 17:57:13 -0800 | |
commit | fde4cd4d1764994c4875507538d578c0ac576d74 (patch) | |
tree | 7b7bed80c07c1b10ba49a7a52f976afd5b055afa | |
parent | b6e164355b8da969abbcf166e5defea705fdb067 (diff) | |
download | bun-fde4cd4d1764994c4875507538d578c0ac576d74.tar.gz bun-fde4cd4d1764994c4875507538d578c0ac576d74.tar.zst bun-fde4cd4d1764994c4875507538d578c0ac576d74.zip |
Enable top-level await in browsers
-rw-r--r-- | src/bundler.zig | 4 | ||||
-rw-r--r-- | src/js_parser/js_parser.zig | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index b73dfbb78..c5e736498 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -2635,7 +2635,9 @@ pub const Bundler = struct { bundler.macro_context = js_ast.Macro.MacroContext.init(bundler); } - opts.features.top_level_await = bundler.options.platform.isBun(); + // we'll just always enable top-level await + // this is incorrect for Node.js files which are modules + opts.features.top_level_await = true; opts.macro_context = &bundler.macro_context.?; opts.macro_context.remap = this_parse.macro_remappings; diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index 809a97e26..356f040b2 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -15427,7 +15427,10 @@ pub fn NewParser( this.require_transposer = @TypeOf(this.require_transposer).init(this); this.require_resolve_transposer = @TypeOf(this.require_resolve_transposer).init(this); - if (opts.features.top_level_await) this.fn_or_arrow_data_parse.allow_await = .allow_expr; + if (opts.features.top_level_await) { + this.fn_or_arrow_data_parse.allow_await = .allow_expr; + this.fn_or_arrow_data_parse.is_top_level = true; + } } }; } |