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 #72584

Closed
hazae41 opened this issue Nov 11, 2024 · 5 comments · Fixed by #73666
Closed

Can't compile "using" keyword #72584

hazae41 opened this issue Nov 11, 2024 · 5 comments · Fixed by #73666
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Output (export/standalone) Related to the the output option in `next.config.js`. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js.

Comments

@hazae41
Copy link

hazae41 commented Nov 11, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/shy-sound-kgyv86?file=%2Fapp%2Flayout.tsx%3A1%2C14

To Reproduce

Write some code with the using keyword

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

> build
> next build

   ▲ Next.js 15.0.4-canary.5

   Creating an optimized production build ...
Failed to compile.

./app/layout.tsx
Module not found: Can't resolve '@swc/helpers/_/_ts_add_disposable_resource'

https://nextjs.org/docs/messages/module-not-found

./app/layout.tsx
Module not found: Can't resolve '@swc/helpers/_/_ts_dispose_resources'

https://nextjs.org/docs/messages/module-not-found


> Build failed because of webpack errors

Provide environment information

Next.js 15.0.4-canary.5

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

Output (export/standalone), SWC, Webpack

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

next build (local)

Additional context

It works in 15.0.2, but not in 15.0.3 nor 15.0.4

@hazae41 hazae41 added the bug Issue was opened via the bug report template. label Nov 11, 2024
@github-actions github-actions bot added Output (export/standalone) Related to the the output option in `next.config.js`. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js. labels Nov 11, 2024
@aidenlx
Copy link

aidenlx commented Nov 19, 2024

additional report: next dev that use babel reports the same error in v15.0.4, and next dev --turbopack does not even transplie the syntax even with explicit_resource_management: true enabled in swc

PS: the official name for using keyword is ECMAScript Explicit Resource Management. may worth mentioning in description.

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

@aidenlx
Copy link

aidenlx commented Dec 2, 2024

seems like 15.0.3-canary.8 breaks the transpile. It may be related to swc_core update to v5.0.1

CleanShot 2024-12-02 at 16 36 20@2x

@aidenlx
Copy link

aidenlx commented Dec 2, 2024

may related: swc-project/swc#9673

@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Dec 2, 2024
@kdy1 kdy1 self-assigned this Dec 8, 2024
@kdy1 kdy1 closed this as completed in 0924393 Dec 9, 2024
@aidenlx
Copy link

aidenlx commented Dec 10, 2024

confirmed that it's fixed in 15.0.4-canary.49

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

It's still not fixed. I've opened a separate issue around turbopack dev server with using keyword in #73739

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 25, 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. linear: next Confirmed issue that is tracked by the Next.js team. locked Output (export/standalone) Related to the the output option in `next.config.js`. SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants