Closed Sinewyk closed 6 years ago
Edit: No apparently moving the curry2
function call inside the findMatches
also does not work. More precisely Side effects in initialization of unused variable select [./node_modules/snabbdom-selector/lib/es6/index.js:3,0]
so, nothing gets dropped.
Split again or accept that we may need to somehow mark the function as pure so that tree shaker can do their thing. Probably.
For what's it's worth, some additional info around here https://gitter.im/cyclejs/cyclejs?at=59f2d81fd6c36fca31a16029.
IMO, for @cycle/dom
we should just export what's necessary to limit the abusive bundling and require just that in @cycle/dom
itself
It is possible to tackle this via tooling, we've had the same discussion in the most.js issues https://github.com/mostjs/core/issues/138 with an (still open) accompanying PR here: https://github.com/mostjs/core/pull/143.
Effectively it uses babel and a plugin babel-plugin-annotate-pure-calls which allows uglifyjs to know that a function is pure when it otherwise assumes it is impure which helps greatly with tree-shaking.
I've tried manually tagging so that
export const select = curry2(findMatches)
becomes
export const select = /*@__PURE__*/curry2(findMatches)
It did not help even though I saw the dropping PURE call or something in the warnings.
@Sinewyk could you share a repro? I've investigated those issues quite a bit and might be able to help identify the problem
That pulls everything (through, readable stream, process, Buffer, etc) various module bundlers, whether you have tree shaking activated or not.
Context: just updating from
@cycle/dom
19.2.0 to 19.3.0, which updated snabbdom-selector from 1 to 2, and updated the manner of the import https://github.com/cyclejs/cyclejs/commit/7af2b198269c3d480d64ab7a5e151ca7a161a967#diff-bba593365d0d8866a7ba95bfd04dd4a0R3 "broke" this.Many way to fix it I suppose. Just don't call curry2 in the index and instead curry inside findMatches ? Split files again ?