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

es6 Imports #146

Closed
gunins opened this issue Sep 5, 2017 · 5 comments
Closed

es6 Imports #146

gunins opened this issue Sep 5, 2017 · 5 comments

Comments

@gunins
Copy link

gunins commented Sep 5, 2017

Hi
Thanks, for very useful library. Any plans to replace require to es6 import? es6 import will be more natural, and since latest versions of chrome and nodejs is supporting them, will work on client and server.

@evilsoft
Copy link
Owner

evilsoft commented Sep 5, 2017

There are indeed plans, but even though the latest v8 version supports it now, need to wait for (2) things: AWS Lambda to move to the latest version of node and the rest of the browsers to catch up. One of the things I do personally, is bring in ramda and crocks functions into a "helpers" file where I:

export const State = require('crocks/State')
export const evolve = require('ramda/src/evolve')
...

// then I can
import { evolve, State } from '../utils/helpers'

There are other benefits to this approach (while we wait for the world to catch up). The problem is, it puts people who are not transpiling in the awkward position to have to require('crocks/Sum').default all over the place. Soon though, it will be a requirement to have this done before we go to 1.x.

That said, I am open to suggestions to avoid the .default thing and get this out sooner.

@evilsoft
Copy link
Owner

evilsoft commented Nov 8, 2017

@gunins Okay. Was talking with someone today and I have a solution to make every one happy.
Will have es6 module support in the next release.

@gunins
Copy link
Author

gunins commented Nov 8, 2017

That's will be great. New chrome and Nodejs support es6 modules nativelly.

Thanks!

@bennypowers
Copy link
Collaborator

Please consider appending the .js extention to import paths, which would allow importing crocks members directly in the browser, sans build-step.

<script type="module">
import Async from '/node_modules/crocks/src/Async/index.js';
</script>

date-fns follows this approach, see for example https://github.com/date-fns/date-fns/blob/master/src/esm/index.js

@dalefrancis88
Copy link
Collaborator

This seems to have a resolution, feel free to open if there is any more to add here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants