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

Generator definition shorthand outputs as function #316

Closed
webpack-bot opened this issue Jun 21, 2018 · 3 comments
Closed

Generator definition shorthand outputs as function #316

webpack-bot opened this issue Jun 21, 2018 · 3 comments

Comments

@webpack-bot
Copy link

Bug report

What is the current behavior?

The shorthand for defining a generator method in an object is sometimes parsed as a function. In some cases, this raises an uncaught syntax error in the browser (because keywords such as yield, yield* cannot be used in functions), causing the site to fail in executing the bundled js file.

If the current behavior is a bug, please provide the steps to reproduce.

Input src/index.js:

export const foo = {
  *bar() { return yield 'something' }
}

Output dist/main.js:

...const n={bar:()=>yield"something"}}]);

What is the expected behavior?

The output should be,

...const n={*bar(){return yield"something"}}}]);

Other relevant information:
webpack version: 4.12.0
Node.js version: v9.11.1
Operating System: Debian 9.4 stretch
Additional tools: -


This issue was moved from webpack/webpack#7566 by @sokra. Original issue was by @ningyuansg.

@alexander-akait
Copy link
Member

/cc @kzc need issue problem in terser?

@kzc
Copy link

kzc commented Jun 21, 2018

Likely already fixed in terser. You can test it yourself.

@alexander-akait
Copy link
Member

Close in favor #298

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

No branches or pull requests

3 participants