Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

The keyword 'await' is reserved #79

Closed
krnlde opened this issue May 14, 2017 · 6 comments · Fixed by #83
Closed

The keyword 'await' is reserved #79

krnlde opened this issue May 14, 2017 · 6 comments · Fixed by #83

Comments

@krnlde
Copy link

krnlde commented May 14, 2017

Run this specimen through https://butternut.now.sh/?version=0.4.1

{
  await: function await() {}
}

// -> Error: The keyword 'await' is reserved (2:2)  bundle.js:324

Both await occurrences are perfectly valid and parsed correctly by Chrome (V8), butternut refuses to minify this.

This code is (essentially) used by the AsyncGenerator babel transform plugin.

@Rich-Harris
Copy link
Owner

Acorn won't parse it by default. The way we fixed this in Rollup was to add an acorn option where you could pass through the appropriate options:

const {code, map} = butternut.squash(source, {
  acorn: {
    allowReserved: true
  }
});

Might be tricky to do via the CLI though...

@krnlde
Copy link
Author

krnlde commented May 14, 2017

Mhm. Maybe it is better to inject this by default through butternut? What would be the downsides?

@Rich-Harris
Copy link
Owner

I was wondering the same. I feel like there must be a reason that Acorn disables it by default, but I'm having a hard time understanding what the dangers are. I guess we could do that, and revisit it if it causes any weird bugs for people

@krnlde
Copy link
Author

krnlde commented May 15, 2017

The dangers would be that all "future reserved keywords" are valid. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Future_reserved_keywords

I don't know what the implications are though.

@Rich-Harris
Copy link
Owner

I think that the worst case is that it would preserve any existing bugs in the code, it wouldn't ever introduce new ones (since the mangler avoids reserved words)

@krnlde
Copy link
Author

krnlde commented May 15, 2017

Sounds like a reasonable change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants