Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] collapse_vars produces broken esm output #333

Closed
TrySound opened this issue Apr 17, 2019 · 6 comments · Fixed by #388
Closed

[bug] collapse_vars produces broken esm output #333

TrySound opened this issue Apr 17, 2019 · 6 comments · Fixed by #388
Labels

Comments

@TrySound
Copy link
Contributor

Bug report or Feature request?
bug

Version (complete output of terser -V)

terser 3.17.0

Complete CLI command or minify() options used

$ yarn terser file.js --compress --toplevel

terser input

function shortOut() {
  return function() {};
}

var setToString = shortOut();

var _setToString = setToString;

export function baseRest() {
  return _setToString();
}

export { _setToString };

terser prettified result

var _setToString,
  setToString = function() {};
export function baseRest() {
  return _setToString();
}
export { setToString as _setToString };

Expected result

var setToString = function() {};
export function baseRest() {
  return setToString();
}
export { setToString as _setToString };
@TrySound TrySound changed the title toplevel incorrectly works with esm [bug] toplevel incorrectly works with esm Apr 17, 2019
@TrySound TrySound changed the title [bug] toplevel incorrectly works with esm [bug] toplevel produces broken code esm output Apr 27, 2019
@TrySound TrySound changed the title [bug] toplevel produces broken code esm output [bug] toplevel produces broken esm output Apr 27, 2019
@TrySound TrySound changed the title [bug] toplevel produces broken esm output [bug] collapse-v produces broken esm output Apr 27, 2019
@TrySound TrySound changed the title [bug] collapse-v produces broken esm output [bug] collapse_vars produces broken esm output Apr 27, 2019
@L2jLiga
Copy link
Contributor

L2jLiga commented Jul 3, 2019

After investigations seems like this issue gone when module: true or toplevel: true

command: terser issue-333.js -c --module (or terser issue-333.js -c --toplevel)

input: same

output:

var _setToString = function () {};

export function baseRest() {
    return _setToString();
}

export { _setToString };

@TrySound
Copy link
Contributor Author

TrySound commented Jul 3, 2019

@L2jLiga Is it master or latest published version? I still get broken output with latest version.

@L2jLiga
Copy link
Contributor

L2jLiga commented Jul 3, 2019

I checked it on master branch, I guess (I have to recheck on which branch I was)

@L2jLiga
Copy link
Contributor

L2jLiga commented Jul 3, 2019

Hmm, I was wrong.. I took input from #343 and it's work with module: true but given in this issue example does not

@TrySound
Copy link
Contributor Author

TrySound commented Jul 3, 2019

I guess I oversimplified test

@L2jLiga
Copy link
Contributor

L2jLiga commented Jul 3, 2019

That's it: #388

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

Successfully merging a pull request may close this issue.

3 participants