Open mellogrand opened 9 months ago
Does this esbuild tool support continue label
?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
Firstly I want to say thank you for this great package. I have been really glad using it.
I am using Angular 17 and Node 20.11.0
It seems the issue comes from this file, when using esbuild.
import { IAsyncEnumerable, IAsyncEqualityComparer } from "../../types"
import { BasicAsyncEnumerable } from "../BasicAsyncEnumerable"
export const distinctAsync = <TSource>(
source: AsyncIterable<TSource>,
comparer: IAsyncEqualityComparer<TSource>): IAsyncEnumerable<TSource> => {
async function* iterator() {
const distinctElements: TSource[] = []
outerLoop:
for await (const item of source) {
for (const distinctElement of distinctElements) {
const found = await comparer(distinctElement, item)
if (found) {
continue outerLoop
}
}
distinctElements.push(item)
yield item
}
}
return new BasicAsyncEnumerable(iterator)
}
If the label and continue was replaced with a break statement, wouldn't the functionality be retained?
import { IAsyncEnumerable, IAsyncEqualityComparer } from "../../types"
import { BasicAsyncEnumerable } from "../BasicAsyncEnumerable"
export const distinctAsync = <TSource>(
source: AsyncIterable<TSource>,
comparer: IAsyncEqualityComparer<TSource>): IAsyncEnumerable<TSource> => {
async function* iterator() {
const distinctElements: TSource[] = []
for await (const item of source) {
for (const distinctElement of distinctElements) {
const found = await comparer(distinctElement, item)
if (found) {
break
}
}
distinctElements.push(item)
yield item
}
}
return new BasicAsyncEnumerable(iterator)
}
I have exactly 0 experience in writing advanced JavaScript and TypeScript as this packages is, so I do not know if this is dead wrong.
And thanks again for this npm package :)
Yeah, this just bit me as well. I'm also using Angular 17. Too bad.
@nikel01 Your code looks wrong, since you are only break
int the inner for loop, not the outer one. I have created a PR to address this issue
@arogozine The issue is introduced when swapping e.g. @angular-devkit/build-angular:browser
, @angular-devkit/build-angular:application
Hello! I'm the author of esbuild. FWIW I noticed this issue and just fixed this bug in esbuild: https://github.com/evanw/esbuild/releases/tag/v0.21.4. So another solution is potentially to update esbuild instead.
@evanw I will try this and report back. Thanks
Unfortunately installing esbuild or esbuild-wasm with the 0.21.5 as dev dependency does not solve the problem
moving to angular 17 i get a blocking issue using esbuild (does not happen with webpack) Illegal continue statement: 'outerLoop' does not denote an iteration statement
just wandering if this will affect your great job in the future thanks