fabianlindfors / multi.js

A user-friendly replacement for select boxes with the multiple attribute enabled
https://fabianlindfors.se/multijs
MIT License
953 stars 76 forks source link

Es6 support #28

Closed dbleier closed 5 years ago

dbleier commented 5 years ago

I returned the original multi.js to the way it was since browsers don't support modules in standard script tags.

Then I created a new multi-es6.js which builds to dist/multi-es6.min.js which can be used for ES6 imports.

I also created an example in the examples folder called es6-import.html which is the same as basic.html except it is using the import.

Caveat with the example is you need to run it via a webserver (such as localhost). Running it as file:/// gave me a CORS error. I mention this on the example page.

fabianlindfors commented 5 years ago

This looks great, thanks!

Is there any way to achieve this without duplicating all the code across two files?

dbleier commented 5 years ago

I am not sure how without breaking existing implementations using script tags. And if I could pull from the multi var from the existing file into the new one, we wouldn't need to make this change at all.

I am not saying there isn't a way, but if there is, it is beyond me.

dbleier commented 5 years ago

hmm, I might have found a grunt task to do this.

dbleier commented 5 years ago

Here we go. I put just the export default multi; into it's own file and used the concat task to append it to multi and build to the multi-es6.min.js while leaving multi.js untouched.

fabianlindfors commented 5 years ago

Brilliant solution!

I see that you've also run a JS formatter on the code which I've been thinking of doing for so long. If I may ask, which style guide are you using? Would love to keep up the same style.

Big thanks for your help! I also bumped the version to 0.5.0 as I consider this a pretty major feature.

dbleier commented 5 years ago

Thanks, I use VSCode as my editor and it has a built in JS formatter that automatically formats the code every time I save.

Thanks for merging this.

dbleier commented 5 years ago

can you add 0.5.0 to the npm to I can install via npm?

dbleier commented 5 years ago

Hi, any time frame on when the new update will be available in npm? We kinda needs this asap.

fabianlindfors commented 5 years ago

Sorry! Been away from a computer for quite a while. Will publish it in a few hours!

Fabian Lindfors

5 dec. 2018 kl. 20:55 skrev Dovid Bleier notifications@github.com:

Hi, any time frame on when the new update will be available in npm? We kinda needs this asap.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

dbleier commented 5 years ago

ok, thanks.

fabianlindfors commented 5 years ago

0.5.0 is now available on npm!

dbleier commented 5 years ago

Jenkins builds not working great with 0.5.0 - thanks! It's a great plugin.