esm icon indicating copy to clipboard operation
esm copied to clipboard

Static getter in a class results in SyntaxError with esm 3.2.23

Open Tronil opened this issue 7 years ago • 9 comments

The following can no longer be loaded with the 3.2.23 release:

export class Foo
{
    static get bar()
    {
        return "Foo";
    }
}

If you try you get:

static get bar()
               ^

SyntaxError: Invalid or unexpected token
    at Object.Module._extensions..js (module.js:664:10)

It works with 3.2.22.

Tronil avatar May 16 '19 08:05 Tronil

Have the same problem

nanodracula avatar May 16 '19 11:05 nanodracula

I'm having a similar issue, works with 3.2.22 but not 3.2.23:

node_modules/puppeteer/lib/Page.js:44
    static async create(client, target, ignoreHTTPSErrors, defaultViewport, screenshotTaskQueue) {
                 ^

  SyntaxError: Invalid or unexpected token

ptb avatar May 16 '19 11:05 ptb

Yep, super sorry about that folks. Updated parsing support and missed smth. Will have it fixed in the next few hours.

jdalton avatar May 16 '19 13:05 jdalton

thanks guys for taking the time to report! looks like a regression.

@jdalton the following fail with v3.2.23.:

class Foo {
  static get bar() {}
  static set bar(val) {}
  static async afunc() {}
  static *gfunc() {}
  static async *agfunc() {}
}

dnalborczyk avatar May 16 '19 13:05 dnalborczyk

@jdalton uups, same time. 😄 btw, not sure if you noticed. the git release tags are tagged as 3.2.33 as supposed to 3.2.23.

dnalborczyk avatar May 16 '19 13:05 dnalborczyk

esm v3.2.24 is released 🎉

jdalton avatar May 16 '19 17:05 jdalton

Thanks for the fix @jdalton! I'm noticing some cases are still having trouble however.

$ node -r esm
> require('node-fetch')
/Users/brian.beck/Projects/node_modules/node-fetch/lib/index.js:899
	[Symbol.iterator]() {
                  ^

SyntaxError: Invalid or unexpected token

(that [Symbol.iterator]() method is on a class)

works fine on 3.2.22 and without esm!

exogen avatar May 16 '19 18:05 exogen

I'll throw that into the test mix too : )

jdalton avatar May 16 '19 18:05 jdalton

Ditto to @exogen comment with the same error.

andrewgremlich avatar May 16 '19 19:05 andrewgremlich