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

create a really nice tree-shakable ES module, with flow function #52

Closed
graingert opened this issue Oct 4, 2017 · 12 comments
Closed

create a really nice tree-shakable ES module, with flow function #52

graingert opened this issue Oct 4, 2017 · 12 comments

Comments

@graingert
Copy link

// ES
import * as ix from 'ix/es';

const fn = ix.flow(
  ix.from,
  ix.filter(x => x % 2 === 0),
  ix.map(x => x * x),
);

const results = fn([1, 2, 3]);

for (let item of results) {
  console.log(`Next: ${item}`);
}
@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

@graingert we support importing operators individually at the moment, but we also have work planned to export pipe-friendly variants of each operator.

You can also use the ix/iterable/__modules default export, which I think can be tree-shook automatically (if not, we can change this back to the export * form). We only use this module internally so the operator names survive minification so they're accessible to the tests (setup here), but they're also available in the Ix.internal UMD bundles.

We also recommend using babel-plugin-transform-imports to help decompose large explicit operator imports. Hope this helps!

@graingert
Copy link
Author

@trxcllnt the export default is not tree-shakeable.

@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

@graingert no problem then, we can change that easily enough.

It's a default export b/c closure-compiler doesn't work with export *, but considering we don't run the raw ES2015 through CC yet (we'd experimented, but CC ES6 support not ready), we can change it and figure that out later.

@graingert
Copy link
Author

@trxcllnt I'd like a true .mjs module available in the package.

@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

@graingert a true .mjs module

do you mind clarifying what you mean? we are publishing the es2015/ESModules compilation target as .mjs in the main ix package:

screen shot 2017-10-04 at 12 27 57 pm

@graingert
Copy link
Author

As apposed to one with a single default export, as in __module

@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

yeah one like this, right?

@graingert
Copy link
Author

Yes exactly like that

@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

yeah I said we can do that again

edit: oops, clicked the wrong button

@trxcllnt trxcllnt closed this as completed Oct 4, 2017
@trxcllnt trxcllnt reopened this Oct 4, 2017
@graingert
Copy link
Author

Nice, didn't know it was there

@graingert
Copy link
Author

graingert commented Oct 4, 2017

Should I open a new issue for curried, data-last functions?

@trxcllnt
Copy link
Member

trxcllnt commented Oct 4, 2017

@graingert nah we already got #23 and #46, so it's planned. would be happy to review a PR if you want to do the manual work of adding all the new pipe-aware impls (and if so, hmu cuz we have thoughts about how to make it less painful), but otherwise it'll happen when we have time.

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

2 participants