2

In my project semantic-version, I am exporting a UMD bundle with webpack.

When imported with <script src="bundles/semVersion.js"></script> in a HTML file, the interesting single class is then available under SemVersion.SemVersion() (<lib name>.<class name>()). How can I do to have it directly exposed as SimVersion()? (Actually like jQuery for example).

Thank you!

Bill
  • 143
  • 1
  • 10

1 Answers1

2

webpack has export option to export whatever in your library. It can be used in your case where a class as being exported as default.

{
    output: {
        library: {
            name: 'SemVersion',
            type: 'umd',
             // add this to export your class to the library
            export: "default"
        },
    },
}
tmhao2005
  • 14,776
  • 2
  • 37
  • 44