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

[PROGRESS] ES6/ES7 support roadmap #306

Closed
11 tasks done
thednp opened this issue Oct 9, 2019 · 30 comments
Closed
11 tasks done

[PROGRESS] ES6/ES7 support roadmap #306

thednp opened this issue Oct 9, 2019 · 30 comments
Labels
community question all in for feedback enhancement potential improvement help wanted need your suggestion

Comments

@thednp
Copy link
Owner

thednp commented Oct 9, 2019

Hello everyone. How you all doin? I want to open a public debate on developing/transitioning towards ES6/ES7 standard(s).

Progress

  • we need a new bundle builder (lib/bundle.js) to do ES6/ES7 index.js -> ES5 bootstrap-native.js compilation + uglify work, that's where YOU come in (rollup, babel, promise, whatever you need, bring it), thanks to @midzer we now have a rollup script introduce rollup bundler #326
  • debug and fix all issues resulted in removal of manual tokenization or other module import/link related issues
  • global object is now BSN = {components:[], initCallback(), supports[]}
  • Toast destroy() and dispose() methods are supposed to do the same
  • rename destroy() to dispose() method for all components
  • custom file headers // BSN | author | License style header for .min.js files
  • remove bower, all old code, code cleanup
  • rework polyfill.js for ES6/ES7, include it later into the rollup grinder
  • we need a full documentation for V4 page, the future main page of the project
  • wiki updates
  • evaluate and discuss code structure to find opportunities for new features and code quality improvements (constructor, private & public methods, etc)

