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

Version 2.37 dead code elimination broken on Rambda ES curry #3942

Closed
StreetStrider opened this issue Jan 30, 2021 · 2 comments · Fixed by #3944
Closed

Version 2.37 dead code elimination broken on Rambda ES curry #3942

StreetStrider opened this issue Jan 30, 2021 · 2 comments · Fixed by #3944

Comments

@StreetStrider
Copy link

  • Rollup Version: 2.37
  • Operating System (or Browser): GNU/Linux
  • Node Version (if applicable): v12.19.1
  • Link to reproduction (IMPORTANT, read below): rollup-dce-curry.zip

Hello! I've may tracked down dead code elimination eliminating the body of usual curry function. This leaves all curried functions broken. I've prepped test case where 2.36 works OK. Then, updating rollup to 2.37 draws the issue.

Expected Behavior

Update Rollup in test case to 2.37. Curried functions works as intended.

Actual Behavior

<function name> is not a function

@kzc
Copy link
Contributor

kzc commented Jan 30, 2021

The issue is related to module sideEffects.

Given:

$ rollup -v
rollup v2.38.1
$ cat node_modules/rambda/package.json 
{
  "sideEffects": false
}
$ cat node_modules/rambda/src/curry.js 
export function curry(fn, args = []){
  return (..._args) =>
    (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([
      ...args,
      ..._args,
    ])
}
$ cat input.js 
import {curry} from './node_modules/rambda/src/curry'
function foo() { console.log('Foo') }
let c = curry(foo);
c();

Correct output with no plugins:

$ rollup input.js --silent
function curry(fn, args = []){
  return (..._args) =>
    (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([
      ...args,
      ..._args,
    ])
}

function foo() { console.log('Foo'); }
let c = curry(foo);
c();

Incorrect output with the node-resolve plugin:

$ rollup input.js --silent -p node-resolve
function curry(fn, args = []){
}

function foo() { console.log('Foo'); }
let c = curry(foo);
c();

@lukastaegert
Copy link
Member

Thanks for the triage, fix at #3944

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.

3 participants