os-js / osjs-gui

OS.js GUI Module
https://manual.os-js.org/v3/
Other
18 stars 10 forks source link

Provide UMD in 'window' by default #11

Open andersevenrud opened 5 years ago

andersevenrud commented 5 years ago

To prevent additional build sizes of applications, @osjs/gui could be provded by the service provider this package provides via window.osjsGui just as the UMD module does.

As far as I know there's no way to use a webpack generated module as both a global and included module. So if I were to do window.osjsGui = osjsGui where import * as osjsGui from 'index.js' would not create a ES5 compatible object since they all will be of the type Module.

Would be nice to sort this out without loading an additional @osjs/gui bundle file.


This way apps can just use this in the webpack config instead of having it as a dependency:

module.export = {
  externals: {
    '@osjs/gui': 'osjsGui'
  }
};

No changes required in the actual implementations:

import {foo} from '@osjs/gui';