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
Uglifyjs fix #1063
Uglifyjs fix #1063
Conversation
Did you try using preact-compat? I think this line https://github.com/developit/preact-compat/blob/master/src/index.js#L41 covers your issue. |
@yaodingyd Unfortunately that's not the case. Since the I added an example in my test environment here. This will log true. |
@ocboogie Just realize I didn't fully read your first comment. My bad! Will investigate more. |
What version of uglifyjs are you using? If it's >= 3, turn off the |
It looks like setting either |
I would prefer to solve this by documenting the issue - adding weight and cost to Preact to fix an Uglify bug isn't something we can do. Anyone want to take a swing at adding it to the docs? |
Anyone know if source position matters to Uglify here? Also is there an upstream bug we can track to know when Uglify fixes this? |
Note: I'm not quite sure if Preact is the problem.
I came across a problem using react-slick and preact. I got a
Uncaught TypeError: Cannot read property 'className' of undefined
, but the odd thing was I only got this error in production mode. So I looked into it and it turns out preact-compat wasn't mutating theVNode
. And the reason for that was Uglifyjs was not exposingVNode
anymore. SinceVNode
is an empty class and only used once, in theh
function, Uglifyjs makes it inline, likelet p = new function() {}();
so preact-compat can't access it.You can see this issue in action here.
So my fix(hack) for this issue was setting a property on
VNode
after it was declared, this way Uglifyjs doesn't make it inline. They're very well might be a more elegant way to fix this.