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: disable top level await #2358

Merged
merged 1 commit into from
Apr 24, 2024
Merged

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Apr 24, 2024

Disables experiments.topLevelAwait in the Webpack config. This was enabled by default in Webpack 5.83.0, but is unsupported in Snaps.

With this flag disabled, trying to build a Snap with top level await will result in:

  • Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enable it)
    File was processed with these loaders:
     * ../../node_modules/swc-loader/src/index.js
    You may need an additional loader to handle the result of these loaders.
    Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enable it)
        at .../node_modules/webpack/lib/dependencies/HarmonyDetectionParserPlugin.js:68:11
        at Hook.eval [as call] (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:16)
        at Hook.CALL_DELEGATE [as _call] (.../node_modules/tapable/lib/Hook.js:14:14)
        at JavascriptParser.walkAwaitExpression (.../node_modules/webpack/lib/javascript/JavascriptParser.js:2893:29)
        at JavascriptParser.walkExpression (.../node_modules/webpack/lib/javascript/JavascriptParser.js:2820:10)
        at JavascriptParser.walkLeftRightExpression (.../node_modules/webpack/lib/javascript/JavascriptParser.js:3061:8)
        at JavascriptParser.walkLogicalExpression (.../node_modules/webpack/lib/javascript/JavascriptParser.js:3080:9)
        at JavascriptParser.walkExpression (.../node_modules/webpack/lib/javascript/JavascriptParser.js:2847:10)
        at JavascriptParser.walkVariableDeclaration (.../node_modules/webpack/lib/javascript/JavascriptParser.js:2638:33)
        at JavascriptParser.walkStatement (.../node_modules/webpack/lib/javascript/JavascriptParser.js:1930:10)

Previously the Snap would build successfully but fail running in the client.

@FrederikBolding FrederikBolding requested a review from a team as a code owner April 24, 2024 11:08
Copy link
Member

@Mrtenz Mrtenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a ticket about looking into improving the error message?

@FrederikBolding
Copy link
Member Author

#2359

@FrederikBolding FrederikBolding merged commit 706d7a1 into main Apr 24, 2024
148 checks passed
@FrederikBolding FrederikBolding deleted the fb/disable-top-level-await branch April 24, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants