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

Experimental scope hoisting not removing dead code #2414

Closed
remko opened this issue Dec 14, 2018 · 1 comment · Fixed by #2418
Closed

Experimental scope hoisting not removing dead code #2414

remko opened this issue Dec 14, 2018 · 1 comment · Fixed by #2418

Comments

@remko
Copy link

remko commented Dec 14, 2018

🐛 bug report

I tried the math example from the 1.9.0 blog post to see if tree shaking worked. It doesn't seem to do anything for me.

🎛 Configuration (.babelrc, package.json, cli command)

No babel configuration.

Ran parcel with ./node_modules/.bin/parcel build --experimental-scope-hoisting index.js

🤔 Expected Behavior

Generate code without the sub function.

😯 Current Behavior

The sub function is there

(function () {function a(r,$){return r+$}function b(r,$){return r-$}a,b;console.log(a(2,3));})();

💻 Code Sample

Straight from the blog post:

// index.js
import { add } from "./math";

console.log(add(2, 3));
// math.js
export function add(a, b) {
  return a+ b;
}

export function sub(a, b) {
  return a - b;
}

🌍 Your Environment

Software Version(s)
Parcel 1.10.3
Node 11.1.0
npm/Yarn 1.12.1
Operating System Mac OS X 10.14.1
@mischnic
Copy link
Member

mischnic commented Dec 14, 2018

This seems to be a minimal example where treeshaking works correctly only with --no-minify actually (as in #2297):

(function() {
	// ASSET: math.js
	// math.js
	function $RK1r$export$add(a, b) {
		return a + b;
	}

	console.log($RK1r$export$add(2, 3));
})();

@remko remko changed the title Experimental code hoisting not removing dead code Experimental scope hoisting not removing dead code Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants