bootstrap-show-toast icon indicating copy to clipboard operation
bootstrap-show-toast copied to clipboard

How to use this plugin on node + vite bundle when using with type module

Open cancrexo opened this issue 2 years ago • 2 comments

Newbie here. Sorry for disturbing.

Trying to use this plugin with node using vite as bundler after npm install .. ¿how do i proceed to use the plugin?

Tried with import { showToast } from 'bootstrap'; or import bootstrap from 'bootstrap' ;

but on build always get same error:

error during build: RollupError: "default" is not exported by "node_modules/bootstrap/dist/js/bootstrap.esm.js", imported by...

Been googling around but cannot figure out how to find the answer

Thank you very much

cancrexo avatar Jul 31 '23 18:07 cancrexo

Hi @cancrexo, because showToast is not an ES6 module you could just import the file with import "./src/bootstrap-show-toast.js", then you should be able to bootstrap.showToast().

<script type="module">
    import "./src/bootstrap-show-toast.js"

    document.getElementById("button-show-simple").addEventListener("click", function () {
        bootstrap.showToast({body: "Hello Toast!"})
    })
</script>

shaack avatar Aug 01 '23 08:08 shaack

Thank you very much!. Will give it a try tonite.

cancrexo avatar Aug 01 '23 15:08 cancrexo