Avoid calling wasm parser immediately on widget module load. (#10688)

Fixes a race condition causing error in RC4:
```
index-ykDiQPdr.js:38 TypeError: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer')
```
This commit is contained in:
Paweł Grabarz 2024-07-26 16:38:42 +02:00 committed by GitHub
parent 340b22b84d
commit b95a390854
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,7 +64,7 @@ function makeLiteralFromUserInput(value: string): Ast.Owned<Ast.MutableTextLiter
}
}
const shownLiteral = computed(() => inputTextLiteral.value ?? emptyTextLiteral)
const shownLiteral = computed(() => inputTextLiteral.value ?? emptyTextLiteral.value)
const closeToken = computed(() => shownLiteral.value.close ?? shownLiteral.value.open)
const textContents = computed(() => shownLiteral.value.rawTextContent)
@ -73,7 +73,8 @@ watch(textContents, (value) => (editedContents.value = value))
</script>
<script lang="ts">
const emptyTextLiteral = makeNewLiteral('')
// Computed used intentionally to delay computation until wasm package is loaded.
const emptyTextLiteral = computed(() => makeNewLiteral(''))
function makeNewLiteral(value: string) {
return Ast.TextLiteral.new(value, MutableModule.Transient())
}