Initial Notes

  • the main focus is going to be mainly V4, which means V3 development will come to an end
  • at the point where we have BSN V4 modernized with ES6/ES7, V3 main file will be renamed to bootstrap-native-legacy.js and moved to a BSN-V3-legacy branch
  • after BSN 3.0 stable release, our V3 will still be available on CDN links only for versions ^2.0.27
  • following the above, the main demo will switch to V4, with the addition of proper guidelines
  • the new documentation should include solutions for highly dynamic applications, I noticed devs ignore the wiki (probably it's not well organized?)
  • manual memoize/tokenization (Eg: element[styleString] comes back to element.style) will go away for easier module "connectivity",
  • following the above, JavaScript API strings (Eg: offsetTop, marginLeft) will all be removed, but essential utilities will remain untouched such as styleTip or event related utilities like emulateTransitionEnd and on, off
  • the expected size of the bootstrap-native.min.js will get back from ~20kb to around ~40kb, but the gzip size will decrease by about 7-10%
  • we open the opportunity to debate/suggest prototype structure per component (what's going public into this or what stays private)
  • all the above mentioned changes will surely require major changes to the build scripting for ES5 compatibility
  • developer PRs are highly encouraged, but ONLY after a prior discussion

Please join, I need to know your key points, availability and any suggestion.

This is a draft, expect changes

@thednp thednp added enhancement potential improvement help wanted need your suggestion community question all in for feedback labels Oct 9, 2019
@thednp thednp added this to the 3.0 milestone Oct 9, 2019
@midzer
Copy link
Contributor

midzer commented Oct 10, 2019

Heyo,

tbh I'm in no hurry with ES6/ES7 code base transition. The real benefit I realize from your post is a gzip reduction which I welcome ofc. Where do you have the numbers from? From my experience libraries tend to get larger, but this is just my observation.

Upcoming Bootstrap v5 might bring additional work to bsn already. We should focus on this task first, I think

@thednp
Copy link
Owner Author

thednp commented Oct 10, 2019

@midzer in regards to manual tokenization, check this out #269.

I think BS5 will come with ES6/ES7 sources, no jQuery dependency, and mostly minor tweaks to components for usability, accessibility and hopefully less or no dependency.

As for the hurry aspect, I think it's a good time to gather around and have a little chat about it, put some ideas on paper and come with a plan. We're not competing with original script, we try and make it better in some ways.

@thednp
Copy link
Owner Author

thednp commented Oct 28, 2019

I have a first proposal for our components: how about the possibility to enable using Tooltip / Popover simultaneously with other components like Modal, Dropdown, Collapse, Button and Tab.

The solution is simple: we just use a different markup for Tooltip and Popover targets. For instance Carousel uses data-ride="carousel" or Alert / Toast use data-dismiss attribute.
We can just use data-tip="tooltip" and data-tip="popover".

I know this would be quite the difference with the original plugins, but I think it's necessary in order to enable this functionality, so please let me know what you think about it.

@cvaize
Copy link
Contributor

cvaize commented Dec 23, 2019

What do you mean "simultaneously with other components"? Do you want to use Modal , Dropdown , Collapse , Button and Tab in Tooltip (in tooltip-inner)?

@cvaize
Copy link
Contributor

cvaize commented Dec 23, 2019

I suggest to apply architecture of import of components, with possibility to include in bundle only the components necessary to the developer. Now the bundle always includes all the components. When switching to ES6/ES7 using import Name Component from 'bootstrap.native/NameComponent.js' and changing the approach to stand-alone components we will allow developers to choose which components they will use in the project, thereby reducing the size of the bundle. As a tool for assembling and shaking the tree, I suggest using "rollup".

@thednp
Copy link
Owner Author

thednp commented Dec 23, 2019

What do you mean "simultaneously with other components"? Do you want to use Modal , Dropdown , Collapse , Button and Tab in Tooltip (in tooltip-inner)?

Dropdown with Tooltip, Modal with Tooltip, Button with Tooltip would be nice, however Dropdown and Modal may not be needed. I'm thinking of combinations that make sense.

I suggest to apply architecture of import of components, with possibility to include in bundle only the components necessary to the developer. Now the bundle always includes all the components. When switching to ES6/ES7 using import Name Component from 'bootstrap.native/NameComponent.js' and changing the approach to stand-alone components we will allow developers to choose which components they will use in the project, thereby reducing the size of the bundle. As a tool for assembling and shaking the tree, I suggest using "rollup".

No, you can build a bundle with only or except the components you want, while the ES6/ES7 standard will make this possibly easier to create builds. But mostly I agree with your suggestions.

thednp added a commit that referenced this issue Dec 31, 2019
* added first ES6/ES7 code draft to `lib/src` folder, the following changes apply
* all components have `destroy()` method
* recent fixes to allow re-init are included (on re-init we trigger `destroy()` before anything else)
* more clear init objects ( in essence we're talking `{chaos,options,methods}` -> `{element,target,options,methods}` )
* removed manual tokenization, resulting in easier long term maintenance, the min files will be larger while gzip files should be 7-10% smaller, now @mustafa0x should be happy #269
* replaced `getClosest()` utility with native `element.closest(selector)`
* Popover and Tooltip now both use `options.template` and make use of attributes like `data-title` to fill in the template markup
* Popover and Tooltip can work simultaneously with other `data-toggle` components via `data-tip="tooltip"` and `data-tip="popover"` attributes (Modal,Dropdown,Tab,Collapse)

TO DO (priority ordered):
* debug and fix all issues resulted in removal of manual tokenization or other module import/link related issues
* evaluate and discuss code structure to find opportunities for new features and code quality improvements (constructor, private & public methods, etc)
* Toast component: aren't `destroy()` and `dispose()` methods supposed to do the same?
* we need a new ES6/ES7 friendly `initCallback`, we might also need an ES6/ES7 friendly `removeDataAPI` for all components, the opposite of `initCallback`, a possible draft at `src/util/callbacks.js`
* we need a new bundle builder (lib/bundle.js) to do ES6/ES7 `index.js` -> ES5 `bootstrap-native.js` compilation + uglify work, that's where YOU come in (rollup, babel, promise, whatever you need, bring it)
* we need a full documentation for V4 page, the future main page of the project
* wiki updates


@cvaize and everyone interested in this thread please join discussion here #306

Happy New Year!
thednp added a commit that referenced this issue Dec 31, 2019
* added first ES6/ES7 code draft to `lib/src` folder, the following changes apply
* all components have `destroy()` method
* recent fixes to allow re-init are included (on re-init we trigger `destroy()` before anything else)
* more clear init objects ( in essence we're talking `{chaos,options,methods}` -> `{element,target,options,methods}` )
* removed manual tokenization, resulting in easier long term maintenance, the min files will be larger while gzip files should be 7-10% smaller, now @mustafa0x should be happy #269
* replaced `getClosest()` utility with native `element.closest(selector)`
* Popover and Tooltip now both use `options.template` and make use of attributes like `data-title` to fill in the template markup
* Popover and Tooltip can work simultaneously with other `data-toggle` components via `data-tip="tooltip"` and `data-tip="popover"` attributes (Modal,Dropdown,Tab,Collapse)

TO DO (priority ordered):
* debug and fix all issues resulted in removal of manual tokenization or other module import/link related issues
* evaluate and discuss code structure to find opportunities for new features and code quality improvements (constructor, private & public methods, etc)
* Toast component: aren't `destroy()` and `dispose()` methods supposed to do the same?
* we need a new ES6/ES7 friendly `initCallback`, we might also need an ES6/ES7 friendly `removeDataAPI` for all components, the opposite of `initCallback`, a possible draft at `src/util/callbacks.js`
* we need a new bundle builder (lib/bundle.js) to do ES6/ES7 `index.js` -> ES5 `bootstrap-native.js` compilation + uglify work, that's where YOU come in (rollup, babel, promise, whatever you need, bring it)
* we need a full documentation for V4 page, the future main page of the project
* wiki updates


@cvaize and everyone interested in this thread please join discussion here #306

Happy New Year!
@midzer
Copy link
Contributor

midzer commented Jan 1, 2020

Howdy and Happy New Year!

Great work so far 👍

I'm just working on it to bring rollup bundler into the process. I'm gonna do a PR once I got something ready.

@thednp thednp changed the title [DRAFT] ES6/ES7 support roadmap [PROGRESS] ES6/ES7 support roadmap Jan 2, 2020
@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

Started testing es6/es7 code. I use rollup and laravel-mix module bundler. laravel-mix is a wrapper over webpack. At the moment, I want to immediately clarify why to place the initialization code in the components?
image
When initializing through importing only the necessary components it is not used.
image
I suggest that you put it in the General initialization file.

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

Write when I should start testing the health of all components. I plan to start tests on Chrome, Safary, Firefox, Safary (Iphone 5)(Old browser), Edge, IE11, IE10, IE9.

@thednp
Copy link
Owner Author

thednp commented Jan 2, 2020

@cvaize we're looking into ways to include components and their respective utils as well as initialization scripting. What would you suggest?

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

Just put the initialization in a shared file.
image

@thednp
Copy link
Owner Author

thednp commented Jan 2, 2020

Are you sure we're not adding it where we don't need it? Don't we need to filter that out if not needed? IDK, I'm just asking?

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

I am sure that in the component General initialization when I import it like this is not involved.
image
image

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

Most experienced developers import only the components they need, and our goal is to ensure that these components do not contain unused code.

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

At the moment, this is all, I will conduct performance tests in browsers when you write to me.

@thednp
Copy link
Owner Author

thednp commented Jan 2, 2020

I know, but just for me to know: rollup will try and remove unused code or just concat code that modules actually need?

Also how do you suggest we implement options for the rollup? (components to be used, add/remove init/remove)

How about using uglify instead of rollup-minify we use now? I hope we can do custom headers for the minified files.

@cvaize
Copy link
Contributor

cvaize commented Jan 2, 2020

I use webpack like millions of people do. Therefore, you should not rely only on rollup. From components it is necessary to remove the code of mass initialization I consider. People are more likely to import the component, put the element in the component constructor, and then manage the created object through its public methods.

@thednp
Copy link
Owner Author

thednp commented Jan 3, 2020

@cvaize and @midzer please test latest master and let me know if we can move on to the next part: documentation & wiki updates.

@cvaize
Copy link
Contributor

cvaize commented Jan 3, 2020

All right, I'll run tests soon.

@midzer
Copy link
Contributor

midzer commented Jan 3, 2020

According to https://medium.com/@kelin2025/so-you-wanna-use-es6-modules-714f48b3a953#dd9e conclusion we should prefer iife builds over (deprecated) umd builds. Furthermore package.json should have a module field.

I will give more feedback when I finished deep testing master in some of my projects.

@cvaize
Copy link
Contributor

cvaize commented Jan 3, 2020

The initial test in Google Chrome I finished, after fixing the bugs found, I will repeat the test. In the current test, I did not consider working with parameters. I'll test them in the next test.

@thednp
Copy link
Owner Author

thednp commented Jan 3, 2020

@cvaize my last couple days I've done alotta work and specifically testing component options, since I've changed init object structure, so you'll be surprised there.

@midzer I like how the iife builds look like :)

@cvaize
Copy link
Contributor

cvaize commented Jan 3, 2020

Checked the closed issue. I will continue the tests tomorrow, today I can not devote more time to them.

@cvaize
Copy link
Contributor

cvaize commented Jan 4, 2020

I will continue the tests tomorrow, today I can not devote more time to them.

@thednp
Copy link
Owner Author

thednp commented Feb 1, 2020

Guys what do you think of setting up an auto-polyfill script via babel.js?

@tamb
Copy link

tamb commented May 11, 2020

I'm kind of in favor of two approaches:

  1. completely ignore polyfills and recommend ones needed for specific components
  2. transpiling the library down to ES5 and use an autopolyfil script via babelrc.

@thednp thednp removed this from the 3.0 milestone May 30, 2020
@thednp thednp closed this as completed May 30, 2020
@swrobel
Copy link

swrobel commented Jun 2, 2020

Is the webpack loader still required? I ask because, although it's still mentioned in this project's README, it isn't marked as compatible (per peerDependencies) with the 3.x release of Bootstrap Native.

@thednp
Copy link
Owner Author

thednp commented Jun 3, 2020

It's not updated, I'm updating the README.md now.

@thednp
Copy link
Owner Author

thednp commented Jun 3, 2020

@swrobel do you have any suggestion on what that loader should look like considering the new library code base and build scripts?

@swrobel
Copy link

swrobel commented Jun 4, 2020

@thednp unfortunately not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community question all in for feedback enhancement potential improvement help wanted need your suggestion
Projects
None yet
Development

No branches or pull requests

5 participants