question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect minify-empty-function?

See original GitHub issue

Why is foo(emptyFunction('how long', '?')); minified to foo(false)?

https://github.com/amasad/babel-minify/blob/0a37687f01fefeacace653d7537e132b386b79f3/packages/babel-plugin-minify-empty-function/__tests__/empty-function-test.js#L37

Is this test not final/functional? https://github.com/amasad/babel-minify/blob/0a37687f01fefeacace653d7537e132b386b79f3/packages/babel-plugin-minify-empty-function/__tests__/empty-function-test.js#L12

And where does this emptyFunction come from? It looks like it’s noop inserted by other plugins, but its usage might be confusing for direct users.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
fregantecommented, Jul 14, 2016

I’m still confused about the specificity of this transform. Verifying only the name makes it unsafe

This:

function emptyFunction() {
  return function () {};
}
var fn = emptyFunction();

would still transformed to:

function emptyFunction() {
  return function () {};
}
var fn = undefined;

It should probably test whether the function is actually a noop, or possible evaluate/resolve it properly like CC does

0reactions
amasadcommented, Jul 15, 2016

This is a copy from the internal FB transform which I believe does transform it to false if it’s part of larger expression. Agree that it doesn’t make much sense outside of FB. If this can be implemented via the replace plugin then great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature] Minify away function calls to empty functions #290
esbuild ex.js --define:__DEV__=false --minify function ... as for this issue, it seems safe to eliminate calls to empty functions and/or ...
Read more >
babel-plugin-minify-empty-function - npm
This is mostly a Facebook-specific transform that removes noop function calls. However, can be generalized to detect and remove noops.
Read more >
How to check if minification went wrong? - Stack Overflow
1 Answer 1 · Go to the Sources panel and selected your desired script from the scripts list. · Next, press the "Pretty...
Read more >
minify css and calc function broken - WordPress.org
i counted 41 calc() method calls in my CSS and that was the only one which got corrupted. So maybe its because its...
Read more >
rollup.js
Empty Import. Load the module code, but don't make any new objects available. import './module.js';. This is useful for polyfills, or when the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found