Why using an ember Addon wrap of a js library over using directly the js library

i am using bootstrap 5 in an ember application , i have imported bootstrap js in ember-cli-build.js app.import('node_modules/bootstrap/dist/js/bootstrap.bundle.min.js'); everthing is working well , only in tests the modals are rendered outside ember test rootElement , i am thinking to use ember-bootstrap instead , what could be the advantages of using ember-bootstrap ? thanks

It depends on the addon…

In the case of a simple library it’s not usually worth it now that we have ember-auto-import and embroider. But often an addon that wraps a library is more than just a shim to add that library to the build. It may provide Ember constructs like components or modifiers that help wrap that library in a declarative and Ember-idiomatic way.

ember-bootstrap is a larger addon which contains components purpose built to easily encapsulate bootstrap components, so the advantage to using it is that someone has already taken the time to integrate Bootstrap and Ember more seamlessly and wrap provide a nice idiomatic Ember API for Bootstrap components.

So it really depends on what you’re looking for. If you want to use Boostrap components pretty heavily it might be worth using the addon, if you just want some of the bootstrap bits maybe it’s easier to customize your integration yourself

1 Like

thank you for the clarification , then i will go for ember-bootstrap gradually, because it is a big project that i am migrating.

One of the things that i found also , is that the Js library is not working under Fastboot, so i am obliged to use the ember ad-don .

Ember Bootstrap is not a wrapper around Bootstrap JavaScript. The addon reimplements the Bootstrap core JavaScript using Ember core primitives like components, helpers and modifiers. It does not use any JavaScript of Bootstrap core. It only relies on Bootstrap CSS classes for which it also provides ways to import it in an Ember project.

3 Likes