Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.35 KB

howtobundle.md

File metadata and controls

48 lines (34 loc) · 1.35 KB

Units Manager

A javascript library to split your code with web workers

How to bundle

Use bundler with code-splitting support.

Note, the library is not transpiled, so do not ignore it while transpiling your bundles.

With webpack, for example, you may use:

Inline syntax is supported:

const main = new Unit(Manager)();

main.add({
  // web worker thread
  // as function
  // will be loaded and resolved on demand
  one: () => import("worker-loader!./units/one.js"),
  // or as promise
  // will be resolved and loaded on demand
  one: import("worker-loader!./units/two"),

  // shared worker thread
  two: () => import("sharedworker-loader!./units/six"),
  // or as promise
  two: import("sharedworker-loader!./units/ten"),

  // service worker
  // will be activated for you
  ten: () => import("service-worker-loader!./units/ten"),
  // or as promise
  ten: import("service-worker-loader!./units/ten")
});

License

Copyright © 2019-2020 G. Schurovski

Licensed under the Apache-2.0 license.