neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

Build library for the browser

Open aratcliffe opened this issue 2 years ago • 0 comments

Hi, I have a library which consists of a single class which is the default export from src/index.js. I'd like the built library to be able to be included via a browser script tag. It builds successfully but what is exported is a module not a class, so in order to use the class I need to reference it as Clusterer.default instead of just Clusterer. This is what my neutrinorc.js looks like:

const library = require("@neutrinojs/library");

module.exports = {
  options: {
    root: __dirname
  },
  use: [
    library({
      name: "Clusterer",
      libraryTarget: "window",
      target: "web"
    }),
    (neutrino) => neutrino.config.externals(undefined)
  ]
};

I'm sure this is super easy to configure but I'm struggling to see how to do it!

aratcliffe avatar Aug 04 '22 05:08 aratcliffe