For example, if you write the code (notice await in a comment):
// something something await
watch(() => result.data.value, data => {
}, { immediate: true })
The code here:
|
if (js.includes('await')) { |
|
js = js.replace(/\bawait\s/g, 'void ') |
|
} |
will produce the following code to get sent to esbuild:
// something something void watch(() => result.data.value, data => {
}, { immediate: true })
User will just see this error:
> /component.vue:53:9: error: Expected identifier but found "{"
53 │ }, { immediate: true })
╵ ^
error during build:
Error: Build failed with 1 error:
html:/component.vue:53:9: error: Expected identifier but found "{"
Does a proper parse need to happen to not secretly cause these issues or would a naive 'in comment' or 'in string' heuristic be good enough? At the very least it would maybe be nice to see what the code esbuild errored on but that seems non-trivial given it is just provided entries and then communicates back progress asynchronously?
For example, if you write the code (notice
awaitin a comment):The code here:
vite/packages/vite/src/node/optimizer/scan.ts
Lines 221 to 223 in d3142cf
will produce the following code to get sent to esbuild:
User will just see this error:
Does a proper parse need to happen to not secretly cause these issues or would a naive 'in comment' or 'in string' heuristic be good enough? At the very least it would maybe be nice to see what the code esbuild errored on but that seems non-trivial given it is just provided entries and then communicates back progress asynchronously?