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 compatibility #245

Open
131 opened this issue Mar 29, 2016 · 8 comments
Open

ES6 compatibility #245

131 opened this issue Mar 29, 2016 · 8 comments

Comments

@131
Copy link

131 commented Mar 29, 2016

Async just move to ES6, and use lodash for tooling (since lodash provide ES6 compatibility). All our projects are moving to ES6 either. Is mout willing to evolve to this ?
Any draft/plans here ?

I can help !

@millermedeiros
Copy link
Member

@131 can you elaborate better your expectations? any special thing about ES6 that you would want us to support? is it just the module format or new features like Map/Set/etc?

@131
Copy link
Author

131 commented Apr 1, 2016

Well, it all start from "lodash did that, maybe mout should". Now that i think about it, i do not see much gain in it. (insert thinking/perplexed smiley here). Maybe you can just brand mout as ALREADY ES6 COMPATIBLE (& hashtag & buzzword & so ) !

@131 131 closed this as completed Apr 1, 2016
@roboshoes
Copy link
Member

roboshoes commented Aug 1, 2016

I'd like to open that issue. I think mout should in the future move to a ES6 import / export. Currently you can keep the file size pretty low by using this syntax"

var clamp = require( "mout/math/clamp" );

However, I believe going forward it would be nice to do things like:

import { clamp, map } from "mout/math";

In order to keep file size low and enable tree shaking we would need to implement ES6 export in files generated by the npm publishing scripts files.

Ideally we could even go as far as:

import { clamp } from "mout";

but that will cause several collisions of module names in different namespaces.

However, porting this should probably be another major release, as it's definitely breaking some code. Also makes me think if it should be changed to use at least commonJS as the default and slowly move away from AMD. I don't have any stats on how much of it gets used with requireJS these days, but my assumption would be very little.

@roboshoes roboshoes reopened this Aug 1, 2016
@niksy
Copy link

niksy commented Jul 18, 2018

What is the status of this issue? Will this be considered as standard consuming format? I don’t think it should be major problem converting this from (generated CommonJS) to ESM. There are also tools which can help with that. Would the maintainers consider implementing this and accepting help from community with this? I would also like to help with this!

@roboshoes
Copy link
Member

I'm actually very interested in this. I would potentially even go one step further and would love to add type information to this. I think we could potentially port this to TypeScript. with the advantage that we can generate the ES level that we are comfortable with. I considered simply writing types for it, but we might as well make it the real thing.

@niksy
Copy link

niksy commented Jul 19, 2018

Maybe go step by step? Setup new infrastructure around tooling, building, publishing and testing, implementing ESM as standard, and then adding types (maybe through community driven effort)?

@roboshoes
Copy link
Member

Right. We could add type information in separate files, but since we would add them to this repo anyway it seems like a round about way for me to maintain them.

The reason I suggested to go right to converting it to typescript is that we could skip the process of simply updating the import statement. Typescript compilation would then allow us to generate either level of ES5 or ES6 or ESnext and so forth.

I don't want to push this too hard, but if there is a chance that we end up converting them AND write type files, I'd strongly vote against it as it seems unnecessarily doubling the work.

That being said, if you want to "just" make a PR that converts the import to newer standards to news ones, I'm more than open to it. We have an elaborate test suite. This would go into a new major version, dropping AMD support or rather point users to 1.x version for AMD and 2.x for ES6 and higher.

@niksy
Copy link

niksy commented Apr 8, 2020

I’ve started with the initial conversion in #264!

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

4 participants