-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Add support for TC39 Explicit Resource Management (using
/await using
syntax)
#1528
Comments
Can you share a reproduction? I would have thought that this already works. |
here is the repro: https://github.com/aidenlx/using-test when running
|
Alright, so, this is an upstream issue with
Here's the actual code that does this, you can see it uses And here's magicast's list of babel plugins in use: You should open a PR over there adding the If you don't want to open a PR, the simple change is to not use // entrypoints/content/index.ts
import { main } from './main';
export default defineContentScript({
// ...
main,
}); // entrypoints/content/main.ts
import { ContentScriptContext } from 'wxt/client';
export function main(ctx: ContentScriptContext) {
using disposable = ...;
} |
Thank you for the quick and detailed explanation! Since magicast's development seems to be on pause currently (no commits in the last 8 months), I'll use the workaround you suggested by moving my code with the |
We could consider dropping magicast (and potentially any other dependencies that depend on babel) and use Edit: Looks like the OXC team needs to publish an napi binding for |
Additional React Component Compatibility IssueI've discovered that the the repro is updated with react preset: https://github.com/aidenlx/using-test
|
I'm not an expert with react... But that doesn't seem like it's something you should do. Just due to the nature of functional components, it seems like a bad idea. Especially if reacts vite plugin is telling you you can't do that. But that error is unrelated to WXT. |
Feature Request
Please support the
(await) using
syntax from the TC39 Explicit Resource Management proposal. Currently, attempting to use this syntax results in the error:This experimental syntax requires enabling the parser plugin: 'explicitResourceManagement'
.Is your feature request related to a bug?
N/A
What are the alternatives?
Alternative solutions I've considered:
@babel/plugin-syntax-explicit-resource-management
plugin, but I'm unsure how to properly integrate this with the wxt framework.Additional context
The Explicit Resource Management proposal (https://github.com/tc39/proposal-explicit-resource-management) is gaining significant adoption.
Current implementation status (from tc39/proposal-explicit-resource-management#242):
As this syntax is becoming standard across the JavaScript ecosystem, it would be valuable for wxt to support this modern language feature that improves resource management patterns.
The text was updated successfully, but these errors were encountered: