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

Can't compile "using" keyword in Turbopack Dev #73739

Closed
aidenlx opened this issue Dec 10, 2024 · 2 comments · Fixed by #73802
Closed

Can't compile "using" keyword in Turbopack Dev #73739

aidenlx opened this issue Dec 10, 2024 · 2 comments · Fixed by #73802
Assignees
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. linear: turbopack Confirmed issue that is tracked by the Turbopack team. locked Turbopack Related to Turbopack with Next.js.

Comments

@aidenlx
Copy link

aidenlx commented Dec 10, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/inspiring-liskov-r72y29

To Reproduce

Write some code with the using keyword (ECMAScript Explicit Resource Management), run dev server with --turbo option

e.g.

class Disposer {
  [Symbol.dispose]() {
    console.log("Disposed")
  }
}

export default function Page({ children }) {
  useEffect(() => {
    using disposer = new Disposer()
  }, [])
  
  return null
}

Current vs. Expected behavior

@ dev /project/workspace
next dev --turbo

▲ Next.js 15.0.4-canary.49 (Turbopack)

✓ Starting...
✓ Ready in 1205ms
○ Compiling / ...
✓ Compiled / in 2.7s
[Error: Failed to load chunk server/chunks/ssr/[root of the server]__64ec1c..js from parent module [project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/esm/build/templates/app-page.js?page=/page { METADATA_0 => "[project]/app/favicon.ico.mjs { IMAGE => "[project]/app/favicon.ico [app-rsc] (static)" } [app-rsc] (structured image object, ecmascript, Next.js server component)", MODULE_1 => "[project]/app/layout.tsx [app-rsc] (ecmascript, Next.js server component)", MODULE_2 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/not-found-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_3 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/forbidden-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_4 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/unauthorized-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_5 => "[project]/app/page.tsx [app-rsc] (ecmascript, Next.js server component)" } [app-rsc] (ecmascript) ] {
[cause]: SyntaxError: Unexpected identifier 'disposer'
at eval ()
}
⨯ unhandledRejection: [Error: Failed to load chunk server/chunks/ssr/[root of the server]__64ec1c.
.js from parent module [project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/esm/build/templates/app-page.js?page=/page { METADATA_0 => "[project]/app/favicon.ico.mjs { IMAGE => "[project]/app/favicon.ico [app-rsc] (static)" } [app-rsc] (structured image object, ecmascript, Next.js server component)", MODULE_1 => "[project]/app/layout.tsx [app-rsc] (ecmascript, Next.js server component)", MODULE_2 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/not-found-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_3 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/forbidden-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_4 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/unauthorized-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_5 => "[project]/app/page.tsx [app-rsc] (ecmascript, Next.js server component)" } [app-rsc] (ecmascript) ] {
[cause]: SyntaxError: Unexpected identifier 'disposer'
at eval ()
}
⨯ unhandledRejection: [Error: Failed to load chunk server/chunks/ssr/[root of the server]__64ec1c..js from parent module [project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/esm/build/templates/app-page.js?page=/page { METADATA_0 => "[project]/app/favicon.ico.mjs { IMAGE => "[project]/app/favicon.ico [app-rsc] (static)" } [app-rsc] (structured image object, ecmascript, Next.js server component)", MODULE_1 => "[project]/app/layout.tsx [app-rsc] (ecmascript, Next.js server component)", MODULE_2 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/not-found-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_3 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/forbidden-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_4 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/unauthorized-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_5 => "[project]/app/page.tsx [app-rsc] (ecmascript, Next.js server component)" } [app-rsc] (ecmascript) ] {
[cause]: SyntaxError: Unexpected identifier 'disposer'
at eval ()
}
⨯ [Error: Failed to load chunk server/chunks/ssr/[root of the server]__64ec1c.
.js from parent module [project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/esm/build/templates/app-page.js?page=/page { METADATA_0 => "[project]/app/favicon.ico.mjs { IMAGE => "[project]/app/favicon.ico [app-rsc] (static)" } [app-rsc] (structured image object, ecmascript, Next.js server component)", MODULE_1 => "[project]/app/layout.tsx [app-rsc] (ecmascript, Next.js server component)", MODULE_2 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/not-found-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_3 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/forbidden-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_4 => "[project]/node_modules/.pnpm/next@15.0.4-canary.49_react-dom@19.0.0_react@19.0.0/node_modules/next/dist/client/components/unauthorized-error.js [app-rsc] (ecmascript, Next.js server component)", MODULE_5 => "[project]/app/page.tsx [app-rsc] (ecmascript, Next.js server component)" } [app-rsc] (ecmascript) ] {
digest: '2118425113',
[cause]: SyntaxError: Unexpected identifier 'disposer'
at eval ()
}
GET / 500 in 3134ms

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.4-canary.49 // Latest available version is detected (15.0.4-canary.49).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Developer Experience, Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

next dev --turbo does not even transplie the syntax even with explicit_resource_management: true enabled in swc

CleanShot 2024-11-19 at 22 07 39@2x

@aidenlx aidenlx added the bug Issue was opened via the bug report template. label Dec 10, 2024
@github-actions github-actions bot added Developer Experience Issues related to Next.js logs, Error overlay, etc. Turbopack Related to Turbopack with Next.js. labels Dec 10, 2024
@mischnic mischnic added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Dec 10, 2024
@aidenlx
Copy link
Author

aidenlx commented Dec 10, 2024

It might be helpful to add a test case to cover this issue, as the problem with using the keyword has gone unnoticed in turbopack dev server (a long-standing issue) and babel dev and build (#72584, versions 15.0.3–15.0.5, resolved in the latest canary release) before being reported.

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. linear: turbopack Confirmed issue that is tracked by the Turbopack team. locked Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants