thednp / bootstrap.native

Bootstrap components build with Typescript
http://thednp.github.io/bootstrap.native/
MIT License
1.7k stars 177 forks source link

Should not import the named export 'version' #468

Closed Cristialt closed 1 year ago

Cristialt commented 1 year ago

I'm using BSN in a big project

Webpack 5 BSN 4.2

getting

WARNING in ./node_modules/bootstrap.native/src/version.js 3:16-23
Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)
 @ ./_common/atoms/bootstrap-native/index.js 7:0-51 17:11-18
 @ ./ebb-portal/main.js 5:0-49

this could be easily fixed if changing node_modules/bootstrap.native/src/version.js

from

import { version } from '../package.json';
const Version = version;
export default Version;

to

import bsnPackage from '../package.json';
const Version = bsnPackage.version;
export default Version;

but obviously this is not a solution, so i'm wondering if there any config that could resolve this or should we just go ahead and create a merge request with this ^ fix?

thanks in advance!

thednp commented 1 year ago

If you would use Vite, a superior packer IMO, there wouldn't be any issue. However, you could also pack a custom BSN:

Create an index.[ts|js] file in your App, copy/paste and/or customize to your needs:

import {
  Alert, Button, // all components you want
  initCallback, removeDataAPI // all other stuff you need
} from 'bootstrap.native';

// OPTIONAL: Bulk initialize all components
if (document.body) initCallback();
else {
  document.addEventListener('DOMContentLoaded', initCallback, { once: true });
}

export default {
  Alert, Button,
  initCallback, removeDataAPI
}

Let me know how it goes.

Cristialt commented 1 year ago

Thanks @thednp, following your suggestion everything worked well this time just had to import { comps } from 'bootstrap.native/dist/bootstrap-native'