From 85101aa87e9fe638ced72df353186c0e98241893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Dec 2024 01:17:48 +0900 Subject: [PATCH 1/5] unconditional --- turbopack/crates/turbopack-ecmascript/src/parse.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/turbopack/crates/turbopack-ecmascript/src/parse.rs b/turbopack/crates/turbopack-ecmascript/src/parse.rs index 0c9598de0434b..24e78604c8482 100644 --- a/turbopack/crates/turbopack-ecmascript/src/parse.rs +++ b/turbopack/crates/turbopack-ecmascript/src/parse.rs @@ -385,6 +385,8 @@ async fn parse_file_content( parsed_program.mutate(swc_core::ecma::lints::rules::lint_to_fold(rules)); drop(span); + parsed_program.mutate(swc_core::ecma::transforms::proposal::explicit_resource_management::explicit_resource_management()); + let transform_context = TransformContext { comments: &comments, source_map: &source_map, From 4b11aef964e9e52172b36cd0ea4d6a6df376a88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Dec 2024 01:35:25 +0900 Subject: [PATCH 2/5] test explicit resource management --- .../app-dir/ecmascript-features/app/layout.tsx | 8 ++++++++ test/e2e/app-dir/ecmascript-features/app/page.tsx | 15 +++++++++++++++ .../ecmascript-features.test.ts | 14 ++++++++++++++ .../app-dir/ecmascript-features/next.config.js | 6 ++++++ 4 files changed, 43 insertions(+) create mode 100644 test/e2e/app-dir/ecmascript-features/app/layout.tsx create mode 100644 test/e2e/app-dir/ecmascript-features/app/page.tsx create mode 100644 test/e2e/app-dir/ecmascript-features/ecmascript-features.test.ts create mode 100644 test/e2e/app-dir/ecmascript-features/next.config.js diff --git a/test/e2e/app-dir/ecmascript-features/app/layout.tsx b/test/e2e/app-dir/ecmascript-features/app/layout.tsx new file mode 100644 index 0000000000000..888614deda3ba --- /dev/null +++ b/test/e2e/app-dir/ecmascript-features/app/layout.tsx @@ -0,0 +1,8 @@ +import { ReactNode } from 'react' +export default function Root({ children }: { children: ReactNode }) { + return ( + + {children} + + ) +} diff --git a/test/e2e/app-dir/ecmascript-features/app/page.tsx b/test/e2e/app-dir/ecmascript-features/app/page.tsx new file mode 100644 index 0000000000000..afb128a4df9f6 --- /dev/null +++ b/test/e2e/app-dir/ecmascript-features/app/page.tsx @@ -0,0 +1,15 @@ +import { useEffect } from 'react' + +class Disposer { + [Symbol.dispose]() { + console.log('Disposed') + } +} + +export default function Page({ children }) { + useEffect(() => { + using _disposer = new Disposer() + }, []) + + return

hello world

+} diff --git a/test/e2e/app-dir/ecmascript-features/ecmascript-features.test.ts b/test/e2e/app-dir/ecmascript-features/ecmascript-features.test.ts new file mode 100644 index 0000000000000..675892753770a --- /dev/null +++ b/test/e2e/app-dir/ecmascript-features/ecmascript-features.test.ts @@ -0,0 +1,14 @@ +import { nextTestSetup } from 'e2e-utils' + +describe('ecmascript-features', () => { + const { next } = nextTestSetup({ + files: __dirname, + }) + + // In case you need to test the response object + it('should work with fetch', async () => { + const res = await next.fetch('/') + const html = await res.text() + expect(html).toContain('hello world') + }) +}) diff --git a/test/e2e/app-dir/ecmascript-features/next.config.js b/test/e2e/app-dir/ecmascript-features/next.config.js new file mode 100644 index 0000000000000..807126e4cf0bf --- /dev/null +++ b/test/e2e/app-dir/ecmascript-features/next.config.js @@ -0,0 +1,6 @@ +/** + * @type {import('next').NextConfig} + */ +const nextConfig = {} + +module.exports = nextConfig From 8521fcc36db945bea6aca06dc12d9b671920f1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Dec 2024 01:49:35 +0900 Subject: [PATCH 3/5] non-client --- test/e2e/app-dir/ecmascript-features/app/page.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/e2e/app-dir/ecmascript-features/app/page.tsx b/test/e2e/app-dir/ecmascript-features/app/page.tsx index afb128a4df9f6..bb5784bfb4a38 100644 --- a/test/e2e/app-dir/ecmascript-features/app/page.tsx +++ b/test/e2e/app-dir/ecmascript-features/app/page.tsx @@ -1,5 +1,3 @@ -import { useEffect } from 'react' - class Disposer { [Symbol.dispose]() { console.log('Disposed') @@ -7,9 +5,7 @@ class Disposer { } export default function Page({ children }) { - useEffect(() => { - using _disposer = new Disposer() - }, []) + using _disposer = new Disposer() return

hello world

} From 297d186d122a0422b5dff5a3039bd451ed436419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Dec 2024 01:53:37 +0900 Subject: [PATCH 4/5] rset CI From a2cb75a068b879dc1f79705988958f3ecd4de875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 12 Dec 2024 02:04:51 +0900 Subject: [PATCH 5/5] fix typing of the test case --- test/e2e/app-dir/ecmascript-features/app/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/app-dir/ecmascript-features/app/page.tsx b/test/e2e/app-dir/ecmascript-features/app/page.tsx index bb5784bfb4a38..43564185772ea 100644 --- a/test/e2e/app-dir/ecmascript-features/app/page.tsx +++ b/test/e2e/app-dir/ecmascript-features/app/page.tsx @@ -4,7 +4,7 @@ class Disposer { } } -export default function Page({ children }) { +export default function Page() { using _disposer = new Disposer() return

hello world