diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index e1d1727127..d243ff6904 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -4157,7 +4157,7 @@ pub const ParseTask = struct { // The definitions of __dispose and __asyncDispose match what esbuild's __wellKnownSymbol() helper does else => \\var __dispose = Symbol.dispose || /* @__PURE__ */ Symbol.for('Symbol.dispose'); - \\var __asyncDispose = Symbol.dispose || /* @__PURE__ */ Symbol.for('Symbol.dispose'); + \\var __asyncDispose = Symbol.asyncDispose || /* @__PURE__ */ Symbol.for('Symbol.asyncDispose'); \\ \\export var __using = (stack, value, async) => { \\ if (value != null) { diff --git a/test/bundler/bundler_browser.test.ts b/test/bundler/bundler_browser.test.ts index cabef30a77..1a3460431b 100644 --- a/test/bundler/bundler_browser.test.ts +++ b/test/bundler/bundler_browser.test.ts @@ -320,4 +320,46 @@ describe("bundler", () => { expect(contents).toBe(""); }, }); + + itBundled("browser/AwaitUsingStatement", { + files: { + "/entry.js": ` + async function test() { + await using resource = { + async [Symbol.asyncDispose]() { + console.log("The function was called"); + await 42; + console.log("and the await finished"); + } + }; + console.log("Before!"); + } + test(); + `, + }, + target: "browser", + run: { + stdout: "Before!\nThe function was called\nand the await finished\n", + }, + }); + + itBundled("browser/UsingStatement", { + files: { + "/entry.js": ` + function test() { + using resource = { + [Symbol.dispose]() { + console.log("The dispose function was called"); + } + }; + console.log("Before!"); + } + test(); + `, + }, + target: "browser", + run: { + stdout: "Before!\nThe dispose function was called\n", + }, + }); }); diff --git a/test/bundler/bundler_npm.test.ts b/test/bundler/bundler_npm.test.ts index 8e26c7ed33..5a4c2dea47 100644 --- a/test/bundler/bundler_npm.test.ts +++ b/test/bundler/bundler_npm.test.ts @@ -57,9 +57,9 @@ describe("bundler", () => { "../entry.tsx", ], mappings: [ - ["react.development.js:524:'getContextName'", "1:5426:Y1"], + ["react.development.js:524:'getContextName'", "1:5436:Y1"], ["react.development.js:2495:'actScopeDepth'", "23:4092:GJ++"], - ["react.development.js:696:''Component'", '1:7488:\'Component "%s"'], + ["react.development.js:696:''Component'", '1:7498:\'Component "%s"'], ["entry.tsx:6:'\"Content-Type\"'", '100:18849:"Content-Type"'], ["entry.tsx:11:''", "100:19103:void"], ["entry.tsx:23:'await'", "100:19203:await"], @@ -67,7 +67,7 @@ describe("bundler", () => { }, }, expectExactFilesize: { - "out/entry.js": 222164, + "out/entry.js": 222174, }, run: { stdout: "

Hello World

This is an example.

",