LinqToTypeScript icon indicating copy to clipboard operation
LinqToTypeScript copied to clipboard

esbuild outerLoop' error

Open mellogrand opened this issue 2 years ago • 7 comments

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

mellogrand avatar Dec 01 '23 15:12 mellogrand

Does this esbuild tool support continue label?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

arogozine avatar Dec 18 '23 04:12 arogozine

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 :)

nikel01 avatar Jan 26 '24 10:01 nikel01

Yeah, this just bit me as well. I'm also using Angular 17. Too bad.

Venom1991 avatar May 18 '24 14:05 Venom1991

@nikel01 Your code looks wrong, since you are only breakint 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

michaelmairegger avatar May 24 '24 10:05 michaelmairegger

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 avatar May 25 '24 02:05 evanw

@evanw I will try this and report back. Thanks

michaelmairegger avatar May 27 '24 12:05 michaelmairegger

Unfortunately installing esbuild or esbuild-wasm with the 0.21.5 as dev dependency does not solve the problem

michaelmairegger avatar Jun 13 '24 14:06 michaelmairegger