Skip to content

Commit

Permalink
fix(turbopack): Enable explicit_resource_management transform (#73802)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Dec 12, 2024
1 parent 477e1e4 commit d63b909
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
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());

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

0 comments on commit d63b909

Please sign in to comment.