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

Feature Request: Don't require global bootstrap & Don't inject into global space #16

Open
wreiske opened this issue Jul 9, 2022 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@wreiske
Copy link

wreiske commented Jul 9, 2022

Hey!

Found your package today while working on new Bootstrap 5 project. I usually use the toastr npm package but wanted something that used the bootstrap 5 toasts. Glad to see a NPM for this! Thank you for your work!

While implementing, I ran into a few little issues. I use meteor for my projects and each individual js / template / layout / etc allows you to import just what you need for that bit of code. Instead of having everything as globals, you can keep the global namespace clean and keep your includes / dynamic imports to the pages that need it only.

My first instinct was to set up a layout like this:

import Toast from 'bootstrap-toaster';

Template.hello.onRendered(function() { 
    Toast.create({ title: 'Hello world!'});
});

This didn't work because the Toast package requires bootstrap to be global. It would be nice if the above example just worked.

I managed to get it working by doing the following:

bootstrap = require('bootstrap');
import Toast from 'bootstrap-toaster';

I'd love it if bootstrap wasn't global though!!

Now the Toast is on every page and in global when it doesn't need to be.

@PeytonRG
Copy link
Owner

PeytonRG commented Jul 10, 2022

Hey, thanks for trying it out!
I'm not familiar with meteor, but I have been trying to get the package to work as a js module. If you haven't already, take a look at the module-test branch and this 5.2.0 beta release.

One of the issues I've run into with it is the ability to have it work globally for people using it as a legacy script (i.e., the whole existing user base) and also have it work perfectly normally as a module so things like web pack, and I suppose meteor, can use. If you read through the notes on that release and know of a way to eliminate those issues, I'm all ears.

@PeytonRG PeytonRG self-assigned this Jul 10, 2022
@PeytonRG PeytonRG added the help wanted Extra attention is needed label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants