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

Uglification of React 16.7.0-alpha (with hooks) seems to be broken #3291

Closed
tshen8 opened this issue Nov 8, 2018 · 9 comments
Closed

Uglification of React 16.7.0-alpha (with hooks) seems to be broken #3291

tshen8 opened this issue Nov 8, 2018 · 9 comments

Comments

@tshen8
Copy link

tshen8 commented Nov 8, 2018

Bug report or feature request?
Bug report

Uglify version (uglifyjs -V)
uglify-js@3.4.9 (via uglify-js-webpack-plugin@2.0.1)

The following is React-DOM's 16.7.0-alpha code for pushing updates to their Component Update Queue (in React Fibre):

JavaScript input

function Gg(a, b, c, d) {
	a = {
		tag: a,
		create: b,
		destroy: c,
		inputs: d,
		next: null
	};
	null === R ? (R = {
		callbackList: null,
		lastEffect: null
	}, R.lastEffect = a.next = a) : (b = R.lastEffect, null === b ? R.lastEffect = a.next = a : (c = b.next, b.next = a, a.next = c, R.lastEffect = a));
	return a
}

The uglifyjs CLI command executed or minify() options used.
All the default options

JavaScript output or error produced.

  function Vo(e, t, n, r) {
    return e = {
      tag: e,
      create: t,
      destroy: n,
      inputs: r,
      next: null
    },
    jo.lastEffect = null === jo ? (jo = {
      callbackList: null,
      lastEffect: null
    },
    e.next = e) : null === (t = jo.lastEffect) ? e.next = e : (n = t.next,
    (t.next = e).next = n,
    e),
    e
  }

The error is trying to set lastEffect on the jo object, which has not yet been defined. Perhaps a result of UglifyJS trying to reduce the return statement?

Related Issues:
facebook/react#14014
webpack-contrib/uglifyjs-webpack-plugin#374

@kzc
Copy link
Contributor

kzc commented Nov 8, 2018

Does it work with terser?

@z4o4z
Copy link

z4o4z commented Nov 9, 2018

Hi @kzc, yep, it works with terser!

@kzc
Copy link
Contributor

kzc commented Nov 9, 2018

Unable to independently confirm that. Cannot reproduce the issue in uglify-js@3.4.9 with input provided and default minify options.

@tshen8
Copy link
Author

tshen8 commented Nov 15, 2018

@z4o4z terser worked great for me, thank you!

@tshen8
Copy link
Author

tshen8 commented Nov 15, 2018

@kzc The uglification was done through uglifyjs-webpack-plugin with default minify options on the entire React-DOM 16.7.0-alpha code.

Using uglifyjs directly on just the function doesn't seem to produce this issue. Hmm, I guess it must be something else in the file...

@cherscarlett
Copy link

Have this issue @starbucks as well, will be moving to terser.

@mgol
Copy link
Contributor

mgol commented Mar 12, 2019

@alexlamsl Why did you close it?

@alexlamsl
Copy link
Collaborator

@mgol the non-reproducible test case looks like #3271 etc., which is fixed by #3329

@krasimir
Copy link

I can confirm that terser has no this issue.

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

No branches or pull requests

7 participants