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(turbopack): Enable explicit_resource_management transform #73802

Merged
merged 5 commits into from
Dec 12, 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
8 changes: 8 additions & 0 deletions test/e2e/app-dir/ecmascript-features/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
11 changes: 11 additions & 0 deletions test/e2e/app-dir/ecmascript-features/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Disposer {
[Symbol.dispose]() {
console.log('Disposed')
}
}

export default function Page() {
using _disposer = new Disposer()

return <p>hello world</p>
}
14 changes: 14 additions & 0 deletions test/e2e/app-dir/ecmascript-features/ecmascript-features.test.ts
Original file line number Diff line number Diff line change
@@ -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')
})
})
6 changes: 6 additions & 0 deletions test/e2e/app-dir/ecmascript-features/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
2 changes: 2 additions & 0 deletions turbopack/crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
kdy1 marked this conversation as resolved.
Show resolved Hide resolved

let transform_context = TransformContext {
comments: &comments,
source_map: &source_map,
Expand Down
Loading